Skip to content

Commit

Permalink
fix: Use backup namespace for clean job
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Mutel committed Apr 26, 2024
1 parent 11e4985 commit 0ab3d78
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG/CHANGELOG-1.16.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ When cutting a new release, update the `unreleased` heading to the tag being gen

## unreleased

* [BUGFIX] [#1272](https://github.com/k8ssandra/k8ssandra-operator/issues/1272) Prevent cass-operator from creating users when an external DC is referenced to allow migration through expansion
* [BUGFIX] [#1299](https://github.com/k8ssandra/k8ssandra-operator/issues/1299) CronJob for medusa purge not in the correct namespace
* [BUGFIX] [#1272](https://github.com/k8ssandra/k8ssandra-operator/issues/1272) Prevent cass-operator from creating users when an external DC is referenced to allow migration through expansion
3 changes: 2 additions & 1 deletion controllers/k8ssandra/medusa_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ func (r *K8ssandraClusterReconciler) reconcileMedusa(
logger.Info("Medusa standalone deployment is not ready yet")
return result.RequeueSoon(r.DefaultDelay)
}

// Create a cron job to purge Medusa backups
operatorNamespace := r.getOperatorNamespace()
purgeCronJob, err := medusa.PurgeCronJob(dcConfig, kc.SanitizedName(), operatorNamespace, logger)
purgeCronJob, err := medusa.PurgeCronJob(dcConfig, kc.SanitizedName(), operatorNamespace, dcNamespace, logger)
if err != nil {
logger.Info("Failed to create Medusa purge backups cronjob", "error", err)
return result.Error(err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/medusa/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func StandaloneMedusaService(dcConfig *cassandra.DatacenterConfig, medusaSpec *a
return medusaService
}

func PurgeCronJob(dcConfig *cassandra.DatacenterConfig, clusterName, namespace string, logger logr.Logger) (*batchv1.CronJob, error) {
func PurgeCronJob(dcConfig *cassandra.DatacenterConfig, clusterName, operatorNamespace string, namespace string, logger logr.Logger) (*batchv1.CronJob, error) {
cronJobName := MedusaPurgeCronJobName(cassdcapi.CleanupForKubernetes(clusterName), dcConfig.SanitizedName())
logger.Info(fmt.Sprintf("Creating Medusa purge backups cronjob: %s", cronJobName))
if len(cronJobName) > 253 {
Expand All @@ -585,7 +585,7 @@ func PurgeCronJob(dcConfig *cassandra.DatacenterConfig, clusterName, namespace s
purgeCronJob := &batchv1.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: cronJobName,
Namespace: namespace,
Namespace: operatorNamespace,
},
Spec: batchv1.CronJobSpec{
Schedule: "0 0 * * *",
Expand Down

0 comments on commit 0ab3d78

Please sign in to comment.