Apply pvc override in Update() rather than Build() #819
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This closes #
Note to reviewers: remember to look at the commits in this PR and consider if they can be squashed
Summary Of Changes
This PR addresses a bug with storage capacity. When a PVC override is provided with the default PVC name "persistence", the created PVC will have the storage from
spec.persistence.storage
rather than the storage capacity set in the PVC override. This can be reproduced with the below manifest, where the created storage would be10Gi
rather than15Gi
from the override:This is due to: PVC override is currently handled in
Build()
.Update()
is called afterBuild()
and we currently allow default PVC expansion which updates the storage capacity inUpdate()
. So the storage from override for the default persistence is being overwritten byspec.persistence.storage
because ofupdatePersistenceStorageCapacity()
.To fix this issue (when PVC override is provided, storage capacity should be what's set in the override rather than the top level spec), I've moved the applying PVC override logic to
Update()
which will happen afterupdatePersistenceStorageCapacity()
. This means that when users set default persistence through PVC override, storage capacity would be whatever set in the override. An additional change of behavior is: updates to the list of PVC override will be attempted by the operator instead of silently ignored. Previously, when updates to PVC override is ignored by the cluster operator because the PVC override is only handled inBuild()
, not inUpdate()
. This this change, updates to the PVC override will be applied and it will always fail because updates to volume templates is forbidden by the sts controller.Tested in unit tests.
Additional Context
Local Testing