fix : reset workspace storage defaults when PVC config removed#2061
fix : reset workspace storage defaults when PVC config removed#2061tolusha merged 1 commit intoeclipse-che:mainfrom
Conversation
|
Skipping CI for Draft Pull Request. |
| constants.PerWorkspacePVCStorageStrategy: devEnvironments.Storage.PerWorkspaceStrategyPvcConfig, | ||
| }[pvcStrategy] | ||
|
|
||
| workspaceConfig.StorageAccessMode = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce} |
There was a problem hiding this comment.
Please, add a constant for default access mode
There was a problem hiding this comment.
Sorry, I've added it to constants.go and reference it here.
84a9d56 to
c0a4aa4
Compare
| constants.PerWorkspacePVCStorageStrategy: devEnvironments.Storage.PerWorkspaceStrategyPvcConfig, | ||
| }[pvcStrategy] | ||
|
|
||
| workspaceConfig.StorageAccessMode = constants.DefaultWorkspaceStorageAccessMode |
There was a problem hiding this comment.
What happens if we set
workspaceConfig.StorageAccessMode = nil
instead?
Would the DWO set the default value in that case?
There was a problem hiding this comment.
No, according to the current logic:
- If the workspace PVC Config (e.g.,
perUserStrategyPvcConfig) is defined and it has StorageAccessMode nil, we assign it as it is (nilin this case).
storage:
perUserStrategyPvcConfig:
storageAccessMode: null
pvcStrategy: per-user- If the workspace PVC config is omitted like this, we assign a default value:
storage:
pvcStrategy: per-userDo you think we should add a nil or empty array check here? But since it's explicitly specified by user shall we accept it as it is?
There was a problem hiding this comment.
Basically what I want to avoid is to define and use DefaultWorkspaceStorageAccessMode = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce} in che-operator.
In line 179 if we have:
workspaceConfig.StorageAccessMode = nil
instead of:
workspaceConfig.StorageAccessMode = constants.DefaultWorkspaceStorageAccessMode
would it mean that if perUserStrategyPvcConfig is not defined, then thestorageAccessMode field will be unset/removed in the DWOC?
If it's removed in the DWOC, then the DevWorkspace operator should use the default value for storageAccessMode, which IMHO is preferable than defining constants.DefaultWorkspaceStorageAccessMode in che-operator
There was a problem hiding this comment.
you're right. Let me update it accordingly.
Previously, removing a workspace PVC Config (e.g., `perUserStrategyPvcConfig`)
did not reset workspaceConfig fields. As a result, stale values in persisted
instead of reverting to defaults.
This change explicitly resets:
- `StorageAccessMode` to `{ReadWriteOnce}`
- `StorageClassName` to `nil`
- `DefaultStorageSize` to `nil`
before applying any PVC config, ensuring that removing PVC config restores default
workspace storage settings.
Signed-off-by: Rohan Kumar <rohaan@redhat.com>
c0a4aa4 to
c162c82
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2061 +/- ##
==========================================
+ Coverage 49.60% 49.92% +0.32%
==========================================
Files 92 94 +2
Lines 12311 12552 +241
==========================================
+ Hits 6107 6267 +160
- Misses 5773 5858 +85
+ Partials 431 427 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dkwon17, rohanKanojia, 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 |
What does this PR do?
Previously, removing a workspace PVC Config (e.g.,
perUserStrategyPvcConfig) did not reset workspaceConfig fields. As a result, stale values in persisted instead of reverting to defaults. See my comment on this issue eclipse-che/che#23502 (comment)This change explicitly resets:
StorageAccessModeto{ReadWriteOnce}StorageClassNametonilDefaultStorageSizetonilbefore applying any PVC config, ensuring that removing PVC config restores default workspace storage settings.
Screenshot/screencast of this PR
What issues does this PR fix or reference?
eclipse-che/che#23502
How to test this PR?
OpenShift
or
on Minikube
kubectl patch checluster eclipse-che -n eclipse-che --type merge -p '{"spec":{"devEnvironments":{"storage":{"perUserStrategyPvcConfig":{"storageAccessMode":["ReadWriteMany"]}}}}}' checluster.org.eclipse.che/eclipse-che patchedkubectl patch checluster eclipse-che -n eclipse-che --type merge -p '{"spec":{"devEnvironments":{"storage":{"perUserStrategyPvcConfig":null}}}}' checluster.org.eclipse.che/eclipse-che patchedCommon Test Scenarios
PR Checklist
As the author of this Pull Request I made sure that:
Reviewers
Reviewers, please comment how you tested the PR when approving it.