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 16, 2024
1 parent 7dbbce7 commit e3c2290
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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 e3c2290

Please sign in to comment.