feat: fall back to kube-system/global-pull-secret for Insights token#1302
feat: fall back to kube-system/global-pull-secret for Insights token#1302judexzhu wants to merge 1 commit into
Conversation
On ARO HCP clusters, openshift-config/pull-secret only contains the ACR registry credential — no cloud.openshift.com token. Customers add their Red Hat pull secret (including cloud.openshift.com) day-2 via the additional-pull-secret method, which HCCO merges into kube-system/global-pull-secret. This change makes updateToken() check kube-system/global-pull-secret as a fallback when openshift-config/pull-secret has no cloud.openshift.com token, enabling Insights reporting on HCP clusters without requiring platform-level changes. Changes: - Generalize fetchSecret() to accept a namespace parameter - Add fallback lookup to kube-system/global-pull-secret in updateToken() - Add read-only RBAC (Role+RoleBinding) for global-pull-secret in kube-system - Include namespace in fetchSecret log/error messages for debuggability - Add tests for fallback and primary-wins-over-fallback precedence Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds fallback token resolution by enabling the insights-operator to read a global pull secret from kube-system when the primary pull secret is unavailable. RBAC permissions are added, secret fetching is generalized to support namespace-aware lookups, token fallback logic is implemented, and token selection is tested for both presence and precedence scenarios. ChangesGlobal Pull Secret Fallback
Sequence DiagramsequenceDiagram
participant updateToken
participant fetchSecret
participant nextConfig
updateToken->>fetchSecret: fetch openshift-config/pull-secret
fetchSecret-->>updateToken: token or empty
alt Token found
updateToken->>nextConfig: set Token, enable Report
else Token empty
updateToken->>fetchSecret: fetch kube-system/global-pull-secret
fetchSecret-->>updateToken: token or empty
alt Global token found
updateToken->>nextConfig: set Token, enable Report
else Global token empty
updateToken->>nextConfig: leave Token empty
end
end
🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 13 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (13 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: judexzhu The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/retest-required |
|
/retest |
|
@judexzhu: The following test failed, say
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. |
|
/cc |
|
Seems the failed job not relate to my PR change?
|
Summary
On ARO HCP clusters,
openshift-config/pull-secretonly contains the ACR registry credential — nocloud.openshift.comtoken. Customers add their Red Hat pull secret (includingcloud.openshift.com) day-2 viakube-system/additional-pull-secret, which HCCO merges intokube-system/global-pull-secret. The Insights Operator currently only checksopenshift-config/pull-secret, so it reportsNoToken/GatheringDisabledeven though the token exists on the cluster.This change makes
updateToken()checkkube-system/global-pull-secretas a read-only fallback whenopenshift-config/pull-secrethas nocloud.openshift.comtoken.Changes:
fetchSecret()to accept a namespace parameterkube-system/global-pull-secretinupdateToken()getonly, no update/patch) forglobal-pull-secretinkube-systemfetchSecretlog/error messages for debuggabilityBehavior:
openshift-config/pull-secrethas the token, fallback is never reachedkube-system/global-pull-secretwhen primary lackscloud.openshift.comglobal-pull-secretis read-only — the operator does not manage, write, or claim ownership of this secretglobal-pull-secretdoesn't exist (NotFound) or is inaccessible (Forbidden), the fallback is silently skippedTest plan
make test— all unit tests passmake lint— 0 issueskube-system/global-pull-secretwhen primary lackscloud.openshift.comopenshift-config/pull-secrettakes precedence when both havecloud.openshift.comglobal-pull-secret🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes