Skip to content

Commit

Permalink
fix pscale + obs issue (#467)
Browse files Browse the repository at this point in the history
* fix some issues

* fiix label issue, add debug logs

* add more debug

* more  debugg lines

* fix pscale issue

* remmove debug logs

* gofmt

* set available to 0 en deployment is not checked

* fix if check

---------

Co-authored-by: grosnj1 <[email protected]>
  • Loading branch information
JacobGros and grosnj1 authored Feb 14, 2024
1 parent d57f869 commit 8354a45
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
16 changes: 8 additions & 8 deletions controllers/csm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,16 @@ func (r *ContainerStorageModuleReconciler) handleDeploymentUpdate(oldObj interfa

//Replicas: 2 desired | 2 updated | 2 total | 2 available | 0 unavailable

log.Infow("deployment", "desired", desired)
log.Infow("deployment", "numberReady", ready)
log.Infow("deployment", "available", available)
log.Infow("deployment", "numberUnavailable", numberUnavailable)
log.Infow("deployment", "deployment name", d.Name, "desired", desired)
log.Infow("deployment", "deployment name", d.Name, "numberReady", ready)
log.Infow("deployment", "deployment name", d.Name, "available", available)
log.Infow("deployment", "deployment name", d.Name, "numberUnavailable", numberUnavailable)

ns := d.GetLabels()[modules.CSMNameSpace]
ns := d.Spec.Template.Labels[constants.CsmNamespaceLabel]
if ns == "" {
ns = d.Namespace
}
log.Debugw("deployment", "namespace", ns, "name", name)
log.Debugw("csm being modified in handledeployment", "namespace", ns, "name", name)
namespacedName := t1.NamespacedName{
Name: name,
Namespace: ns,
Expand Down Expand Up @@ -424,7 +424,7 @@ func (r *ContainerStorageModuleReconciler) handlePodsUpdate(oldObj interface{},
p, _ := obj.(*corev1.Pod)
name := p.GetLabels()[constants.CsmLabel]
//if this pod is an obs. pod, namespace might not match csm namespace
ns := p.GetLabels()[modules.CSMNameSpace]
ns := p.GetLabels()[constants.CsmNamespaceLabel]
if ns == "" {
ns = p.Namespace
}
Expand Down Expand Up @@ -491,7 +491,7 @@ func (r *ContainerStorageModuleReconciler) handleDaemonsetUpdate(oldObj interfac
log.Infow("daemonset ", "available", available)
log.Infow("daemonset ", "numberUnavailable", numberUnavailable)

ns := d.GetLabels()[modules.CSMNameSpace]
ns := d.Spec.Template.Labels[constants.CsmNamespaceLabel]
if ns == "" {
ns = d.Namespace
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ var PodStatusRemoveString = "rpc error: code = Unknown desc = Error response fro
// CsmLabel - label driver resources
var CsmLabel = "csm"

// CsmNamespaceLabel - label to track namespace for csm
var CsmNamespaceLabel = "csmNamespace"

// AccLabel - label client resources
var AccLabel = "acc"

Expand Down
21 changes: 14 additions & 7 deletions pkg/utils/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ func getDeploymentStatus(ctx context.Context, instance *csmv1.ContainerStorageMo
log.Infof("deployment status for cluster: %s", cluster.ClusterID)
msg += fmt.Sprintf("error message for %s \n", cluster.ClusterID)

if instance.Name == "" {
if instance.GetName() == "" || instance.GetName() == string(csmv1.Authorization) || instance.GetName() == string(csmv1.ApplicationMobility) {
log.Infof("Not a driver instance, will not check deploymentstatus")
return 0, csmv1.PodStatus{}, nil
return 0, csmv1.PodStatus{Available: "0"}, nil
}

err = cluster.ClusterCTRLClient.Get(ctx, t1.NamespacedName{Name: instance.GetControllerName(),
Namespace: instance.GetNamespace()}, deployment)
if err != nil {
return 0, csmv1.PodStatus{}, err
return 0, csmv1.PodStatus{Available: "0"}, err
}
log.Infof("Calculating status for deployment: %s", deployment.Name)
desired = deployment.Status.Replicas
Expand Down Expand Up @@ -402,7 +402,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() != string(csmv1.Authorization) {
if instance.GetName() != "" && instance.GetName() != string(csmv1.Authorization) {
expected, nodeStatus, daemonSetErr := getDaemonSetStatus(ctx, instance, r)
newStatus.NodeStatus = nodeStatus
if daemonSetErr != nil {
Expand Down Expand Up @@ -836,7 +836,6 @@ func appMobStatusCheck(ctx context.Context, instance *csmv1.ContainerStorageModu

// observabilityStatusCheck - calculate success state for observability module
func observabilityStatusCheck(ctx context.Context, instance *csmv1.ContainerStorageModule, r ReconcileCSM, _ *csmv1.ContainerStorageModuleStatus) (bool, error) {

topologyEnabled := false
otelEnabled := false
certEnabled := false
Expand All @@ -848,6 +847,14 @@ func observabilityStatusCheck(ctx context.Context, instance *csmv1.ContainerStor
metricsRunning := false
topologyRunning := false

driverName := instance.Spec.Driver.CSIDriverType

//TODO: PowerScale DriverType should be changed from "isilon" to "powerscale"
// this is a temporary fix until we can do that
if driverName == "isilon" {
driverName = "powerscale"
}

for _, m := range instance.Spec.Modules {
if m.Name == csmv1.Observability {
for _, c := range m.Components {
Expand All @@ -866,7 +873,7 @@ func observabilityStatusCheck(ctx context.Context, instance *csmv1.ContainerStor
certEnabled = true
}
}
if c.Name == fmt.Sprintf("metrics-%s", instance.Spec.Driver.CSIDriverType) {
if c.Name == fmt.Sprintf("metrics-%s", driverName) {
if *c.Enabled {
metricsEnabled = true
}
Expand Down Expand Up @@ -895,7 +902,7 @@ func observabilityStatusCheck(ctx context.Context, instance *csmv1.ContainerStor
if otelEnabled {
otelRunning = checkFn(&deployment)
}
case fmt.Sprintf("%s-metrics-%s", ObservabilityNamespace, instance.Spec.Driver.CSIDriverType):
case fmt.Sprintf("%s-metrics-%s", ObservabilityNamespace, driverName):
if metricsEnabled {
metricsRunning = checkFn(&deployment)
}
Expand Down

0 comments on commit 8354a45

Please sign in to comment.