Skip to content

Check GitHub status duplicates per context - #1387

Closed
itamar-marom wants to merge 1 commit into
fluxcd:mainfrom
itamar-marom:github-status-dedup-combined
Closed

itamar-marom wants to merge 1 commit into
fluxcd:mainfrom
itamar-marom:github-status-dedup-combined

Conversation

@itamar-marom

Copy link
Copy Markdown

The GitHub notifier skips posting a commit status when the latest status for the same context already has the same state and description. It looks for that status only among the first 50 statuses returned by ListStatuses.

kustomize-controller emits an event with commit status metadata on every successful reconciliation (Reconciliation finished in ...), so the duplicate check is what keeps a Kustomization from posting a status every interval. Once a commit carries more than 50 statuses from other contexts, the previous status of a context falls off the first page. The check then never matches, and every event posts a new status. This happens as soon as enough Kustomizations or clusters report on the same revision, and it does not settle: each re-post pushes other contexts off the page too.

We hit this rolling commit statuses out to 11 clusters reporting on one repository, with about 120 contexts at a 30s interval. A single commit collected 4,040 statuses in 30 minutes, about 170 per minute, all success with unchanged descriptions. With 12 contexts the same setup was stable.

This change reads the combined status (GET /repos/{owner}/{repo}/commits/{ref}/status) instead. It returns the latest status of each context and pages at up to 100 contexts. The notifier pages until it finds its context, so the result no longer depends on how many statuses other contexts have posted. The comparison itself (duplicateGithubStatus) is unchanged.

TestGitHubPostDuplicateOnLaterPage serves both endpoints the way GitHub does: a status history in which the context's latest status sits behind 60 newer ones, and a combined status in which it is on page 2 after 100 other contexts. With the previous code, the unchanged case posts a duplicate. With this change, only a changed state, a changed description or a missing context posts.

The GitLab, Gitea and Azure DevOps notifiers use a similar first-page check. This PR only changes GitHub.

make tidy fmt vet && make test passes. Prepared with the assistance of Claude Code; the commit carries an Assisted-by trailer.

The GitHub notifier skipped posting a commit status when the latest
status with the same context already had the same state and
description. It looked for that status in the first 50 statuses of the
commit only. Controllers emit an event with commit status metadata on
every successful reconciliation, so once other contexts post more than
50 statuses on a commit, which happens when many Kustomizations or
clusters report on the same revision, the previous status is never
found and every event posts a new one.

Read the combined status instead. It holds the latest status of each
context, and is paged until the context is found, so the check no
longer depends on how many statuses other contexts posted.

Signed-off-by: Itamar Marom <46691031+itamar-marom@users.noreply.github.com>
Assisted-by: Claude Code/claude-opus-5-5
@itamar-marom
itamar-marom deleted the github-status-dedup-combined branch September 27, 2026 11:07
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