Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Fix sandboxctl destroy timeout #743

Merged
merged 7 commits into from
Jun 17, 2021
Merged
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
7 changes: 7 additions & 0 deletions sre-recipes/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ def _run_command(command):
)
output, error = process.communicate()
return output, error

@staticmethod
def _run_command_interactive(command):
"""Runs the given interactive command that waits for user input and returns any output and error"""
process = subprocess.run(command.split())
Copy link
Member

@daniel-sanche daniel-sanche Jun 17, 2021

Choose a reason for hiding this comment

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

nit: It might be useful to return some data from the completed process like before. If not, then you should get rid of the unused process variable

return


@staticmethod
def _get_project_id():
Expand Down
2 changes: 1 addition & 1 deletion sre-recipes/sandboxctl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def destroy():
"""Delete an existing sandbox"""
os.chdir(os.path.abspath(sys.path[0]))
destroy_command = "../terraform/destroy.sh"
Recipe._run_command(destroy_command)
Recipe._run_command_interactive(destroy_command)
Ayelet41 marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion terraform/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ gcloud projects delete $PROJECT_ID


# if user backed out or deletion failed, stop script
found=$(gcloud projects list --filter="${PROJECT_ID}" --format="value(projectId)")
found=$(gcloud projects describe ${PROJECT_ID} --flatten="lifecycleState" |grep "ACTIVE")
if [[ -n "${found}" ]]; then
log "project $PROJECT_ID not deleted"
sendTelemetry $PROJECT_ID sandbox-not-destroyed
Expand Down