Skip to content

Commit 67c6a6b

Browse files
authored
[bugbash] hack/teardown.sh: add --cluster-scoped to tear down one cluster (#3296)
`hack/teardown.sh --all` deletes resources that every Substrate cluster in the project shares, so cleaning up one cluster broke image pulls and snapshot transfers on the others. Fixes #3227 - `--cluster-scoped` deletes only the cluster, its buckets and the bindings on them. - `--all` still deletes everything setup-gcp created, including the dashboards, the transfer service account and the project-level IAM bindings. The usage text lists those steps as project-wide. - The README says to use `--cluster-scoped` while other clusters share the project. Assisted by Claude Code. I reviewed the diff. --------- Signed-off-by: Haven Xia <[email protected]>
1 parent 7a19374 commit 67c6a6b

2 files changed

Lines changed: 28 additions & 14 deletions

File tree

‎README.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,12 @@ go run ./cmd/ate-setup delete all
230230
If you need to delete the resources created by the setup script, you can use the provided script `hack/teardown.sh`. This script will delete resources in the reverse order of creation and handles partial failures gracefully.
231231

232232
```bash
233-
./hack/teardown.sh --all
233+
./hack/teardown.sh [--all|--cluster-scoped]
234234
```
235235

236+
* `--all` deletes everything, including the dashboards, the snapshot transfer service account and the project-level IAM bindings, which every Substrate cluster in the project shares.
237+
* `--cluster-scoped` deletes only this cluster, its buckets and the bindings on them. Use it while other Substrate clusters still use the project.
238+
236239
Or run individual teardown steps as needed (see `./hack/teardown.sh` for available options).
237240

238241
#### Tearing down local `kind` resources

‎hack/teardown.sh‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,17 @@ transfer_service_account() {
5050
function usage() {
5151
echo "Usage: $0 [options]"
5252
echo "Options:"
53-
echo " --revoke-gke-node-permissions Revoke GKE nodes permission to pull images"
54-
echo " --revoke-atelet-permissions Revoke atelet's project-level IAM bindings"
5553
echo " --delete-iam-policy-bindings Delete bucket IAM policy bindings for atelet, ate-api-server and the transfer account"
56-
echo " --delete-transfer-service-account Delete the snapshot transfer service account"
5754
echo " --delete-snapshot-bucket Delete snapshot bucket"
5855
echo " --delete-gvisor-node-pool Delete gVisor node pool"
5956
echo " --delete-cluster Delete GKE cluster"
57+
echo " --cluster-scoped Run the steps above (reverse order of setup)"
58+
echo "Project-wide options. These affect every Substrate cluster in the project:"
6059
echo " --delete-dashboards Delete the Substrate monitoring dashboards"
61-
echo " --all Run all teardown steps (reverse order of setup)"
60+
echo " --delete-transfer-service-account Delete the snapshot transfer service account"
61+
echo " --revoke-atelet-permissions Revoke atelet's project-level IAM bindings"
62+
echo " --revoke-gke-node-permissions Revoke GKE nodes permission to pull images, on every cluster that uses the default compute service account"
63+
echo " --all Run every step above (reverse order of setup)"
6264
exit 1
6365
}
6466

@@ -189,6 +191,19 @@ delete_cluster() {
189191
--quiet || true
190192
}
191193

194+
# delete_buckets_and_cluster deletes the buckets, the node pool and the cluster.
195+
delete_buckets_and_cluster() {
196+
delete_snapshot_bucket
197+
# Deleting the cluster removes its node pools, so this does not insist on a
198+
# pool name a caller (e.g. an installer) may not track.
199+
if [ -n "${NODE_POOL_NAME:-}" ]; then
200+
delete_gvisor_node_pool
201+
else
202+
echo "NODE_POOL_NAME not set; skipping node pool deletion (the cluster deletion removes its pools)"
203+
fi
204+
delete_cluster
205+
}
206+
192207
# --- Main Logic ---
193208
if [ "$#" -eq 0 ]; then
194209
usage
@@ -204,21 +219,17 @@ while [[ "$#" -gt 0 ]]; do
204219
--delete-gvisor-node-pool) delete_gvisor_node_pool ;;
205220
--delete-cluster) delete_cluster ;;
206221
--delete-dashboards) delete_dashboards ;;
222+
--cluster-scoped)
223+
delete_iam_policy_bindings
224+
delete_buckets_and_cluster
225+
;;
207226
--all)
208227
delete_dashboards
209228
delete_iam_policy_bindings
210229
delete_transfer_service_account
211230
revoke_atelet_permissions
212231
revoke_gke_node_permissions
213-
delete_snapshot_bucket
214-
# Deleting the cluster removes its node pools, so --all does not insist
215-
# on a pool name a caller (e.g. an installer) may not track.
216-
if [ -n "${NODE_POOL_NAME:-}" ]; then
217-
delete_gvisor_node_pool
218-
else
219-
echo "NODE_POOL_NAME not set; skipping node pool deletion (the cluster deletion removes its pools)"
220-
fi
221-
delete_cluster
232+
delete_buckets_and_cluster
222233
;;
223234
*) usage ;;
224235
esac

0 commit comments

Comments
 (0)