Use replica-level dataVolumeClaimTemplate and logVolumeClaimTemplate when the shard's field is not set. #1861
+289
−10
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.
in the case where replicas override
dataVolumeClaimTemplates/logVolumeClaimTemplatesbut the shard does not set it, the replica-level overrides are ignored. This fix prefers the replica settings always as they are more fine grained control points.I found this while attempting to do something a little bit out of the box: attempting to leverage the operator to migrate a clickhouse cluster from an old storageclass to a new one by leveraging the replica level template overrides.
So I'm going from this type of spec, which uses the
defaultsfor each shard and replica:And I'd like to migrate to this, which should have the effect of (re)creating the 3 existing replicas using their existing PVs, and adding a new replica to the shard which uses the new storageclass via the
logVolumeClaimTemplate + dataVolumeClaimTemplatefields.What happens though, is that the new replica
0-4is created using the default dataVolumeClaim instead of the one that is specified in the replica-level field of the spec.While trying to get this to work, I noticed that the replica level
dataVolumeClaimTemplatefield is ignored if it is not also set in the shard. This PR removes the shard-level check in favour of the replica-level field which allows for finer grained control of the logVolumeClaimTemplates and dataVolumeClaimTemplates.NOTE: I believe this to be a bug fix since replica level
logVolumeClaimTemplate + dataVolumeClaimTemplateconfigurations are ignored when both shard and replica were set, but it will change behaviour for users:Thanks for taking the time to contribute to
clickhouse-operator!Please, read carefully instructions on how to make a Pull Request.
This will help a lot for maintainers to adopt your Pull Request.
Important items to consider before making a Pull Request
Please check items PR complies to:
next-releasebranch, not intomasterbranch1. More info--
1 If you feel your PR does not affect any Go-code or any testable functionality (for example, PR contains docs only or supplementary materials), PR can be made into
masterbranch, but it has to be confirmed by project's maintainer.