Skip to content

Commit

Permalink
Micke's requested changes inc. unit test, changelog and conditional p…
Browse files Browse the repository at this point in the history
…atching only.
  • Loading branch information
Miles-Garnsey committed Apr 3, 2024
1 parent 8b09c4b commit e14083d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG/CHANGELOG-1.14.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ When cutting a new release, update the `unreleased` heading to the tag being gen

## unreleased
* [BUGFIX] [#1253](https://github.com/k8ssandra/k8ssandra-operator/issues/1253) Medusa storage secrets are now labelled with a unique label.
* [FEATURE] [#1260](https://github.com/k8ssandra/k8ssandra-operator/issues/1260) Update controller-gen to version 0.12.0.
* [FEATURE] [#1260](https://github.com/k8ssandra/k8ssandra-operator/issues/1260) Update controller-gen to version 0.14.0.
* [FEATURE] [#1242](https://github.com/k8ssandra/k8ssandra-operator/issues/1242) Allow for creation of replicated secrets with a prefix, so that we can distinguish between multiple secrets with the same origin but targeting different clusters.
* [BUGFIX] [#1226](https://github.com/k8ssandra/k8ssandra-operator/issues/1226) Medusa purge cronjob should be created in the operator namespace
* [BUGFIX] [#1141](https://github.com/k8ssandra/k8ssandra-operator/issues/1141) Use DC name override when naming secondary resources
Expand Down
8 changes: 5 additions & 3 deletions controllers/medusa/medusaconfiguration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ func (r *MedusaConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.
if secret.Labels == nil {
secret.Labels = make(map[string]string)
}
secret.Labels[MedusaStorageSecretIdentifierLabel] = utils.HashNameNamespace(secret.Name, secret.Namespace)
if err = r.Client.Patch(ctx, secret, patch); err != nil {
logger.Error(err, "Failed to patch Medusa Bucket Secret with required label")
if secret.Labels[MedusaStorageSecretIdentifierLabel] != utils.HashNameNamespace(secret.Name, secret.Namespace) {
secret.Labels[MedusaStorageSecretIdentifierLabel] = utils.HashNameNamespace(secret.Name, secret.Namespace)
if err = r.Client.Patch(ctx, secret, patch); err != nil {
logger.Error(err, "Failed to patch Medusa Bucket Secret with required label")
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions controllers/medusa/medusaconfiguration_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

api "github.com/k8ssandra/k8ssandra-operator/apis/medusa/v1alpha1"
"github.com/k8ssandra/k8ssandra-operator/pkg/utils"
"github.com/k8ssandra/k8ssandra-operator/test/framework"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -65,6 +66,10 @@ func testMedusaConfigurationOk(t *testing.T, ctx context.Context, f *framework.F
t.Logf("failed to get medusa configuration: %v", err)
return false
}
//Ensure that the unique label has been added to the secret.
if bucketKeySecret.Labels[MedusaStorageSecretIdentifierLabel] != utils.HashNameNamespace(bucketKeySecret.Name, bucketKeySecret.Namespace) {
return false
}
for _, condition := range updated.Status.Conditions {
t.Logf("medusa configuration condition: %v", condition)
if condition.Type == string(api.ControlStatusReady) {
Expand Down

0 comments on commit e14083d

Please sign in to comment.