diff --git a/pkg/utils/status.go b/pkg/utils/status.go index 706519f9..c83269da 100644 --- a/pkg/utils/status.go +++ b/pkg/utils/status.go @@ -69,7 +69,7 @@ func getDeploymentStatus(ctx context.Context, instance *csmv1.ContainerStorageMo log.Infof("getting deployment status for cluster: %s", cluster.ClusterID) msg += fmt.Sprintf("error message for %s \n", cluster.ClusterID) - if instance.GetName() == "" || instance.GetName() == string(csmv1.Authorization) || instance.GetName() == string(csmv1.ApplicationMobility) { + if instance.GetName() == "" || isAuthorizationProxyServer(instance) || instance.GetName() == string(csmv1.ApplicationMobility) { log.Infof("Not a driver instance, will not check deploymentstatus") return emptyStatus, nil } @@ -218,7 +218,7 @@ func calculateState(ctx context.Context, instance *csmv1.ContainerStorageModule, // Auth proxy has no daemonset. Putting this if/else in here and setting nodeStatusGood to true by // default is a little hacky but will be fixed when we refactor the status code in CSM 1.10 or 1.11 log.Infof("instance.GetName() is %s", instance.GetName()) - if instance.GetName() != "" && instance.GetName() != string(csmv1.Authorization) && instance.GetName() != string(csmv1.ApplicationMobility) { + if instance.GetName() != "" && !isAuthorizationProxyServer(instance) && instance.GetName() != string(csmv1.ApplicationMobility) { expected, nodeStatus, daemonSetErr := getDaemonSetStatus(ctx, instance, r) newStatus.NodeStatus = nodeStatus if daemonSetErr != nil { @@ -768,10 +768,25 @@ func authProxyStatusCheck(ctx context.Context, instance *csmv1.ContainerStorageM log.Infof("%s component not running in auth proxy deployment", deployment.Name) return false, nil } + case "authorization-controller": + if !checkFn(&deployment) { + log.Infof("%s component not running in auth proxy deployment", deployment.Name) + return false, nil + } } + } log.Info("auth proxy deployment successful") return true, nil } + +func isAuthorizationProxyServer(cr *csmv1.ContainerStorageModule) bool { + for _, m := range cr.Spec.Modules { + if m.Name == csmv1.AuthorizationServer { + return true + } + } + return false +} diff --git a/pkg/utils/status_test.go b/pkg/utils/status_test.go index ee484fea..a8ea507d 100644 --- a/pkg/utils/status_test.go +++ b/pkg/utils/status_test.go @@ -72,10 +72,24 @@ func TestGetDeploymentStatus(t *testing.T) { wantErr: false, }, { - name: "Test getDeploymentStatus when instance name is authorization", + name: "Test getDeploymentStatus when instance is authorization proxy server", args: args{ ctx: context.Background(), - instance: createCSM(string(csmv1.Authorization), "", csmv1.PowerFlex, csmv1.Replication, true, nil), + instance: createCSM("authorization", "", "", csmv1.AuthorizationServer, true, nil), + r: &fakeReconcile, + }, + want: csmv1.PodStatus{ + Available: "0", + Desired: "0", + Failed: "0", + }, + wantErr: false, + }, + { + name: "Test getDeploymentStatus when instance is authorization proxy server with non-default name", + args: args{ + ctx: context.Background(), + instance: createCSM("csm-authorization", "", "", csmv1.AuthorizationServer, true, nil), r: &fakeReconcile, }, want: csmv1.PodStatus{ @@ -1262,6 +1276,19 @@ func TestAuthProxyStatusCheck(t *testing.T) { Replicas: &i32One, }, } + deployment11 := appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: "authorization-controller", + Namespace: "test-namespace", + }, + Status: appsv1.DeploymentStatus{ + ReadyReplicas: 1, + }, + Spec: appsv1.DeploymentSpec{ + Replicas: &i32One, + }, + } + err = ctrlClient.Create(ctx, &deployment1) assert.NoError(t, err, "failed to create client object during test setup") err = ctrlClient.Create(ctx, &deployment2) @@ -1282,6 +1309,8 @@ func TestAuthProxyStatusCheck(t *testing.T) { assert.NoError(t, err, "failed to create client object during test setup") err = ctrlClient.Create(ctx, &deployment10) assert.NoError(t, err, "failed to create client object during test setup") + err = ctrlClient.Create(ctx, &deployment11) + assert.NoError(t, err, "failed to create client object during test setup") // Create a fake instance of ReconcileCSM fakeReconcile := FakeReconcileCSM{