← Back to Pull requests

fix(operator): resolve the post-merge review of the operator #3501

Closed
unknown closed this pull request without merging on Oct 29, 2026 21:16 UTC
View on GitHub
unknown unknown commented on Oct 29, 2026 14:45 UTC
Author

Summary

Fixes the AICR Operator issues raised in the post-merge review of #3475: rollout and approval edge cases, unbounded or overflowing readers, admission gaps, metrics, and controller setup. Each fix has a regression test.

Motivation / Context

#3475 was reviewed after it merged. This PR fixes the verified findings before the operator ships as a preview (#3469). Docs-only findings are fixed in #3491. Findings that need more than a small change are tracked in #3495–#3499, #3502 and #3514. Each review thread says which applies.

Fixes: N/A
Related: #3469
Related: #3514

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

  • New feature (non-breaking change that adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

  • Documentation update

  • Refactoring (no functional changes)

  • Build/CI/tooling
  • Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)

  • API server (cmd/aicrd, pkg/server)

  • Recipe engine / data (pkg/recipe)

  • Bundler and deployers (pkg/bundler, pkg/component)

  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)

  • Validator (pkg/validator)

  • Core libraries (pkg/errors, pkg/k8s)

  • Docs/examples (docs/, examples/)

  • Other: AICR Operator (pkg/operator, api/operator, cmd/aicr-operator, charts/aicr-operator, tests/operator)
  • Implementation Notes

    The commits are grouped by area.

    Chart, controller setup and metrics (c7f24211e):

  • Admission: only the operator's ServiceAccount may create a RuntimeRollout. Before, a rollout created with approvalRequired: false or an outcome label skipped approval, held back only by RBAC.

  • Job environment: AICR Jobs may set only HOME, TMPDIR and DOCKER_CONFIG by value, with no envFrom, and mount only emptyDir and Secret volumes. An env var such as AICR_IMAGE can therefore no longer get around the pinned image.

  • Delete annotation: the delete-rollout annotation must be non-empty.

  • Controller setup: the rollout controller has a 30-minute reconcile timeout, and both controllers run one worker explicitly. Application updates that only refresh status timestamps no longer trigger a reconcile.

  • Pod: GOMEMLIMIT follows the memory limit, the grace period is 45s, and the operator refuses to start when validation is enabled but POD_NAME is unset.

  • Metrics: every known label value starts at zero, and the job metrics are renamed aicr_operator_job_*. Nothing has shipped yet, so the rename is free.

  • ECR policy: allows ecr:CreateRepository under the prefix.
  • Engine, registry, resolver and Jobs (f0715f225):

  • Exit-0 failure: a failed Job whose container exited 0, as in a deadline race, panicked every reconcile. It is now an internal error with a bounded retry.

  • Bundle bounds: the tar size check can no longer overflow. The caps drop to 16 MiB compressed and 64 MiB unpacked, so two bundles held at once fit in the 512Mi limit. Real bundles are about 350 KiB.

  • Chart readers: the chart-defaults reader bounds nesting depth, total size and entry count. Values files are skipped only at chart roots, so a CRD under templates/values.yaml counts.

  • Plain HTTP: allowed only for configured hosts, and the following commit applies the same rule to redirects.

  • Plans: reading a plan recomputes its digest and checks the ConfigMap name.

  • Input-only failures: an override path or namespace failure is remembered for its input digest, instead of re-pulling and re-mirroring every 30s.

  • Suspend and Orphan: Suspend continues past a refused Application. A refused orphaned-from write is reported as an Event and no longer holds the finalizer.

  • Job runs: a run is marked before it is counted. Token gauges become timestamps, 0 until known.
  • Rollout, approval and validation (573286573):

  • Repair: never reinstalls a release whose Remove step failed, and never rolls back a release a failed rollout moved.

  • CRD changes: a CRD change counts when either the old or the new chart owns CRDs, so a chart that drops a CRD needs approval.

  • Transient reads: a failed read of the AppProject or repo-creds Secret is retried. Only a missing object sets a stall reason.

  • Early validation stall: a runtime that requires validation without it installed stalls before a rollout is created, not after every step is applied.

  • Ready: a stalled runtime is not Ready.

  • Retry token: used up in the same patch that supersedes the old rollout, so a failed write no longer burns it. Comparing the token instead would also supersede a later stall of the rollout that same retry created.

  • Assessment report: a blocked transition keeps its report.

  • Revocation: the evidence approval record now carries a revocation made after the last step.

  • Conflicts: approve, revoke and acknowledge retry on a 409.

  • Approval lifetime: an approval lasts until the rollout's deadline unless --expires is set; the old 2-hour default could end a rollout half-applied.

  • API: CurrentStep.Attempts, always 1, is removed, and the CRD is regenerated.
  • Integration (0eba4844a): refuses a chart-fetch redirect to an unconfigured plain-HTTP host, and documents the new Event and the tightened policies.

    Pre-PR review (cd9dbfda6). A review of the combined change found one gap that predates this branch, and four smaller ones:

  • Image arguments: the pinned-image rule for AICR Jobs checked only --image and --image=. The CLI also parses -image, -image=, and --config, whose file can name the agent image, so a Job could run another image in the privileged discovery namespace. Now only the exact --image <pinned> pair may name an image, and no Job takes --config.

  • Forbidden reads: a forbidden read stalls the runtime with Unauthorized instead of leaving its status frozen.

  • Redirects: a redirect to an unconfigured plain-HTTP host is now refused before it is followed, through CheckRedirect.

  • Refused deletes: a delete that was refused leaves its release Pending, so repair still covers it.

  • Ready: the early validation stall names its cause on Ready too.
  • Later review comments (ddbdfaf78):

  • every Event note is bounded to the 1024 bytes events/v1 accepts, on a rune boundary, and condition messages are cut on a rune boundary too;

  • listing referrers stops once they pass the bound, instead of paging until the timeout;

  • Secrets are never read through the cache;

  • the cached Node list is not deep-copied on every resolve.
  • Behavior changes worth knowing:

  • Restoring RuntimeRollouts as another identity, for example with Velero, now needs the policy binding suspended first. Approved rollouts already could not be restored that way.

  • A runtime that requires validation without it installed now creates no rollout at all.

  • A failed read of the repo-creds Secret no longer reports RegistryCredentialsStale.
  • Testing

    KUBEBUILDER_ASSETS=$(setup-envtest use -p path) go test -race -count=1 ./api/operator/... ./pkg/operator/... ./cmd/aicr-operator/... ./tests/operator/chart/...
    golangci-lint run -c .golangci.yaml ./api/operator/... ./pkg/operator/... ./cmd/aicr-operator/... ./tests/operator/...
    go vet ./tests/operator/...
    make operator-check-generated
    make qualify
    

  • Unit and envtest: all pass. The chart admission suite also passes on the Kubernetes 1.34 floor.

  • Regression tests: each behavior fix has one, and each was checked to fail with its fix reverted.

  • Kind lanes: the kind-only qualify suite compiles. It runs in Operator E2E on this PR.
  • make qualify passes, with 85.8% coverage, and make operator-check-generated reports the generated code current. Both ran on the branch before its rebase onto #3491; they run again on this head before it leaves draft.

    Risk Assessment

  • Low — Isolated change, well-tested, easy to revert

  • Medium — Touches multiple components or has broader impact

  • High — Breaking change, affects critical paths, or complex rollout
  • It tightens admission and changes rollout gating in several places. The operator has not shipped, so no installed state depends on the old behavior.

    Rollout notes: The CRD change only removes an unused status field. A chart upgrade applies the new policies.

    Checklist

  • Tests pass locally (make test with -race)

  • Linter passes (make lint)

  • I did not skip/disable tests to make CI green

  • I added/updated tests for new functionality

  • I updated docs if user-facing behavior changed

  • Changes follow existing patterns in the codebase

  • Commits are signed off and cryptographically signed (git commit -s -S) — GPG signing info
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: yuanchen8911 Review duration: 390m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3501"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository