fix(home): skip persistent home init container for ephemeral workspaces#1651
fix(home): skip persistent home init container for ephemeral workspaces#1651tolusha wants to merge 1 commit into
Conversation
When a DevWorkspaceOperatorConfig defines an init-persistent-home entry in workspace.initContainers, the config merge logic only checked whether persistent home was globally enabled (PersistUserHomeEnabled) but not whether the specific workspace actually needs it. Ephemeral workspaces passed this check, causing an init container to be injected that references a non-existent persistent-home volume and potentially has no image — resulting in an invalid Deployment. Add a NeedsPersistentHomeDirectory check to also skip the config-level init container when the workspace storage strategy does not support home persistence (e.g. ephemeral storage). Fixes: eclipse-che/che#23884 Assisted-by: Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Anatolii Bazko <abazko@redhat.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tolusha 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 |
|
Warning Review limit reached
More reviews will be available in 40 minutes and 22 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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! I'm che-ai-assistant — I help with your pull requests. Available commands:
|
|
/che-ai-assistant ok-pr-review |
tolusha
left a comment
There was a problem hiding this comment.
Review Summary
This is a well-crafted bug fix that correctly addresses the issue. The fix is minimal, surgical, and reuses existing abstractions appropriately. The main concern is test coverage, which you've already acknowledged as TODO.
Positive Observations
- The fix correctly delegates to
NeedsPersistentHomeDirectory()rather than duplicating logic - The log message is distinct and diagnostic-friendly
- Commit message thoroughly explains root cause and fix
- Design is sound - aligns the config-level guard logic with the Devfile-level path
Key Findings
I've added inline comments with specific recommendations. The most important is adding test coverage for the ephemeral storage case.
Review conducted using ok-pr-review
| continue | ||
| } | ||
| // Skip if workspace does not need persistent home (e.g. ephemeral storage) | ||
| if !home.NeedsPersistentHomeDirectory(workspace) { |
There was a problem hiding this comment.
Add test coverage for ephemeral storage case
The PR description marks testing as "TODO". This is a bug fix in the main reconciliation loop - the exact kind of change that benefits most from a unit test proving ephemeral workspaces skip the init container.
The existing pkg/library/home/persistentHome_test.go tests NeedsPersistentHomeDirectory itself, but there's no test verifying the controller's filtering logic applies it correctly. More importantly, none of the 10 test fixtures in testdata/persistent-home/ test the ephemeral storage branch (storageStrategySupportsPersistentHome returning false).
Recommendation: Add a test fixture like noop-if-ephemeral-storage.yaml to pkg/library/home/testdata/persistent-home/ with:
- Workspace that has
controller.devfile.io/storage-type: ephemeralin its attributes - Persistent home enabled in config
- Expected output: workspace unchanged (no home volume added)
This is low-effort (YAML file only) and closes the only real coverage gap.
| continue | ||
| } | ||
| // Skip if workspace does not need persistent home (e.g. ephemeral storage) | ||
| if !home.NeedsPersistentHomeDirectory(workspace) { |
There was a problem hiding this comment.
Minor note - redundant check
home.NeedsPersistentHomeDirectory(workspace) internally calls home.PersistUserHomeEnabled(workspace) (see persistentHome.go:96), which is already checked on line 418 above.
This is harmless - the function is cheap and the double-check doesn't affect correctness. The current approach preserves distinct log messages for each skip reason, which aids debugging. Not a defect, just worth noting for future maintainers.
When a DevWorkspaceOperatorConfig defines an init-persistent-home entry in workspace.initContainers, the config merge logic only checked whether persistent home was globally enabled (PersistUserHomeEnabled) but not whether the specific workspace actually needs it. Ephemeral workspaces passed this check, causing an init container to be injected that references a non-existent persistent-home volume and potentially has no image — resulting in an invalid Deployment.
Add a NeedsPersistentHomeDirectory check to also skip the config-level init container when the workspace storage strategy does not support home persistence (e.g. ephemeral storage).
Assisted-by: Claude Code
What issues does this PR fix or reference?
eclipse-che/che#23884
Is it tested? How?
TODO
PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-pathto trigger)v8-devworkspace-operator-e2e: DevWorkspace e2e testv8-che-happy-path: Happy path for verification integration with Che