Fix default pull secret configuration for new service accounts#16617
Fix default pull secret configuration for new service accounts#16617rzhabbarov wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rzhabbarov 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 |
WalkthroughThe ChangesPullSecret imagePullSecrets field tracking and modal submit callback
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @rzhabbarov. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
|
@rhamilto I don't have a Jira/OCPBUGS issue for this bug yet. Could you please advise whether I should create one, or can this PR be triaged as-is? |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/public/components/__tests__/namespace.spec.tsx (1)
71-91: ⚡ Quick winAdd a test for the existing-field branch (
hasImagePullSecretsField: true).This regression covers the missing-field path well, but the modal has a second patch strategy for when
imagePullSecretsalready exists. Add a case withk8sGetMock.mockResolvedValue({ imagePullSecrets: [] })and assert launched modal props sethasImagePullSecretsFieldtotrue.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/public/components/__tests__/namespace.spec.tsx` around lines 71 - 91, Add a new test case similar to the existing "shows a newly configured default pull secret without reloading the page" test that covers the scenario where imagePullSecrets already exist. In this new test, change k8sGetMock.mockResolvedValue to pass an object with imagePullSecrets field (e.g., imagePullSecrets: []) instead of an empty object, then verify that the launched modal receives modalProps.hasImagePullSecretsField set to true instead of false, ensuring both code paths (existing and missing imagePullSecrets field) are tested.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/public/components/modals/configure-ns-pull-secret-modal.tsx`:
- Around line 67-82: The getDefaultServiceAccountPatch function relies on stale
cached state (hasImagePullSecretsField) to determine the patch strategy, which
can lead to destructive overwrites of existing imagePullSecrets if the field was
concurrently created. Instead of deriving the patch strategy from cached state
at modal creation time, fetch the fresh ServiceAccount state at the moment the
patch is being submitted/applied, inspect the current state of the
imagePullSecrets field, and use that real-time information to decide whether to
append to the existing list (add to array) or initialize the field. This ensures
the patch strategy reflects the actual current state rather than potentially
stale cached information.
---
Nitpick comments:
In `@frontend/public/components/__tests__/namespace.spec.tsx`:
- Around line 71-91: Add a new test case similar to the existing "shows a newly
configured default pull secret without reloading the page" test that covers the
scenario where imagePullSecrets already exist. In this new test, change
k8sGetMock.mockResolvedValue to pass an object with imagePullSecrets field
(e.g., imagePullSecrets: []) instead of an empty object, then verify that the
launched modal receives modalProps.hasImagePullSecretsField set to true instead
of false, ensuring both code paths (existing and missing imagePullSecrets field)
are tested.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 890bd20c-6b35-4120-ab7b-2bb8cc287741
📒 Files selected for processing (3)
frontend/public/components/__tests__/namespace.spec.tsxfrontend/public/components/modals/configure-ns-pull-secret-modal.tsxfrontend/public/components/namespace.jsx
When a default ServiceAccount does not have imagePullSecrets, adding to /imagePullSecrets/- fails because the parent field does not exist. Create the field when needed and update the page state after the pull secret is configured so the UI reflects the change without a reload.
Fetch the default ServiceAccount after creating the Secret and build the JSON Patch from the current imagePullSecrets field. This avoids replacing an existing imagePullSecrets array when the page state is stale.
fa7f51e to
71b9a50
Compare
Summary
Fix configuring a namespace default pull secret when the default ServiceAccount does not already have
imagePullSecrets.The change now:
imagePullSecretswhen the field is missingTesting
cd frontend && HOME=/home/openshift-cluster-console/.test-home node .yarn/releases/yarn-4.14.1.cjs test public/components/__tests__/namespace.spec.tsx --runInBandcd frontend && HOME=/home/openshift-cluster-console/.test-home node .yarn/releases/yarn-4.14.1.cjs eslint public/components/__tests__/namespace.spec.tsx public/components/namespace.jsx public/components/modals/configure-ns-pull-secret-modal.tsxSummary by CodeRabbit
Release Notes
Bug Fixes
Tests