← Back to Pull requests

SREP-4339: Preserve customer pull secret entries during ECR credential refresh #2696

Closed
unknown closed this pull request without merging on Apr 08, 2026 23:09 UTC
View on GitHub
unknown unknown commented on Apr 08, 2026 17:05 UTC
Author

What type of PR is this?


bug

What this PR does / why we need it?


The ecr-credential-refresh CronJob on zero-egress HCP clusters overwrites the entire additional-pull-secret with 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, use python3 for 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 .dockerconfigjson containing 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 .dockerconfigjson with error guards (validates oc get, non-empty, valid base64)
2. Uses python3 -c with json.loads()/json.dumps() for JSON-aware merging — handles any valid dockerconfigjson regardless of field ordering or auth format (reordered fields, identitytoken, username/password entries)
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 where auth is not the first field.

Verified merge logic locally with tests covering:

  • Customer non-ECR entries preserved

  • Customer-owned ECR registries preserved

  • Reordered fields (auth not first key) preserved

  • identitytoken-based auth entries preserved

  • Managed ECR tokens refreshed

  • Multiple managed registries

  • Invalid JSON rejected with error
  • Confirmed the bug on test cluster 2820d2ba-4d41-4ef2-ab16-998865e45fa6.

    Pre-checks (if applicable):


  • Tested latest changes against a cluster

  • Included documentation changes with PR

  • If this is a new object that is not intended for the FedRAMP environment (if unsure, please reach out to team FedRAMP), please exclude it with: N/A - existing object
  • 🤖 Generated with Claude Code

    Diff: 329 lines (+246 / -83) across 4 files Reviewer: reedcort Review duration: 363m
    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
    0.65
    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.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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    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: 65.3% (HIGH) · Higher = larger blast radius
    65.3%
    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: 25.8% · Safe to merge
    25.8%