Skip to content

Commit 6a43adb

Browse files
committed
fix(bucket): drop no-op label-based order/challenge delete
Per maintainer review: the label selector cert-manager.io/certificate-name=<release>-ui-tls matches nothing — Challenge objects carry no labels, and on Orders certificate-name is an annotation (not a label). Orders are already reaped by the Certificate owner cascade and Challenges by the host-scoped .spec.dnsName sweep, so the line deleted nothing and its comment misstated cert-manager labeling. Remove the dead delete, replace the inaccurate comment, and drop the test assertion that pinned it; add negative assertions so a label-based order/challenge delete cannot be reintroduced. Assisted-By: Claude <[email protected]> Signed-off-by: Алексей Артамонов <[email protected]>
1 parent 58b2a3d commit 6a43adb

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎packages/apps/bucket/templates/hooks/cleanup-acme.yaml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ spec:
6565
# populates ({{ .Release.Name }}-ui-tls).
6666
kubectl delete certificate {{ .Release.Name }}-ui-tls -n {{ .Release.Namespace }} --ignore-not-found --wait=false --request-timeout=30s \
6767
|| echo "WARNING: cert-manager cleanup failed for {{ .Release.Name }}; orphaned ACME resources may remain" >&2
68-
# Orders/Challenges do NOT carry the Helm app.kubernetes.io/instance
69-
# label; cert-manager stamps them with its own
70-
# cert-manager.io/certificate-name label, so target them by the
71-
# Certificate name to reliably reap any that outlived the cascade.
72-
kubectl delete order,challenge -n {{ .Release.Namespace }} -l cert-manager.io/certificate-name={{ .Release.Name }}-ui-tls --ignore-not-found --wait=false --request-timeout=30s \
73-
|| echo "WARNING: cert-manager cleanup failed for {{ .Release.Name }}; orphaned ACME resources may remain" >&2
68+
# Orders are owned by the Certificate and are removed by the cascade
69+
# above; Challenges carry no labels and are reaped by the
70+
# host-scoped .spec.dnsName sweep below. There is therefore no
71+
# reliable label selector for Order/Challenge, so we do not attempt
72+
# a label-based delete here.
73+
#
7474
# Release-scoped solver sweep. We deliberately do NOT delete
7575
# ingress/service/pod objects namespace-wide by the
7676
# acme.cert-manager.io/http01-solver=true label: that label is set

‎packages/apps/bucket/tests/cleanup_acme_test.yaml‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ tests:
6767
- matchRegex:
6868
path: spec.template.spec.containers[0].command[2]
6969
pattern: "kubectl delete certificate my-bucket-ui-tls -n tenant-root"
70-
# Orders/Challenges are targeted by cert-manager's own
71-
# cert-manager.io/certificate-name label, not the Helm release label.
72-
- matchRegex:
70+
# Orders are removed by the Certificate cascade and Challenges by the
71+
# host-scoped dnsName sweep. cert-manager puts no usable label on either
72+
# (Challenges are unlabeled; certificate-name is an annotation on Orders),
73+
# so the hook must NOT attempt a label-based order/challenge delete.
74+
- notMatchRegex:
7375
path: spec.template.spec.containers[0].command[2]
74-
pattern: "kubectl delete order,challenge -n tenant-root -l cert-manager.io/certificate-name=my-bucket-ui-tls"
75-
# The release label selector must NOT be used for cert-manager resources.
76+
pattern: "delete order,challenge"
7677
- notMatchRegex:
7778
path: spec.template.spec.containers[0].command[2]
7879
pattern: "delete .*-l app.kubernetes.io/instance=my-bucket"

0 commit comments

Comments
 (0)