Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New string generator for the hash string in NSX resources #995

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

wenyingd
Copy link
Contributor

@wenyingd wenyingd commented Jan 8, 2025

  1. Use chars 0-9,a-z,A-Z to generate the hash string for ID/DisplayName in NSX resources with VPC scenario. It also works on the Security Policy related resources' display name in T1.
  2. The length is 6 chars when using the new hash string function.

Test Done:

  1. VPC pipeline has passed, the supervisor is running, and the cluster status is ready.
  2. T1 pipeline has passed.

Manual Verification

  1. Created a subnetset with a long name which is longer than 80 char:
# k get subnetset -n antrea-test
NAME                                                                           ACCESSMODE   IPV4SUBNETSIZE   NETWORKADDRESSES
subnetset-sample-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa   Private      64               172.26.0.0/26
  1. Created a VM using the subnetset to enforce a NSX subnet is created,
  2. Check the NSX subnet configurations, and observed its display name is shorter than 80 chars and all chars are allowed.
{
    "ipv4_subnet_size": 64,
    "access_mode": "Private",
    "ip_addresses": [
        "172.26.0.0/26"
    ],
    "advanced_config": {
        "static_ip_allocation": {
            "enabled": true
        },
        "connectivity_state": "CONNECTED",
        "gateway_addresses": [
            "172.26.0.1/26"
        ]
    },
    "ip_blocks": [
        "/orgs/default/projects/project-quality/infra/ip-blocks/antrea-test_5110d687-625f-4d36-8a69-3642a46eaa15-172_26_0_0_16"
    ],
    "subnet_dhcp_config": {
        "mode": "DHCP_DEACTIVATED"
    },
    "resource_type": "VpcSubnet",
    "id": "subnetset-sample-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_ccfb9059-fc0f-4eb9-945e-10c525630f25_7316e37e",
    "display_name": "subnetset-sample-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_qepgkF_7316e37e",
    "tags": [
        {
            "scope": "nsx-op/cluster",
            "tag": "1ea68964-9a4a-465d-98ec-e0cf5b49088e"
        },
        {
            "scope": "nsx-op/version",
            "tag": "1.0.0"
        },
        {
            "scope": "nsx-op/subnetset_name",
            "tag": "subnetset-sample-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        },
        {
            "scope": "nsx-op/subnetset_uid",
            "tag": "ccfb9059-fc0f-4eb9-945e-10c525630f25"
        },
        {
            "scope": "nsx-op/vm_namespace_uid",
            "tag": "a15e101c-1fe0-4eb2-b6e2-6afba280fd2b"
        },
        {
            "scope": "nsx-op/vm_namespace",
            "tag": "antrea-test"
        },
        {
            "scope": "kubernetes.io/metadata.name",
            "tag": "antrea-test"
        },
        {
            "scope": "vSphereClusterID",
            "tag": "domain-c11"
        }
    ],
    "path": "/orgs/default/projects/project-quality/vpcs/antrea-test_5110d687-625f-4d36-8a69-3642a46eaa15/subnets/subnetset-sample-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_ccfb9059-fc0f-4eb9-945e-10c525630f25_7316e37e",
    "relative_path": "subnetset-sample-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa_ccfb9059-fc0f-4eb9-945e-10c525630f25_7316e37e",
    "parent_path": "/orgs/default/projects/project-quality/vpcs/antrea-test_5110d687-625f-4d36-8a69-3642a46eaa15",
    "remote_path": "",
    "unique_id": "4d32b77d-3b82-4e7d-9166-4415eb4b8159",
    "realization_id": "4d32b77d-3b82-4e7d-9166-4415eb4b8159",
    "owner_id": "4150403c-990c-42e0-8a99-719a8ade14f3",
    "marked_for_delete": false,
    "overridden": false,
    "_create_time": 1736481273138,
    "_create_user": "wcp-cluster-user-1ea68964-9a4a-465d-98ec-e0cf5b49088e-fc8ae4db-0e7e-44bd-848f-b5964f0f9af2",
    "_last_modified_time": 1736481273138,
    "_last_modified_user": "wcp-cluster-user-1ea68964-9a4a-465d-98ec-e0cf5b49088e-fc8ae4db-0e7e-44bd-848f-b5964f0f9af2",
    "_system_owned": false,
    "_protection": "REQUIRE_OVERRIDE",
    "_revision": 0
}

pkg/util/utils.go Outdated Show resolved Hide resolved
@wenyingd wenyingd force-pushed the update_id_hash branch 3 times, most recently from 2dcd646 to e6eeb57 Compare January 8, 2025 09:18
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.11%. Comparing base (ccc66e7) to head (b8425ed).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #995      +/-   ##
==========================================
+ Coverage   74.08%   74.11%   +0.03%     
==========================================
  Files         118      118              
  Lines       16362    16382      +20     
==========================================
+ Hits        12122    12142      +20     
  Misses       3466     3466              
  Partials      774      774              
Flag Coverage Δ
unit-tests 74.11% <100.00%> (+0.03%) ⬆️
Files with missing lines Coverage Δ
pkg/nsx/services/common/types.go 100.00% <ø> (ø)
pkg/util/utils.go 86.53% <100.00%> (+0.81%) ⬆️

@wenyingd wenyingd requested a review from gran-vmv January 8, 2025 10:32
pkg/util/utils.go Outdated Show resolved Hide resolved
pkg/util/utils.go Outdated Show resolved Hide resolved
pkg/util/utils.go Show resolved Hide resolved
pkg/util/utils.go Show resolved Hide resolved
@timdengyun
Copy link
Contributor

@wenyingd @lxiaopei I confirmed that we don't change ID for T1, so current change will not affect T1 case.

1. Use chars 0-9,a-z,A-Z to generate the hash string for ID/DisplayName in NSX
resources with VPC scenario. It also works on the Security Policy related
resources' display name in T1.
2. The length is 6 chars when using the new hash string function.
Copy link
Contributor

@timdengyun timdengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks wenying

@wenyingd
Copy link
Contributor Author

/e2e

1 similar comment
@wenyingd
Copy link
Contributor Author

/e2e

Copy link
Contributor

@lxiaopei lxiaopei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenyingd wenyingd merged commit 5546a6d into vmware-tanzu:main Jan 10, 2025
2 checks passed
wenyingd added a commit to wenyingd/nsx-operator that referenced this pull request Jan 10, 2025
…zu#995)

1. Use chars 0-9,a-z,A-Z to generate the hash string for ID/DisplayName in NSX
resources with VPC scenario. It also works on the Security Policy related
resources' display name in T1.
2. The length is 6 chars when using the new hash string function.
wenyingd added a commit that referenced this pull request Jan 10, 2025
1. Use chars 0-9,a-z,A-Z to generate the hash string for ID/DisplayName in NSX
resources with VPC scenario. It also works on the Security Policy related
resources' display name in T1.
2. The length is 6 chars when using the new hash string function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants