mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 20:23:39 +09:00
The tenant addon HelmRelease remediates a failed install by uninstalling the release, and an uninstall deletes whatever the chart rendered. Deleting a CRD makes the API server garbage-collect every custom resource of that kind, so a failed reinstall takes every VolumeSnapshot and VolumeSnapshotContent in the tenant cluster with it — the objects that carry the only reference to a snapshot on the storage backend. Stamp helm.sh/resource-policy: keep on each CustomResourceDefinition and teach `make update` to reapply it, since that target rebuilds templates/ from upstream and would otherwise drop the annotation silently. Removing the release on purpose now leaves the definitions behind to be deleted by hand. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
26 lines
1.5 KiB
Makefile
26 lines
1.5 KiB
Makefile
export NAME=vsnap-crd
|
|
export NAMESPACE=cozy-$(NAME)
|
|
|
|
include ../../../hack/package.mk
|
|
|
|
test:
|
|
helm unittest .
|
|
|
|
# Stamp helm.sh/resource-policy: keep on every CustomResourceDefinition so a
|
|
# chart uninstall never garbage-collects the CRDs and, with them, every
|
|
# VolumeSnapshot and VolumeSnapshotContent in the cluster — the objects that
|
|
# hold the only reference to a snapshot on the storage backend.
|
|
# The stamp goes into the CRD's existing metadata.annotations block; a CRD that
|
|
# arrives without one is skipped, and the chart's helm-unittest suite is what
|
|
# catches that.
|
|
update:
|
|
rm -rf templates
|
|
mkdir templates
|
|
wget -O ./templates/volumesnapshotclasses.yaml https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/refs/tags/v8.3.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
|
|
wget -O ./templates/volumesnapshotcontents.yaml https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/refs/tags/v8.3.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
|
|
wget -O ./templates/volumesnapshots.yaml https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/refs/tags/v8.3.0/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
|
|
@set -e; tmp=$$(mktemp); for f in ./templates/*.yaml; do \
|
|
awk '/^ helm.sh\/resource-policy: keep$$/{next} /^kind: /{kind=$$2} /^ annotations:$$/ && kind=="CustomResourceDefinition"{print; print " helm.sh/resource-policy: keep"; next} {print}' "$$f" > "$$tmp"; \
|
|
cat "$$tmp" > "$$f"; \
|
|
done; rm -f "$$tmp"
|