mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
test(clickhouse): delete the round-trip's Certificate before its Secret
cert-manager issues the Secret of a Certificate that still exists again as soon as it is deleted, and the Certificate is only removed by Chainsaw's own cleanup after the step's finally has run. Deleting the Secret first therefore left a freshly issued copy behind in tenant-root, carrying no owner reference to take it down with the Certificate. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
1 parent
1003cdb1b6
commit
6e23bd5629
2 files changed
+28
-2
No files matched your search
@@ -179,3 +179,26 @@ STUBEOF
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
# cert-manager issues the Secret of a Certificate that still exists again as
|
||||
# soon as it is deleted, so the Certificate has to go first or its Secret
|
||||
# outlives the run.
|
||||
@test "the round-trip cleanup deletes the Certificate before its Secret" {
|
||||
script=$(yq 'select(.metadata.name == "clickhouse-3-system-bucket-roundtrip") | .spec.steps[]
|
||||
| select(.name == "run") | .finally[]
|
||||
| select(.description == "system-bucket round-trip cleanup") | .script.content' \
|
||||
hack/e2e-chainsaw/clickhouse/chainsaw-test.yaml)
|
||||
[ -n "$script" ] || { echo "the run step has no system-bucket round-trip cleanup" >&2; false; }
|
||||
cat >"$STUB/kubectl" <<'STUBEOF'
|
||||
#!/bin/bash
|
||||
echo "$*" >>"$STUB/calls"
|
||||
STUBEOF
|
||||
PATH="$STUB:$PATH" NAMESPACE=tenant-root sh -c "$script"
|
||||
cert=$(grep -nE '^-n tenant-root delete certificate e2e-system-bucket-s3( |$)' "$STUB/calls" | cut -d: -f1)
|
||||
secret=$(grep -nE '^-n tenant-root delete secret e2e-system-bucket-s3-tls( |$)' "$STUB/calls" | cut -d: -f1)
|
||||
[ -n "$cert" ] && [ -n "$secret" ] && [ "$cert" -lt "$secret" ] || {
|
||||
echo "the cleanup does not delete Certificate e2e-system-bucket-s3 before Secret e2e-system-bucket-s3-tls; kubectl calls:" >&2
|
||||
cat "$STUB/calls" >&2
|
||||
false
|
||||
}
|
||||
}
|
||||
@@ -559,10 +559,12 @@ spec:
|
||||
'
|
||||
# Chainsaw did not apply these: the jobs come from the script and the
|
||||
# Backup from the controller, and deleting a BackupJob reclaims no Backup.
|
||||
# The Certificate's Secret outlives the Certificate Chainsaw deletes.
|
||||
# The Certificate's Secret outlives the Certificate, and cert-manager
|
||||
# issues it again while the Certificate exists, so the Certificate goes
|
||||
# first rather than at Chainsaw's cleanup after this finally.
|
||||
- description: system-bucket round-trip cleanup
|
||||
script:
|
||||
timeout: 3m
|
||||
timeout: 4m
|
||||
content: |
|
||||
set -eu
|
||||
kubectl -n "$NAMESPACE" delete restorejob sysbucket-restore --ignore-not-found --wait=true --timeout=30s
|
||||
@@ -570,4 +572,5 @@ spec:
|
||||
# The driver names the Backup after the BackupJob; by name it is
|
||||
# found even when status.backupRef was never written.
|
||||
kubectl -n "$NAMESPACE" delete backup sysbucket-backup --ignore-not-found --wait=true --timeout=60s
|
||||
kubectl -n "$NAMESPACE" delete certificate e2e-system-bucket-s3 --ignore-not-found --wait=true --timeout=30s
|
||||
kubectl -n "$NAMESPACE" delete secret e2e-system-bucket-s3-tls --ignore-not-found --wait=true --timeout=30s
|
||||
Reference in new issue
Block a user