Skip to content

Commit

Permalink
Remove EdgeMissingInProject from GatewayConnectionReady reason (vmwar…
Browse files Browse the repository at this point in the history
…e-tanzu#760)

* Remove EdgeMissingInProject from GatewayConnectionReady reason

Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq authored Sep 13, 2024
1 parent 6ebcd77 commit d38fd16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 49 deletions.
19 changes: 2 additions & 17 deletions pkg/nsx/services/vpc/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
33 changes: 1 addition & 32 deletions pkg/nsx/services/vpc/vpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit d38fd16

Please sign in to comment.