Gate acceptance/rejection on release mirror job completion#798
Conversation
rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughRelease payload creation now conditionally configures mirror coordinates. Acceptance and rejection controllers defer condition evaluation until configured mirror jobs reach terminal states, with expanded tests covering precedence and synchronization. ChangesMirror job flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ReleasePayload
participant AcceptanceController
participant RejectionController
participant MirrorJob
ReleasePayload->>AcceptanceController: evaluate accepted condition
AcceptanceController->>MirrorJob: read mirror job status
MirrorJob-->>AcceptanceController: pending or terminal status
AcceptanceController-->>ReleasePayload: defer or evaluate acceptance
ReleasePayload->>RejectionController: evaluate rejected condition
RejectionController->>MirrorJob: read mirror job status
MirrorJob-->>RejectionController: pending or terminal status
RejectionController-->>ReleasePayload: Unknown or evaluate rejection
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/cmd/release-payload-controller/payload_accepted_controller.go (1)
141-156: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicated mirror-job gate logic across both controllers.
The mirror-job "must reach terminal state, skip if already accepted/rejected" predicate is duplicated verbatim (modulo the condition variable name) in both controllers. A future change to the gate's semantics risks being applied to only one file.
pkg/cmd/release-payload-controller/payload_accepted_controller.go#L141-L156: extract this predicate into a shared helper (e.g.mirrorJobPending(payload) bool) callable from both files.pkg/cmd/release-payload-controller/payload_rejected_controller.go#L144-L159: replace this block with a call to the same shared helper.♻️ Example shared helper
// mirrorJobPending reports whether a configured mirror job has not yet reached // a terminal state, and the payload has not already been accepted or rejected. func mirrorJobPending(payload *v1alpha1.ReleasePayload) bool { if payload.Spec.PayloadCreationConfig.ReleaseMirrorCoordinates.ReleaseMirrorJobName == "" { return false } if v1helpers.IsConditionTrue(payload.Status.Conditions, v1alpha1.ConditionPayloadAccepted) || v1helpers.IsConditionTrue(payload.Status.Conditions, v1alpha1.ConditionPayloadRejected) { return false } return payload.Status.ReleaseMirrorJobResult.Status != v1alpha1.ReleaseMirrorJobSuccess && payload.Status.ReleaseMirrorJobResult.Status != v1alpha1.ReleaseMirrorJobFailed }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/cmd/release-payload-controller/payload_accepted_controller.go` around lines 141 - 156, Extract the duplicated mirror-job pending predicate into a shared helper, such as mirrorJobPending(payload), preserving the configured-job, accepted/rejected, and terminal-status checks. In pkg/cmd/release-payload-controller/payload_accepted_controller.go lines 141-156, replace the inline gate with the helper while retaining the existing accepted condition return; make the same replacement in pkg/cmd/release-payload-controller/payload_rejected_controller.go lines 144-159, retaining that controller’s existing return behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/cmd/release-payload-controller/payload_accepted_controller_test.go`:
- Line 299: Correct the section header above the mirror-job tests to state that
the mirror gate is evaluated before and blocks payload overrides, matching
MirrorJobBlocksOverrideAccepted, MirrorJobBlocksOverrideRejected, and the
implementation comment. Remove the incorrect “third precedence — after
overrides” wording without changing test behavior.
---
Nitpick comments:
In `@pkg/cmd/release-payload-controller/payload_accepted_controller.go`:
- Around line 141-156: Extract the duplicated mirror-job pending predicate into
a shared helper, such as mirrorJobPending(payload), preserving the
configured-job, accepted/rejected, and terminal-status checks. In
pkg/cmd/release-payload-controller/payload_accepted_controller.go lines 141-156,
replace the inline gate with the helper while retaining the existing accepted
condition return; make the same replacement in
pkg/cmd/release-payload-controller/payload_rejected_controller.go lines 144-159,
retaining that controller’s existing return behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 71efcc40-ab24-4dce-aa5c-f720ffda688e
📒 Files selected for processing (6)
cmd/release-controller/sync_release_payload.gocmd/release-controller/sync_release_payload_test.gopkg/cmd/release-payload-controller/payload_accepted_controller.gopkg/cmd/release-payload-controller/payload_accepted_controller_test.gopkg/cmd/release-payload-controller/payload_rejected_controller.gopkg/cmd/release-payload-controller/payload_rejected_controller_test.go
💤 Files with no reviewable changes (1)
- cmd/release-controller/sync_release_payload_test.go
|
/hold |
rh-pre-commit.version: 2.4.0 rh-pre-commit.check-secrets: ENABLED
|
/label tide/merge-method-squash |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bradmwilliams, hoxhaeris The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/unhold |
|
@bradmwilliams: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
ReleaseMirrorCoordinateson ReleasePayloads whenAlternateImageRepositoryandAlternateImageRepositorySecretNameare both configuredPayloadAcceptedandPayloadRejectedcondition evaluation on the mirror job reaching a terminal state (Success or Failed), when a mirror job is configured — including manual overrides, since images need to be backed up before any decision is madeReleaseMirrorJobResult.Statusand evaluation proceeds normallyPrecedence order
rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
Summary by CodeRabbit