Repository navigation
Warn about conflicting Kustomization ownership - #1807
Conversation
|
Not sure we want to add one GET per object... I'm wondering if it would be possible for the SSA lib to report the conflicts back to the controller, then the controller emits the warning... |
|
Thanks, that makes sense. I've opened fluxcd/pkg#1377 to report ownership conflicts from SSA's existing live-object lookup, after skip checks and before the first write. I tested the controller change locally against that patch: the ownership tests now assert one GET per object and a warning before the first PATCH. The full SSA suite passes with race detection, and the full controller suite passes. I'll update this PR to use the callback once the upstream SSA change is available. |
|
The SSA prerequisite, fluxcd/pkg#1377, is now merged. I'll update this PR once an official SSA release includes |
|
Tag |
|
Updated this PR to use the released SSA v0.84.0 and |
matheuscscp
left a comment
There was a problem hiding this comment.
A big problem with this implementation is that we may end up sending too many events... There could be a situation where two different Kustomizations apply 1000 overlapping objects...
In fluxcd/source-watcher#392 we introduced OwnershipConflict by making the event content short. We can for example emit all the object references in the controller logs, but not on events...
|
Agreed, one event per object is too much. Updated this to emit a single short Added concurrent batch coverage for successful and failed applies, repeated attempts, and GET reuse. Local |
|
@DDINGJOO Please run https://github.com/fluxcd/kustomize-controller/actions/runs/44234357357/job/134693901633?pr=1807 |
matheuscscp
left a comment
There was a problem hiding this comment.
LGTM
@DDINGJOO Please squash all the commits into one and force-push 🙏
Emit one warning per apply before adopting resources owned by another Kustomization, and log the conflicting resources and previous owners. Reuse the SSA ownership lookup and cover ordering and concurrency. Signed-off-by: MyungJoo Song <173995233+DDINGJOO@users.noreply.github.com> Assisted-by: Codex/GPT-6
4673a55 to
492c564
Compare
|
Squashed into one commit and force-pushed as 492c564. The workflows are waiting for approval. Thanks for the review! |
When ownership labels identify another Kustomization, emit one short
OwnershipConflictWarning event per apply attempt before writing the first conflicting resource. Record all detected resources and their previous owners in one structured log per apply, including failed applies. SSA continues without changing readiness or pruning behavior.Use
ApplyOptions.OnOwnershipConflictfrom the releasedgithub.com/fluxcd/pkg/ssa v0.84.0to reuse SSA's live-object lookup and skip-policy handling. The warning is limited with a function-localsync.Once; conflict details are collected safely across concurrent callbacks and logged when staged apply returns.Includes 21 ownership cases, a read-concurrency regression and 32-object concurrent batches. Tests check one GET per resource, warning timing, one short event and one log containing every resource and previous owner, repeated attempts, write failures and silence without conflicts. Reverting the log aggregation makes both conflict batch cases fail with 32 logs instead of one.
Validation:
make test GO_TEST_ARGS='-count=1' ENVTEST_KUBERNETES_VERSION=1.37.0passes, including tidy, generation, formatting and vet. The full suite passes 90 top-level tests (403 including subtests), with no failures or skips. Generated files are unchanged. Focused ownership tests also pass with-race.Fixes #1724
AI assistance: Codex (GPT-6).