From 2db42061b07c515a008dee7bea96571a1aba4cbe Mon Sep 17 00:00:00 2001 From: "denis.bilenko" Date: Thu, 19 Nov 2026 10:00:18 +0000 Subject: [PATCH] acc: purge alerts created by bind/alert and generate/alert bind/alert never deleted the alert it created, and generate/alert only deleted the parent directory, which trashes the alert but keeps it. Both leaked an alert per cloud run; the Azure workspace hit its alert quota. aws: TestAccept/bundle/deployment/bind/alert TestAccept/bundle/generate/alert Co-authored-by: Isaac --- acceptance/bundle/deployment/bind/alert/output.txt | 2 ++ acceptance/bundle/deployment/bind/alert/script | 8 ++++++++ acceptance/bundle/generate/alert/output.txt | 2 ++ acceptance/bundle/generate/alert/script | 7 +++++++ 4 files changed, 19 insertions(+) diff --git a/acceptance/bundle/deployment/bind/alert/output.txt b/acceptance/bundle/deployment/bind/alert/output.txt index 4473eb83917..5afb0c2b971 100644 --- a/acceptance/bundle/deployment/bind/alert/output.txt +++ b/acceptance/bundle/deployment/bind/alert/output.txt @@ -30,3 +30,5 @@ Resources: my_alert: Name: test-alert URL: (not deployed) + +>>> [CLI] alerts-v2 trash-alert [ALERT_ID] --purge diff --git a/acceptance/bundle/deployment/bind/alert/script b/acceptance/bundle/deployment/bind/alert/script index 9b6ae2f4085..3a7d8554680 100644 --- a/acceptance/bundle/deployment/bind/alert/script +++ b/acceptance/bundle/deployment/bind/alert/script @@ -3,6 +3,14 @@ envsubst < alert.json.tmpl > alert.json alert_id=$(trace $CLI alerts-v2 create-alert --json @alert.json | jq -r '.id') add_repl "$alert_id" ALERT_ID + +# Unbind leaves the alert in place; purge it so leaked alerts do not exhaust the +# workspace quota for alerts. +cleanup() { + trace $CLI alerts-v2 trash-alert $alert_id --purge +} +trap cleanup EXIT + trace $CLI bundle deployment bind my_alert $alert_id --auto-approve trace $CLI bundle summary diff --git a/acceptance/bundle/generate/alert/output.txt b/acceptance/bundle/generate/alert/output.txt index 774cd68f1ca..9d4878d19eb 100644 --- a/acceptance/bundle/generate/alert/output.txt +++ b/acceptance/bundle/generate/alert/output.txt @@ -13,4 +13,6 @@ include: - out/resource/*.yml +>>> [CLI] alerts-v2 trash-alert [ALERT_ID] --purge + >>> [CLI] workspace delete /Workspace/Users/[USERNAME]/test-[UNIQUE_NAME] --recursive diff --git a/acceptance/bundle/generate/alert/script b/acceptance/bundle/generate/alert/script index 1d5e4b165d5..5ab1f23e3eb 100644 --- a/acceptance/bundle/generate/alert/script +++ b/acceptance/bundle/generate/alert/script @@ -6,4 +6,11 @@ alert_id=$($CLI alerts-v2 create-alert --json @alert.json | jq -r '.id') add_repl "$alert_id" ALERT_ID rm alert.json +# Purge the alert: deleting its parent dir in script.cleanup only trashes it, and a +# trashed alert is kept until purged. Leaked alerts exhaust the workspace alert quota. +cleanup_alert() { + trace $CLI alerts-v2 trash-alert $alert_id --purge +} +trap cleanup_alert EXIT + trace $CLI bundle generate alert --existing-id $alert_id --source-dir out/alert --config-dir out/resource