SREP-4339: Preserve customer pull secret entries during ECR credential refresh #2696
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.65) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.65 · 329 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.347
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.065
Real PR Conversation Timeline
1 comments
"Review active on #2696"
general
weight: 0.35
reedcort
What type of PR is this?
bug
What this PR does / why we need it?
The
ecr-credential-refreshCronJob on zero-egress HCP clusters overwrites the entireadditional-pull-secretwith only ECR registry credentials every 4 hours, wiping out any customer-added entries for private registries.Updated the
update_secret()function to read the existing secret, usepython3for JSON-aware merging to preserve all entries except those matching IDMS-discovered registries, and patch with the merged result. Added error guards for unreadable or malformed secret data. Only exact registries found in ImageDigestMirrorSets are replaced, so any customer-owned ECR registries are also preserved.Only affects zero-egress HCP clusters — regular HCP clusters are unaffected.
Which Jira/Github issue(s) this PR fixes?
Fixes SREP-4339
Special notes for your reviewer:
Root Cause: The
update_secret()function built a new.dockerconfigjsoncontaining only ECR auths and patched it over the existing secret without merging.Fix: When the secret already exists, the script now:
1. Reads the current
.dockerconfigjsonwith error guards (validates oc get, non-empty, valid base64)2. Uses
python3 -cwithjson.loads()/json.dumps()for JSON-aware merging — handles any valid dockerconfigjson regardless of field ordering or auth format (reordered fields,identitytoken,username/passwordentries)3. Passes IDMS-discovered registries via env var, only removes exact matches — customer-owned ECR registries are preserved
4. Patches the secret with the merged result
Why python3: The container image (
ocp-v4.0-art-dev/ node-resolver) includes Python 3.9. grep/sed-based JSON parsing is brittle — it misses entries whereauthis not the first field.Verified merge logic locally with tests covering:
authnot first key) preservedidentitytoken-based auth entries preservedConfirmed the bug on test cluster
2820d2ba-4d41-4ef2-ab16-998865e45fa6.Pre-checks (if applicable):
🤖 Generated with Claude Code