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

[bug-1737]: Check if CSM is Authorization Proxy Server by checking module name #893

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
19 changes: 17 additions & 2 deletions pkg/utils/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
33 changes: 31 additions & 2 deletions pkg/utils/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand All @@ -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{
Expand Down
Loading