From 230837e287774363d6a5e6e37968cd0f05ada344 Mon Sep 17 00:00:00 2001 From: Wenqi Qiu Date: Thu, 11 Jul 2024 12:36:00 +0800 Subject: [PATCH] Update Signed-off-by: Wenqi Qiu --- go.mod | 14 +++++--------- go.sum | 16 ++++++++-------- pkg/nsx/client.go | 12 ++++++------ pkg/nsx/cluster.go | 2 +- pkg/nsx/services/nsxserviceaccount/cluster.go | 9 ++++++--- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index c3041bb04..770955f0b 100644 --- a/go.mod +++ b/go.mod @@ -7,14 +7,10 @@ replace ( github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1 => ./pkg/apis/v1alpha1 github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha2 => ./pkg/apis/v1alpha2 github.com/vmware-tanzu/nsx-operator/pkg/client => ./pkg/client - //github.com/vmware/vsphere-automation-sdk-go/lib => github.com/zhengxiexie/vsphere-automation-sdk-go/lib v0.7.3-0.20240628090521-3ad1af047210 - //github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/zhengxiexie/vsphere-automation-sdk-go/runtime v0.7.3-0.20240628090521-3ad1af047210 - //github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240628090521-3ad1af047210 - //github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/zhengxiexie/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240628090521-3ad1af047210 - github.com/vmware/vsphere-automation-sdk-go/lib => github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240707161013-a8f39aba7c1e - github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240707161013-a8f39aba7c1e - github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240707161013-a8f39aba7c1e - github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240707161013-a8f39aba7c1e + github.com/vmware/vsphere-automation-sdk-go/lib => github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240711034503-a008ff3b1f16 + github.com/vmware/vsphere-automation-sdk-go/runtime => github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240711034503-a008ff3b1f16 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt => github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240711034503-a008ff3b1f16 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp => github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240711034503-a008ff3b1f16 ) require ( @@ -49,6 +45,7 @@ require ( k8s.io/apimachinery v0.29.3 k8s.io/client-go v0.29.3 k8s.io/code-generator v0.29.3 + k8s.io/klog/v2 v2.110.1 sigs.k8s.io/controller-runtime v0.16.0 ) @@ -104,7 +101,6 @@ require ( k8s.io/apiextensions-apiserver v0.29.3 // indirect k8s.io/component-base v0.29.3 // indirect k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 // indirect - k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect diff --git a/go.sum b/go.sum index 20e16b320..5520ca2ef 100644 --- a/go.sum +++ b/go.sum @@ -182,14 +182,14 @@ github.com/vmware-tanzu/vm-operator/api v1.8.2/go.mod h1:vauVboD3sQxP+pb28TnI9wf github.com/vmware/govmomi v0.27.4 h1:5kY8TAkhB20lsjzrjE073eRb8+HixBI29PVMG5lxq6I= github.com/vmware/govmomi v0.27.4/go.mod h1:daTuJEcQosNMXYJOeku0qdBJP9SOLLWB3Mqz8THtv6o= github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk= -github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240707161013-a8f39aba7c1e h1:ZZaRftnZ4DP+220Ga4U6Y3/Vw5VXJ96xILvY0IOD1Wc= -github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240707161013-a8f39aba7c1e/go.mod h1:x4s3xpeRcJk6PTx9Xyb3LSDzHMLz9BKsA708vmss7MQ= -github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240707161013-a8f39aba7c1e h1:4GPHMUuBv7uPhg0bqwu3B/i1VZiIxOM8qHlEp58HLWk= -github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240707161013-a8f39aba7c1e/go.mod h1:DzLetYAmw1+vj7bqElRWEpuy40WYE/woL3alsymYa/c= -github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240707161013-a8f39aba7c1e h1:CxFT1A9bYXCj65epb0JYq3p2l4MearOvS0wn89WG0sk= -github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240707161013-a8f39aba7c1e/go.mod h1:5svFmx8JLpYUwXiAevMJ3mcu+OmEkBp/t3TlMXXbovw= -github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240707161013-a8f39aba7c1e h1:Qh0W4qbqiEOV9+HUxHRPz/uFfC/2g6Zr0LUjJRwIpME= -github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240707161013-a8f39aba7c1e/go.mod h1:KAXagEsQzxWVrf/W1FejwoGI0TFqCvtAlTl4skHnpU4= +github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240711034503-a008ff3b1f16 h1:KSgWYactid4NnlAlmZS+P+U5xW8Ci6UFrTz+RE3lEcc= +github.com/wenqiq/vsphere-automation-sdk-go/lib v0.7.3-0.20240711034503-a008ff3b1f16/go.mod h1:x4s3xpeRcJk6PTx9Xyb3LSDzHMLz9BKsA708vmss7MQ= +github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240711034503-a008ff3b1f16 h1:T/SlpoW90WLCBDObwHD6oEz2j8jGFQ3sH+3p3owB/CQ= +github.com/wenqiq/vsphere-automation-sdk-go/runtime v0.7.3-0.20240711034503-a008ff3b1f16/go.mod h1:DzLetYAmw1+vj7bqElRWEpuy40WYE/woL3alsymYa/c= +github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240711034503-a008ff3b1f16 h1:0kplISkgha3t4yocB+4K4mrkaaDmg3zvOWyYJSC0tC8= +github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt v0.12.3-0.20240711034503-a008ff3b1f16/go.mod h1:5svFmx8JLpYUwXiAevMJ3mcu+OmEkBp/t3TlMXXbovw= +github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240711034503-a008ff3b1f16 h1:1wRbltM387/RLbqeS+Im5Kk/6YSSUC3dqeeKpD92ehk= +github.com/wenqiq/vsphere-automation-sdk-go/services/nsxt-mp v0.6.3-0.20240711034503-a008ff3b1f16/go.mod h1:KAXagEsQzxWVrf/W1FejwoGI0TFqCvtAlTl4skHnpU4= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/pkg/nsx/client.go b/pkg/nsx/client.go index b1d7b54cd..230201df4 100644 --- a/pkg/nsx/client.go +++ b/pkg/nsx/client.go @@ -91,12 +91,12 @@ type Client struct { } var ( - nsx320Version = [3]int64{3, 2, 0} - nsx401Version = [3]int64{4, 0, 1} - nsx411Version = [3]int64{4, 1, 1} - nsx412Version = [3]int64{4, 1, 2} - nsx413Version = [3]int64{4, 1, 3} - nsx421Version = [3]int64{4, 2, 1} + nsx320Version = [3]int64{3, 2, 0} + nsx401Version = [3]int64{4, 0, 1} + nsx411Version = [3]int64{4, 1, 1} + nsx412Version = [3]int64{4, 1, 2} + nsx413Version = [3]int64{4, 1, 3} + nsxWithNodeTypeVersion = [3]int64{9, 0, 0} ) type NSXHealthChecker struct { diff --git a/pkg/nsx/cluster.go b/pkg/nsx/cluster.go index 6e235a010..8c0302c18 100644 --- a/pkg/nsx/cluster.go +++ b/pkg/nsx/cluster.go @@ -438,7 +438,7 @@ func (nsxVersion *NsxVersion) featureSupported(feature int) bool { minVersion = nsx411Version validFeature = true case NodeType: - minVersion = nsx421Version + minVersion = nsxWithNodeTypeVersion validFeature = true } diff --git a/pkg/nsx/services/nsxserviceaccount/cluster.go b/pkg/nsx/services/nsxserviceaccount/cluster.go index 122028b9e..3d4331c20 100644 --- a/pkg/nsx/services/nsxserviceaccount/cluster.go +++ b/pkg/nsx/services/nsxserviceaccount/cluster.go @@ -257,18 +257,21 @@ func (s *NSXServiceAccountService) createPIAndCCP(normalizedClusterName string, hasCCP := len(s.ClusterControlPlaneStore.GetByIndex(common.TagScopeNSXServiceAccountCRUID, string(obj.UID))) > 0 clusterId := "" if ccpObj := s.ClusterControlPlaneStore.GetByKey(normalizedClusterName); !hasCCP && ccpObj == nil { - ccp, err := s.NSXClient.ClusterControlPlanesClient.Update(siteId, enforcementpointId, normalizedClusterName, model.ClusterControlPlane{ + modelCCP := model.ClusterControlPlane{ Revision: &revision1, ResourceType: &antreaClusterResourceType, Certificate: &cert, VhcPath: &vpcPath, NodeId: existingClusterId, Tags: s.buildBasicTags(obj), - }) + } if s.NSXClient.NSXCheckVersion(nsx.NodeType) { - ccp.NodeType = &nodeTypeAntrea + modelCCP.NodeType = &nodeTypeAntrea } + + ccp, err := s.NSXClient.ClusterControlPlanesClient.Update(siteId, enforcementpointId, normalizedClusterName, modelCCP) + err = nsxutil.NSXApiError(err) if err != nil { return "", err