Skip to content

Commit

Permalink
ReplicatedSecrets should not pick up secrets from outside their own n…
Browse files Browse the repository at this point in the history
…amespace.
  • Loading branch information
Miles-Garnsey committed Apr 15, 2024
1 parent 9577b31 commit 03e3452
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/CHANGELOG-1.14.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog for the K8ssandra Operator, new PRs should update the `unreleased` sec
When cutting a new release, update the `unreleased` heading to the tag being generated and date, like `## vX.Y.Z - YYYY-MM-DD` and create a new placeholder section for `unreleased` entries.

## unreleased
* [BUGFIX] [#1282](https://github.com/k8ssandra/k8ssandra-operator/issues/1282) The ReplicatedSecrets controller no longer looks in all namespaces to pick up secrets matching its matchLabels selector. It only looks in it's own namespace.
* [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.14.0.
* [BUGFIX] [#1240](https://github.com/k8ssandra/k8ssandra-operator/issues/1240) The PullSecretRef for medusa is ignored in the standalone deployment of medusa
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG/RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# k8ssandra-operator - Release Notes

## v1.14.0

Replicated secrets no longer look in all namespaces to Replicate secrets whose labels match the MatchLabels selector in the ReplicatedSecret.

Instead, secrets will only be picked up by the matcher if they both have matching labels AND are also in the same namespace as the ReplicatedSecret.

## v1.12.0

It is now possible to disable Reaper front end authentication by adding either `spec.reaper.uiUserSecretRef: {}` or `spec.reaper.uiUserSecretRef: ""`.
Expand Down
7 changes: 4 additions & 3 deletions controllers/replication/secret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s *SecretSyncController) Reconcile(ctx context.Context, req ctrl.Request)
return reconcile.Result{}, err
}

secrets, err := s.fetchAllMatchingSecrets(ctx, selector)
secrets, err := s.fetchAllMatchingSecrets(ctx, selector, rsec.Namespace)
if err != nil {
logger.Error(err, "Failed to fetch the replicated secrets to cleanup", "ReplicatedSecret", req.NamespacedName)
return reconcile.Result{}, err
Expand Down Expand Up @@ -177,7 +177,7 @@ func (s *SecretSyncController) Reconcile(ctx context.Context, req ctrl.Request)
s.selectorMutex.Unlock()

// Fetch all the secrets that match the ReplicatedSecret's rules
secrets, err := s.fetchAllMatchingSecrets(ctx, selector)
secrets, err := s.fetchAllMatchingSecrets(ctx, selector, req.Namespace)
if err != nil {
logger.Error(err, "Failed to fetch linked secrets", "ReplicatedSecret", req.NamespacedName)
return reconcile.Result{Requeue: true}, err
Expand Down Expand Up @@ -361,10 +361,11 @@ func (s *SecretSyncController) verifyHashAnnotation(ctx context.Context, sec *co
return nil
}

func (s *SecretSyncController) fetchAllMatchingSecrets(ctx context.Context, selector labels.Selector) ([]corev1.Secret, error) {
func (s *SecretSyncController) fetchAllMatchingSecrets(ctx context.Context, selector labels.Selector, namespace string) ([]corev1.Secret, error) {
secrets := &corev1.SecretList{}
listOption := client.ListOptions{
LabelSelector: selector,
Namespace: namespace,
}
err := s.ClientCache.GetLocalClient().List(ctx, secrets, &listOption)
if err != nil {
Expand Down

0 comments on commit 03e3452

Please sign in to comment.