Skip to content

Commit

Permalink
Ensure that the original secret isn't cleaned up if it was never repl…
Browse files Browse the repository at this point in the history
…icated due to having no target prefix.
  • Loading branch information
Miles-Garnsey committed Apr 15, 2024
1 parent 5023530 commit fe15c62
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions controllers/replication/secret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func (s *SecretSyncController) Reconcile(ctx context.Context, req ctrl.Request)
}
for _, origSecret := range sourceSecretsToMapToTargets {
deleteObject := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: getPrefixedSecretName(target.TargetPrefix, origSecret.Name), Namespace: target.Namespace}}
if origSecret.Namespace == target.Namespace && origSecret.Name == deleteObject.Name {
// Target is the same secret as the original - bail.
continue
}
logger.Info("Deleting secrets for", "objectMeta", deleteObject.ObjectMeta,
"Cluster", target.K8sContextName)
err = remoteClient.Delete(ctx, deleteObject)
Expand Down

0 comments on commit fe15c62

Please sign in to comment.