Skip to content

Fix artifactSet Diff for duplicate revisions - #2234

Open
amalsaidov wants to merge 1 commit into
fluxcd:mainfrom
amalsaidov:fix-artifactset-diff-duplicate-revisions
Open

amalsaidov wants to merge 1 commit into
fluxcd:mainfrom
amalsaidov:fix-artifactset-diff-duplicate-revisions

Conversation

@amalsaidov

Copy link
Copy Markdown

artifactSet.Diff decides whether a GitRepository's set of included
artifacts has changed. It did a length check and then, for each current
revision, looked for any match in the updated set.

With that one-directional membership check, a set that holds the same
revision more than once can change without being detected: if a distinct
revision is replaced by a duplicate of another, the length stays equal
and every current revision is still found in the updated set, so Diff
returns false.

Example (current vs stored):

current: ["foo", "foo"]
stored:  ["foo", "bar"]

These differ ("bar" is gone), but Diff reports no change. This is
reachable for a GitRepository with multiple .spec.include entries that
resolve to the same revision (for instance two includes of the same
commit). The call site is reconcileInclude in
gitrepository_controller.go, where a missed change leaves the
aggregated artifact stale until another reconcile is triggered.

The fix compares the two sets as multisets of revisions, so a repeated
revision must appear the same number of times in both. Order-independence
and the existing cases are preserved.

Added table cases cover the duplicate-revision change and an
out-of-order equal set. The new duplicate case fails on the previous
implementation and passes with this change.

AI-assisted; directed, reviewed and tested by the author.

Diff compared each current revision against the updated set with
one-directional membership and a length check. When a set holds the
same revision more than once, a change that turns a distinct revision
into a duplicate kept the length equal and still found every current
revision in the updated set, so Diff reported no change.

For a GitRepository with multiple includes that resolve to the same
revision, that masks an included artifact change and leaves the
aggregated artifact stale until another reconcile is triggered.

Compare the two sets as multisets of revisions so repeated revisions
must appear the same number of times in both.

Signed-off-by: Amal Saidov <amalsaidov@users.noreply.github.com>
Assisted-by: Claude Code/claude-opus-4-8
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.

1 participant