OCPBUGS-128842: honor graph download context and status #1566
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.55) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.55 · 556 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.378
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #1566"
general
weight: 0.35
chdeshpa-hue
OCPBUGS-128842
Repository: openshift/oc-mirror
Component: oc-mirror
Files:
internal/pkg/release/graph.go,internal/pkg/release/graph_test.goFixes: https://redhat.atlassian.net/browse/OCPBUGS-128842
Status: pushed as single commit
60eead95; reviewer feedback addressed.Summary
Make graph-image downloads context-aware and status-aware. Command cancellation can then stop a stalled graph request, and HTTP failures are reported before gzip/archive decoding.
Error
Before this change,
CreateGraphImageaccepted a context but usedhttp.Get. A non-success response was read as graph data and later reported as a gzip/archive error.Fix
The implementation mirrors the existing
internal/pkg/cincinnati/download.gorequest pattern:http.NewRequestWithContext.GlobalOptions.CommandTimeout, which is configured by--image-timeoutand defaults to 10 minutes. Preserve the supplied caller context and do not impose an immediate timeout when the duration is zero.client.Do(req.WithContext(timeoutCtx))and wrap request/read errors with operation context.resp.StatusCode == http.StatusOKand returnunexpected HTTP status <status>before reading graph data.Why this approach
| Alternative | Decision | Reason |
|---|---|---|
| Keep
http.Get| Rejected | It ignores the supplied context. || Set
http.Client.Timeout| Rejected | The repository's analogous download path derives a timeout context, which preserves caller cancellation/deadlines and provides the established error behavior. || Accept every 2xx response | Rejected | The cited Cincinnati pattern requires exactly
http.StatusOK; 204 and 206 are not graph archives. || Decode before checking status | Rejected | It produces a misleading archive error. |
| Context-bound request with exact status check | Chosen | Matches
cincinnati/download.goand preserves successful graph handling. |Testing Results
The fix-specific tests were added and run against the unmodified revision first. Baseline results were expected failures for status reporting, cancellation, and deadline handling; success, invalid-URL, and graph-disabled cases passed. Post-fix validation passed:
make verifyremains blocked by 232 pre-existing repository-wide lint findings, including the unchangedmockImageBuilder.ProcessImageIndexinterface-return warning and existinggraph.gofindings outside the rework. Diff-scoped lint reports 0 new issues. The validation preflight classifies macOS Bash 3 and loopback listener failures as host/toolchain limitations. The mandatorymake test-envtest-ocptarget is not applicable because no API or CRD files changed.Backward compat
Valid HTTP 200 gzip graph data and cached disk-to-mirror paths remain supported. Only stalled or non-successful HTTP responses change from misleading decode failures to actionable request errors. The change is a clean backport candidate for release-5.2 and release-5.1; both branches currently share the main base revision and no API or generated files changed.
Workaround
Use a reachable graph endpoint and wrap the command in an external timeout when endpoint behavior is uncertain.
Related
Unit Test
graph_test.gocovers successful graph downloads in mirror-to-disk and mirror-to-mirror modes, the configured command timeout, zero-timeout success, HTTP 204/206/503 rejection before gzip parsing, context cancellation, context deadlines, invalid URL construction, and the graph-disabled collector path. Request-error tests also assert that the image builder is not invoked.