Skip to content

fix(operator): refuse to overwrite a Secret the operator does not manage - #326

Merged
BryanFRD merged 2 commits into
mainfrom
fix/313-refuse-unowned-secret
Oct 25, 2026
Merged

BryanFRD merged 2 commits into
mainfrom
fix/313-refuse-unowned-secret

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

Closes #313

If the target Secret already exists without the ferrvault.com/managed-by annotation or an owner reference to the CR, the reconcile now stops with Ready=False, reason TargetConflict, and leaves the Secret untouched. The connection token Secret keeps its existing behaviour (it is deliberately user-created).

Existing reconcile fixtures that pre-created a target now carry the managed-by annotation, since they model operator-created Secrets.

Tests: unmanaged Secret untouched with condition set; managed and CR-owned Secrets still updated.

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard is correct. It runs inside the CreateOrUpdate mutate func, so a conflict aborts before any write. Fresh creates (ResourceVersion == "") and token targets are exempt as intended. Secrets written by earlier versions already carry ferrvault.com/managed-by, so upgrades don't trip it. TargetConflict requeues on the refresh interval through failReady, so it clears once the user deletes or annotates the Secret.

Nit (not from this PR): the annotation check only tests whether the key is present. Two FerrVaultSecrets that point at the same target name will still overwrite each other. If that matters, a follow-up could match on the controller ownerRef instead.

Comment thread internal/controller/ferrvaultsecret_controller.go Outdated
@BryanFRD
BryanFRD merged commit 3b34635 into main Oct 25, 2026
19 checks passed
@BryanFRD
BryanFRD deleted the fix/313-refuse-unowned-secret branch October 25, 2026 11:00
ferrflow Bot added a commit that referenced this pull request Oct 25, 2026
## [6.1.2] - 2026-10-25

### Bug Fixes

- fix(operator): refuse to overwrite a Secret the operator does not manage (#326)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(operator): refuse to overwrite a pre-existing Secret the operator did not create

1 participant