Skip to content

Commit

Permalink
return "default" if operator namespace not found in environment
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 committed Mar 4, 2024
1 parent 967e42b commit 5e2f90e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions controllers/k8ssandra/medusa_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,7 @@ func (r *K8ssandraClusterReconciler) reconcileMedusa(
return result.RequeueSoon(r.DefaultDelay)
}
// Create a cron job to purge Medusa backups
operatorNamespace, err := r.getOperatorNamespace()
if err != nil {
logger.Info("Failed to get Operator namespace", "error", err)
return result.Error(err)
}
operatorNamespace := r.getOperatorNamespace()
purgeCronJob, err := medusa.PurgeCronJob(dcConfig, kc.SanitizedName(), operatorNamespace, logger)
if err != nil {
logger.Info("Failed to create Medusa purge backups cronjob", "error", err)
Expand Down Expand Up @@ -331,10 +327,10 @@ func (r *K8ssandraClusterReconciler) reconcileBucketSecrets(
return nil
}

func (r *K8ssandraClusterReconciler) getOperatorNamespace() (string, error) {
func (r *K8ssandraClusterReconciler) getOperatorNamespace() string {
operatorNamespace, found := os.LookupEnv(operatorNamespaceEnvVar)
if !found {
return "", fmt.Errorf("environment variable %s not set", operatorNamespaceEnvVar)
return "default"
}
return string(operatorNamespace), nil
return operatorNamespace

Check warning on line 335 in controllers/k8ssandra/medusa_reconciler.go

View check run for this annotation

Codecov / codecov/patch

controllers/k8ssandra/medusa_reconciler.go#L335

Added line #L335 was not covered by tests
}

0 comments on commit 5e2f90e

Please sign in to comment.