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

Fix the system VPCNetworkConfiguration update issue #5

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
26 changes: 12 additions & 14 deletions pkg/controllers/networkinfo/networkinfo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,20 @@
log.Error(err, "failed to get the gateway connection status", "req", req.NamespacedName)
return common.ResultRequeueAfter10sec, err
}

gatewayConnectionReason := ""
if !gatewayConnectionReady {
if ncName == commonservice.SystemVPCNetworkConfigurationName {
gatewayConnectionReady, gatewayConnectionReason, err = r.Service.ValidateGatewayConnectionStatus(&nc)
log.Info("got the gateway connection status", "gatewayConnectionReady", gatewayConnectionReady, "gatewayConnectionReason", gatewayConnectionReason)
if err != nil {
log.Error(err, "failed to validate the edge and gateway connection", "org", nc.Org, "project", nc.NSXProject)
updateFail(r, ctx, obj, &err, r.Client, nil)
return common.ResultRequeueAfter10sec, err
}
setVPCNetworkConfigurationStatusWithGatewayConnection(ctx, r.Client, vpcNetworkConfiguration, gatewayConnectionReady, gatewayConnectionReason)
} else {
log.Info("skipping reconciling the network info because the system gateway connection is not ready", "NetworkInfo", req.NamespacedName)
return common.ResultRequeueAfter60sec, nil
if ncName == commonservice.SystemVPCNetworkConfigurationName {
gatewayConnectionReady, gatewayConnectionReason, err = r.Service.ValidateGatewayConnectionStatus(&nc)
log.Info("got the gateway connection status", "gatewayConnectionReady", gatewayConnectionReady, "gatewayConnectionReason", gatewayConnectionReason)
if err != nil {
log.Error(err, "failed to validate the edge and gateway connection", "org", nc.Org, "project", nc.NSXProject)
updateFail(r, ctx, obj, &err, r.Client, nil)
return common.ResultRequeueAfter10sec, err

Check warning on line 103 in pkg/controllers/networkinfo/networkinfo_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/controllers/networkinfo/networkinfo_controller.go#L101-L103

Added lines #L101 - L103 were not covered by tests
}
setVPCNetworkConfigurationStatusWithGatewayConnection(ctx, r.Client, vpcNetworkConfiguration, gatewayConnectionReady, gatewayConnectionReason)
}
if !gatewayConnectionReady && ncName != commonservice.SystemVPCNetworkConfigurationName {
log.Info("skipping reconciling the network info because the system gateway connection is not ready", "NetworkInfo", req.NamespacedName)
return common.ResultRequeueAfter60sec, nil
}
lbProvider := r.Service.GetLBProvider()
createdVpc, err := r.Service.CreateOrUpdateVPC(obj, &nc, lbProvider)
Expand Down
1 change: 0 additions & 1 deletion pkg/controllers/networkinfo/networkinfo_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ func TestNetworkInfoReconciler_Reconcile(t *testing.T) {
return true, "", nil
})
patches.ApplyMethod(reflect.TypeOf(r.Service), "ValidateGatewayConnectionStatus", func(_ *vpc.VPCService, _ *servicecommon.VPCNetworkConfigInfo) (bool, string, error) {
assert.FailNow(t, "should not be called")
return true, "", nil
})
patches.ApplyMethod(reflect.TypeOf(r.Service), "CreateOrUpdateVPC", func(_ *vpc.VPCService, _ *v1alpha1.NetworkInfo, _ *servicecommon.VPCNetworkConfigInfo, _ vpc.LBProvider) (*model.Vpc, error) {
Expand Down
Loading