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

Specify node-type during creating ClusterControlPlane #628

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ require (
github.com/vmware-tanzu/nsx-operator/pkg/client v0.0.0-20240102061654-537b080e159f
github.com/vmware-tanzu/vm-operator/api v1.8.2
github.com/vmware/govmomi v0.27.4
github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0
github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1-0.20240611083326-25a4e1834c4d
github.com/vmware/vsphere-automation-sdk-go/lib v0.7.1
github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0
go.uber.org/automaxprocs v1.5.3
Expand Down
4 changes: 3 additions & 1 deletion pkg/nsx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ const (
ServiceAccountRestore
ServiceAccountCertRotation
StaticRoute
NodeType
AllFeatures
)

var FeaturesName = [AllFeatures]string{"VPC", "SECURITY_POLICY", "NSX_SERVICE_ACCOUNT", "NSX_SERVICE_ACCOUNT_RESTORE", "NSX_SERVICE_ACCOUNT_CERT_ROTATION", "STATIC_ROUTE"}
var FeaturesName = [AllFeatures]string{"VPC", "SECURITY_POLICY", "NSX_SERVICE_ACCOUNT", "NSX_SERVICE_ACCOUNT_RESTORE", "NSX_SERVICE_ACCOUNT_CERT_ROTATION", "STATIC_ROUTE", "NODE_TYPE"}

type Client struct {
NsxConfig *config.NSXOperatorConfig
Expand Down Expand Up @@ -110,6 +111,7 @@ var (
nsx411Version = [3]int64{4, 1, 1}
nsx412Version = [3]int64{4, 1, 2}
nsx413Version = [3]int64{4, 1, 3}
nsx900Version = [3]int64{9, 0, 0}
)

type NSXHealthChecker struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/nsx/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ func (nsxVersion *NsxVersion) featureSupported(feature int) bool {
case ServiceAccountCertRotation:
minVersion = nsx413Version
validFeature = true
case NodeType:
minVersion = nsx900Version
validFeature = true
}

if validFeature {
Expand Down
13 changes: 11 additions & 2 deletions pkg/nsx/services/nsxserviceaccount/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
revision1 = int64(1)

proxyLabels = map[string]string{"mgmt-proxy.antrea-nsx.vmware.com": ""}

nodeTypeAntrea = "ANTREA_NODE"
)

type NSXServiceAccountService struct {
Expand Down Expand Up @@ -255,14 +257,21 @@
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) {
modelCCP.NodeType = &nodeTypeAntrea

Check failure on line 270 in pkg/nsx/services/nsxserviceaccount/cluster.go

View workflow job for this annotation

GitHub Actions / build

modelCCP.NodeType undefined (type "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model".ClusterControlPlane has no field or method NodeType)) (typecheck)

Check failure on line 270 in pkg/nsx/services/nsxserviceaccount/cluster.go

View workflow job for this annotation

GitHub Actions / build

modelCCP.NodeType undefined (type "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model".ClusterControlPlane has no field or method NodeType)) (typecheck)

Check failure on line 270 in pkg/nsx/services/nsxserviceaccount/cluster.go

View workflow job for this annotation

GitHub Actions / build

modelCCP.NodeType undefined (type "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model".ClusterControlPlane has no field or method NodeType)
}

ccp, err := s.NSXClient.ClusterControlPlanesClient.Update(siteId, enforcementpointId, normalizedClusterName, modelCCP)

err = nsxutil.NSXApiError(err)
if err != nil {
return "", err
Expand Down
9 changes: 7 additions & 2 deletions pkg/nsx/services/nsxserviceaccount/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@
ResourceType: &antreaClusterResourceType,
Certificate: nil,
VhcPath: &vpcPath,
NodeType: &nodeTypeAntrea,

Check failure on line 313 in pkg/nsx/services/nsxserviceaccount/cluster_test.go

View workflow job for this annotation

GitHub Actions / build

unknown field NodeType in struct literal of type "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model".ClusterControlPlane (typecheck)
Tags: []model.Tag{{
Scope: &tagScopeCluster,
Tag: &s.NSXConfig.CoeConfig.Cluster,
Expand All @@ -328,7 +329,7 @@
}})
patches.ApplyMethodSeq(s.NSXClient, "NSXCheckVersion", []gomonkey.OutputCell{{
Values: gomonkey.Params{true},
Times: 1,
Times: 2,
}})
return patches
},
Expand Down Expand Up @@ -446,7 +447,7 @@
}})
patches.ApplyMethodSeq(s.NSXClient, "NSXCheckVersion", []gomonkey.OutputCell{{
Values: gomonkey.Params{true},
Times: 1,
Times: 2,
}})
return patches
},
Expand Down Expand Up @@ -888,6 +889,10 @@
}, nil},
Times: 1,
}})
patches.ApplyMethodSeq(s.NSXClient, "NSXCheckVersion", []gomonkey.OutputCell{{
Values: gomonkey.Params{true},
Times: 1,
}})
return patches
},
args: args{
Expand Down
Loading