Repository navigation
π hub: cache stable-promotion status and use authenticated GitHub reads - #10630
Conversation
Route the docker.yml workflow-runs read through authGitHubRequest, cache the runs list, per-run GHCR verification and ghcrTagGeneration for channelDigestTTL with single-flight refresh, cap per-evaluation verification at 8 runs, and reuse the already-computed status in /api/saas/my-hives. Closes #10605 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <scanner@hive.kubestellar.io>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
Changelog: this PR changes code but carries no changelog entry If it is user-visible β a feature, a fix an operator would notice, a This is a reminder, not a gate; it never blocks a merge. |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of No conflicting open PRs or same-file overlaps were found. |
Generated by changelog-fragment-guard from the PR title (#5675). Edit the wording freely, or replace this file with the no-changelog label if the change is not user-visible. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
CI red on 17558fe was inherited from the base, not this PR: π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Merging v5 into this branch left pkg/github at 88.9%, one tenth under its 89% floor. Add unit tests for HumanReviewAddressed, PRClosesIssue (nil client), SetAutoMergeMinHeadAge, auditRemoveMentionsLabel, safeMigrationFilePart, absDuration, durationFromEnv and the 404 negative-cache evictLocked path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <scanner@hive.kubestellar.io>
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
There was a problem hiding this comment.
Read stable_promotion.go, stable_promotion_cache.go, channel_targeting.go and the saas_hives_api.go call site against v5. The refactor looks correct to me; one low-severity observation below, nothing blocking.
What I verified
stablePromotionEligibleBuildkeeps the old selection semantics: newest soaked verified build wins (sort.SliceStablebyRunNumberdesc,stable_promotion.go:217), else the soaking build with the earliesteligiblethat verifies (:218). The only behavioural addition is thestablePromotionMaxVerifiedRunscap, which the body states.ttlFlight.getsingle-flight is sound: the in-flight call is published underc.mubeforefetch()runs, waiters block ondone, and the post-fetch re-init handlesreset()racing a fetch (stable_promotion_cache.go:56β59). A failed fetch never overwrites a cached entry.stablePromotionFromTargetsfalls back tostablePromotionStatuswhen no stable row carries a status, so/api/saas/my-hivescannot regress to an empty payload (stable_promotion.go:303β310).- The
pkg/github/coverage_helpers_test.goaddition is unrelated to the hub change; commitf5e9eccsays it exists to clear the 89% coverage floor, which matches the v2-ci per-package gate. Fine, just noting the scope for the maintainer.
Low: transient GHCR failures are cached as "not verified" for 5 min β stable_promotion_cache.go:126β135
stablePromotionVerifyBuild returns ok=true from the fetch closure in both branches, so a digest == "" or ghcrTagGeneration(...) == 0 caused by a GHCR timeout (fetchGHCRTagGeneration returns 0 on any HTTP error) is stored as a negative for channelDigestTTL (5 min, release_channels.go:144). By contrast cachedGHCRTagGeneration (:106β111) deliberately refuses to cache 0. Consequence: during a GHCR blip the card can skip the newest soaked build and advertise an older soaked build as the promotion candidate for up to 5 minutes. The code comment says negatives are cached on purpose (so a run whose image never landed doesn't re-hit the registry), which is reasonable β but a "tag missing" negative and a "lookup failed" negative are conflated here. If you want to keep the intent, caching the negative only when ghcrTagGeneration returned non-zero (i.e. the tag exists but carries a different generation) would separate the two. Advisory-only surface per the comment at channel_targeting.go:202β204, so I'd not hold the PR on it.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
What
stablePromotionFetchRunsbuilds the workflow-runs request withhttp.NewRequestagainstgithubAPIBaseand passes it throughauthGitHubRequest, like every other hub GitHub read.ttlFlightkeyed cache (stable_promotion_cache.go) with single-flight refresh: concurrent callers for one key share a single fetch; failed refreshes are not cached and the previous answer is served withinchannelRevisionStaleGrace(same contract aschannelRevisionSHA).channelDigestTTL(5 min): the docker.yml runs list, per-run GHCR verification (digest + generation, negative results cached too), andghcrTagGenerationper (repo, tag).stablePromotionEligibleBuildtries soaked runs newest-first, then unsoaked runs soonest-eligible-first, stopping at the first verified build, and verifies at moststablePromotionMaxVerifiedRuns= 8 runs per evaluation. Result semantics are unchanged./api/saas/my-hivesreuses the status already attached to the stable channel row instead of computing it a second time.stableNextPromotionAtis untouched (it picks up the caching through the helpers it calls).Tests
New stable_promotion_cache_test.go: runs cached until TTL then refetched; 16 concurrent callers β one fetch; failed refresh serves previous answer and is retried; ghcrTagGeneration cached per tag and refetched after expiry; verification capped and reused across evaluations; workflow-runs request carries the hub token. Existing stable-promotion tests reset the caches.
Closes #10605
β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88