Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions run/django/e2e_test_cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ steps:
./retry.sh "gcloud secrets describe ${_SECRET_SETTINGS_NAME}" \
"gcloud secrets delete ${_SECRET_SETTINGS_NAME} --quiet --project $PROJECT_ID"
./retry.sh "gsutil ls gs://${_STORAGE_BUCKET}" \
"gsutil -m rm -r gs://${_STORAGE_BUCKET}"
./retry.sh "gcloud storage ls gs://${_STORAGE_BUCKET}" \
"gcloud storage rm --recursive gs://${_STORAGE_BUCKET}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The migrated command gcloud storage rm --recursive gs://${_STORAGE_BUCKET} only deletes the contents of the bucket, not the bucket itself. The original gsutil rm -r command was likely incorrect as it would fail when used on a bucket URI. While this change fixes the command execution error, it doesn't complete the cleanup, leaving an empty bucket behind. To prevent resource leaks, the bucket itself should be deleted. I suggest chaining the bucket deletion command after emptying it. Using /** ensures all object versions are deleted, which is important if versioning is enabled on the bucket.

          "gcloud storage rm --recursive gs://${_STORAGE_BUCKET}/** && gcloud storage buckets delete gs://${_STORAGE_BUCKET}"

./retry.sh "gcloud artifacts docker images describe ${_IMAGE_NAME}" \
"gcloud artifacts docker images delete ${_IMAGE_NAME} --quiet"
Expand Down
8 changes: 3 additions & 5 deletions run/django/e2e_test_setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ steps:
args:
- "-c"
- |
./retry.sh "gsutil mb \
-l ${_REGION} \
-p ${PROJECT_ID} \
gs://${_STORAGE_BUCKET}"
./retry.sh "gcloud storage buckets create gs://${_STORAGE_BUCKET} \
--location ${_REGION} \
--project ${PROJECT_ID}"

- id: "IAM and Secrets"
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
Expand Down Expand Up @@ -148,4 +147,3 @@ substitutions:
_DB_PASS: password1234
_ADMIN_PASSWORD: superpass
_ADMIN_EMAIL: [email protected]