Skip to content

Commit

Permalink
Merge pull request vmware-tanzu#916 from seanpang-vmware/seanpang-vmw…
Browse files Browse the repository at this point in the history
…are-v4.2.0

[cherry-pick]Merge pull request vmware-tanzu#828 from seanpang-vmware/removeip
  • Loading branch information
zhengxiexie authored Nov 21, 2024
2 parents 237518e + 847f978 commit 0e239dc
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
3 changes: 0 additions & 3 deletions build/yaml/crd/vpc/crd.nsx.vmware.com_networkinfos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ spec:
items:
type: string
type: array
vpcPath:
description: NSX Policy path for VPC.
type: string
required:
- defaultSNATIP
- name
Expand Down
1 change: 0 additions & 1 deletion build/yaml/samples/nsx_v1alpha1_networkinfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ vpcs:
name: vpc-d110d5aa-006d-4b59-9caf-424a4fba932c--kube-system
privateIPs:
- 172.26.0.0/16
vpcPath: /orgs/default/projects/project-quality/vpcs/19a8a52e-beb0-4396-91ce-5821a15a43db
2 changes: 0 additions & 2 deletions pkg/apis/vpc/v1alpha1/networkinfo_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ type VPCState struct {
LoadBalancerIPAddresses string `json:"loadBalancerIPAddresses,omitempty"`
// Private CIDRs used for the VPC.
PrivateIPs []string `json:"privateIPs,omitempty"`
// NSX Policy path for VPC.
VPCPath string `json:"vpcPath,omitempty"`
}

func init() {
Expand Down
1 change: 0 additions & 1 deletion pkg/controllers/networkinfo/networkinfo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ func (r *NetworkInfoReconciler) Reconcile(ctx context.Context, req ctrl.Request)
DefaultSNATIP: snatIP,
LoadBalancerIPAddresses: cidr,
PrivateIPs: privateIPs,
VPCPath: *createdVpc.Path,
}

// AKO needs to know the AVI subnet path created by NSX
Expand Down
12 changes: 6 additions & 6 deletions test/e2e/nsx_networkinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ func testUpdateVPCNetworkconfigNetworkInfo(t *testing.T) {
networkInfo := assureNetworkInfo(t, ns, ns)
require.NotNil(t, networkInfo)

networkInfoNew := getVPCPathFromNetworkInfo(t, ns, networkInfo.Name)
networkInfoNew := getNetworkInfoWithPrivateIPs(t, ns, networkInfo.Name)
privateIPs := networkInfoNew.VPCs[0].PrivateIPs
assert.Contains(t, privateIPs, customizedPrivateCIDR1, "privateIPs %s should contain %s", privateIPs, customizedPrivateCIDR1)
assert.Contains(t, privateIPs, customizedPrivateCIDR2, "privateIPs %s should contain %s", privateIPs, customizedPrivateCIDR1)

vncPath, _ := filepath.Abs("./manifest/testVPC/customize_networkconfig_updated.yaml")
require.NoError(t, applyYAML(vncPath, ""))

networkInfoNew = getVPCPathFromNetworkInfo(t, ns, networkInfo.Name)
networkInfoNew = getNetworkInfoWithPrivateIPs(t, ns, networkInfo.Name)
privateIPs = networkInfoNew.VPCs[0].PrivateIPs
assert.Contains(t, privateIPs, customizedPrivateCIDR3, "privateIPs %s should contain %s", privateIPs, customizedPrivateCIDR3)
}
Expand Down Expand Up @@ -264,16 +264,16 @@ func assureNamespaceDeleted(t *testing.T, ns string) {
return
}

func getVPCPathFromNetworkInfo(t *testing.T, ns, networkInfoName string) (networkInfo *v1alpha1.NetworkInfo) {
func getNetworkInfoWithPrivateIPs(t *testing.T, ns, networkInfoName string) (networkInfo *v1alpha1.NetworkInfo) {
deadlineCtx, deadlineCancel := context.WithTimeout(context.Background(), defaultTimeout)
defer deadlineCancel()
err := wait.PollUntilContextTimeout(deadlineCtx, 1*time.Second, defaultTimeout, false, func(ctx context.Context) (done bool, err error) {
networkInfo, err = testData.crdClientset.CrdV1alpha1().NetworkInfos(ns).Get(ctx, networkInfoName, v1.GetOptions{})
if err != nil {
log.Error(err, "Check VPC path of vpcnetworkconfigurations networkInfo", networkInfo)
return false, fmt.Errorf("error when waiting for vpcnetworkconfigurations VPC path: %s", networkInfoName)
t.Logf("Check private ips of networkinfo: %v, error: %+v", networkInfo, err)
return false, fmt.Errorf("error when waiting for vpcnetworkinfo private ips: %s", networkInfoName)
}
if len(networkInfo.VPCs) > 0 && networkInfo.VPCs[0].VPCPath != "" {
if len(networkInfo.VPCs) > 0 && len(networkInfo.VPCs[0].PrivateIPs) > 0 {
return true, nil
}
return false, nil
Expand Down

0 comments on commit 0e239dc

Please sign in to comment.