fix(backup): read registry auth secret from workspace namespace#1597
Conversation
The Dashboard backend's getRegistryCredentials() was reading the auth secret from the operator namespace using the SA kubeconfig, which results in HTTP 403 Forbidden since the Dashboard SA has no RBAC to read secrets in that namespace. DWO always copies the configured auth secret into every workspace namespace as 'devworkspace-backup-registry-auth'. Switch to reading that secret from the workspace namespace using the user kubeconfig, which the Dashboard SA is permitted to access. This fixes the case where deleted workspaces do not appear in the Backups tab: with the old code the registry listing was always unauthenticated, causing it to silently return an empty result for private registries. Resolves: CRW-11079 Assisted-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
|
Hi! I'm che-ai-assistant — I help with your pull requests. Available commands:
|
|
/che-ai-assistant ok-pr-review Review is complete. Please check the review comments below. |
… lookup Remove the SA kubeconfig mock for getRegistryCredentials — the method now reads the fixed-name secret from the workspace namespace via the user kubeconfig instead of reading the operator-configured secret name from the operator namespace via the SA kubeconfig. Assisted-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
tolusha
left a comment
There was a problem hiding this comment.
Code Review Summary
Comprehensive review completed across multiple dimensions:
- Standard Review: ✅ Approve
- Deep Review: ✅ Design is Sound
- Impact Review: ✅ No system-level concerns
✅ Excellent work overall
This is a well-executed fix with several strong points:
- Clean scope - Only touches the two files that need to change, no unnecessary refactoring
- Strong documentation - PR description clearly explains root cause, fix approach, DWO dependency, and manual test steps
- Good comments - Inline comments explain the "why" (e.g., why reading from workspace namespace instead of operator namespace)
- Security improvement - Shift from SA to user kubeconfig follows least-privilege principles
- Test quality - All 8 test cases properly updated with improved assertion rigor (now verifies both secret name and namespace)
Suggestions for improvement
I've posted a few inline suggestions below - all are optional improvements, not blocking issues:
- Add debug logging when secret read fails for better operational troubleshooting
- Document the DWO contract with a source reference
- Consider removing unused
authSecretfromgetBackupRegistryPath()return type - Add a regression test to verify SA API is never used
Noted for coordination
The PR correctly documents the dependency on DWO PR #1631 (removing ownerReferences so the secret survives workspace deletion). Ensure both changes ship together for the full fix.
Review generated by Claude Code with ok-pr-review
|
Suggestion: Add regression test for SA API usage Consider adding a test in |
|
Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1597 (linux/amd64, linux/arm64) kubectl patch commandkubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1597", name: che-dashboard}]}}]" |
- Add warn log when auth secret read fails (was silently returning empty) - Add DWO source reference to BACKUP_REGISTRY_AUTH_SECRET_NAME constant - Remove unused authSecret from getBackupRegistryPath() return type Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Verify that prepareCoreV1API is called exactly once with the user kubeconfig. If someone re-adds saCoreV1Api, this test fails. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1597 +/- ##
==========================================
- Coverage 92.45% 92.45% -0.01%
==========================================
Files 587 585 -2
Lines 60049 59926 -123
Branches 4627 4619 -8
==========================================
- Hits 55518 55404 -114
+ Misses 4472 4463 -9
Partials 59 59 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Done — added in 3721e89. |
Fix import sort order and prettier line-wrapping for logger.warn call. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
… fix Fix import sort order: move logger import after prepareCoreV1API. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
|
Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1597 (linux/amd64, linux/arm64) kubectl patch commandkubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1597", name: che-dashboard}]}}]" |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: akurinnoy, dkwon17, svor 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 |



What does this PR do?
Fixes the
Backupstab showing no entries for deleted workspaces even when backup images still exist in the registry.getRegistryCredentials()inregistryApi.tswas reading the auth secret from the operator namespace using the SA kubeconfig. The Dashboard SA has no RBAC to read secrets there — every call returned 403 Forbidden, causing the registry listing to fall back to unauthenticated access and return[]for private registries.DWO always copies the configured auth secret into the workspace namespace as
devworkspace-backup-registry-auth. This PR switchesgetRegistryCredentials()to read it from there using the user kubeconfig.Note: this is one of two fixes needed to fully resolve CRW-11079. The other is in devworkspace-operator#1631 — without it, DWO sets an
ownerRefon the workspace-namespace secret causing it to be GC'd on workspace deletion.Screenshot/screencast of this PR
What issues does this PR fix or reference?
Fixes https://issues.redhat.com/browse/CRW-11079
Related: devfile/devworkspace-operator#1631
Is it tested? How?
ownerRefon the workspace namespace auth secret (e.g. DWOquay.io/devfile/devworkspace-controller:sha-ec6de18).DevWorkspaceOperatorConfigwith backup enabled and a private registry (e.g. quay.io).Backupstab, see: the deleted workspace entry is visible with a(Deleted)label.Backupstab is empty.Release Notes
Fixed: backup entries for deleted workspaces are now visible in the Backups tab when using a private OCI registry.
Docs PR
N/A