Delete postgres pvcs from pulumi down
Fix https://github.com/DACH-NY/canton-network-internal/issues/7564
Problem
cncluster pulumi_down_canton deletes the in-cluster Postgres StatefulSets but not their PVCs. A following pulumi_up_canton generates a new random Postgres password, but the new pod reattaches the old PVC, whose data directory still holds the old password hash. Postgres only applies POSTGRES_PASSWORD when initialising an empty data directory, so the Canton nodes can no longer authenticate and the stack's up fails.
Why it happens:
- Kubernetes retains PVCs when the StatefulSet is deleted.
sv-cantonstacks declare thenamespacewithretainOnDelete: trueso the namespace cascade that cleans up PVCs incncluster resetdoesn't happen here.
It goes unnoticed because cncluster apply + cncluster reset deletes the namespace and the PVCs
with it. It only hits the up/down-only workflow.
Check problem
cncluster apply --sv1-only
cncluster pulumi_down_canton
cncluster pulumi_up_canton
FATAL: password authentication failed for user "cnadmin"
Solution and why a separate flag
New config pulumiProjectConfig.deletePostgresPvcsOnDelete (default false), set to true in
scratchnet.yaml. When on, the Postgres StatefulSet gets
persistentVolumeClaimRetentionPolicy: { whenDeleted: Delete, whenScaled: Retain }, so Kubernetes
deletes the PVCs together with the StatefulSet. The field is only emitted when the flag is on, so
the spec of every other cluster is unchanged.
Testing solution
cncluster reset
cncluster apply --sv1-only
DSO_SIZE=1 SPLICE_SKIP_EXTRA_SVS=true cncluster pulumi_down_canton
DSO_SIZE=1 SPLICE_SKIP_EXTRA_SVS=true cncluster pulumi_up_canton
Postgres PVCs that cncluster apply --sv1-only created for the sv-canton stackwere deleted by cncluster pulumi_down_canton, and cncluster pulumi_up_canton created new ones. All three PVC UIDs changed