From d38fd1626ca7b8523c75ca4ae2330a58f59edebb Mon Sep 17 00:00:00 2001 From: wenqi Date: Fri, 13 Sep 2024 11:19:51 +0800 Subject: [PATCH] Remove EdgeMissingInProject from GatewayConnectionReady reason (#760) * Remove EdgeMissingInProject from GatewayConnectionReady reason Signed-off-by: Wenqi Qiu --- pkg/nsx/services/vpc/vpc.go | 19 ++---------------- pkg/nsx/services/vpc/vpc_test.go | 33 +------------------------------- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/pkg/nsx/services/vpc/vpc.go b/pkg/nsx/services/vpc/vpc.go index 926f2d484..f02328fea 100644 --- a/pkg/nsx/services/vpc/vpc.go +++ b/pkg/nsx/services/vpc/vpc.go @@ -825,21 +825,6 @@ func (s *VPCService) GetGatewayConnectionTypeFromConnectionPath(connectionPath s } func (s *VPCService) ValidateGatewayConnectionStatus(nc *common.VPCNetworkConfigInfo) (bool, string, error) { - // Case 1: the project has the full list of edge clusters, so if the project doesn't have edge, - // we can say that the edge is not deployed. - var projectEdges []string - project, err := s.NSXClient.ProjectClient.Get(nc.Org, nc.NSXProject, nil) - err = nsxutil.NSXApiError(err) - if err != nil { - return false, "", err - } - for _, siteInfo := range project.SiteInfos { - projectEdges = append(projectEdges, siteInfo.EdgeClusterPaths...) - } - if len(projectEdges) == 0 { - return false, common.ReasonEdgeMissingInProject, nil - } - var connectionPaths []string // i.e. gateway connection paths var profiles []model.VpcConnectivityProfile var cursor *string @@ -864,12 +849,12 @@ func (s *VPCService) ValidateGatewayConnectionStatus(nc *common.VPCNetworkConfig connectionPaths = append(connectionPaths, *attachment.ConnectionPath) } } - // Case 2: there's no gateway connection paths. + // Case 1: there's no gateway connection paths. if len(connectionPaths) == 0 { return false, common.ReasonGatewayConnectionNotSet, nil } - // Case 3: detected distributed gateway connection which is not supported. + // Case 2: detected distributed gateway connection which is not supported. for _, connectionPath := range connectionPaths { gatewayConnectionType, err := s.GetGatewayConnectionTypeFromConnectionPath(connectionPath) if err != nil { diff --git a/pkg/nsx/services/vpc/vpc_test.go b/pkg/nsx/services/vpc/vpc_test.go index 45f82fde3..9d4c313cd 100644 --- a/pkg/nsx/services/vpc/vpc_test.go +++ b/pkg/nsx/services/vpc/vpc_test.go @@ -646,26 +646,6 @@ func TestValidateGatewayConnectionStatus(t *testing.T) { expectedReason string expectedError error }{ - { - name: "EdgeMissingInProject", - prepareFunc: func(_ *testing.T, service *VPCService) (patches *gomonkey.Patches) { - patches = gomonkey.ApplyMethodSeq(reflect.TypeOf(service.NSXClient.ProjectClient), "Get", []gomonkey.OutputCell{{ - Values: gomonkey.Params{ - model.Project{}, - nil, - }, - Times: 1, - }}) - return patches - }, - vpcNetworkConfigInfo: common.VPCNetworkConfigInfo{ - Org: "default", - NSXProject: "project-quality", - }, - expectedReady: false, - expectedReason: "EdgeMissingInProject", - expectedError: nil, - }, { name: "GatewayConnectionNotSet", prepareFunc: func(_ *testing.T, service *VPCService) (patches *gomonkey.Patches) { @@ -728,18 +708,7 @@ func TestValidateGatewayConnectionStatus(t *testing.T) { { name: "DistributedGatewayConnectionNotSupported", prepareFunc: func(_ *testing.T, service *VPCService) (patches *gomonkey.Patches) { - patches = gomonkey.ApplyMethodSeq(reflect.TypeOf(service.NSXClient.ProjectClient), "Get", []gomonkey.OutputCell{{ - Values: gomonkey.Params{ - model.Project{ - SiteInfos: []model.SiteInfo{ - {EdgeClusterPaths: []string{"edge"}}, - }, - }, - nil, - }, - Times: 1, - }}) - patches.ApplyMethodSeq(reflect.TypeOf(service.NSXClient.VPCConnectivityProfilesClient), "List", []gomonkey.OutputCell{{ + patches = gomonkey.ApplyMethodSeq(reflect.TypeOf(service.NSXClient.VPCConnectivityProfilesClient), "List", []gomonkey.OutputCell{{ Values: gomonkey.Params{ model.VpcConnectivityProfileListResult{ Results: []model.VpcConnectivityProfile{