Fix missing ownerReferences in pvc metadata #1837
Merged
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.
Problem
See issue #1799, #1843
Root Cause
By default, the Clickhouse Helm chart deploys the Keeper StatefulSet with PVCs provisioned by the Operator (
chk.yaml
:33), but the Operator does not setmetadata.OwnerReferences
on the PVCs.Without
metadata.OwnerReferences
correctly set, ArgoCD can't attribute the PVCs to the application installation, and will incorrectly mark the PVCs asOutOfSync
, which leads to the following undesirable behaviors/workarounds documented in the aforementioned issue.The cluster instance's PVCs don't encounter the same issue because the Helm chart
chi.yaml
doesn't specifyspec.defaults.storageManagement.provisioner
, so the defaultStatefulSet
provisioner is used:clickhouse-operator/pkg/model/common/volume/volumer.go
Lines 60 to 61 in 732a1be
Thus, ArgoCD is able to correctly map the StatefulSet-created PVCs to the CHI StatefulSet resources.
Solution: set
metadata.OwnerReferences
on PVCsThere's already precedence with doing this on Operator-provisioned StatefulSet and Service k8s resources:
clickhouse-operator/pkg/model/common/creator/stateful-set.go
Lines 35 to 41 in 732a1be
clickhouse-operator/pkg/model/common/creator/service.go
Lines 81 to 85 in 732a1be
This PR makes code changes in a similar manner to the above code snippets.
Pull Request checklist
next-release
branch, not intomaster
branch1. More info