Skip to content

Commit

Permalink
Merge pull request #743 from GoogleCloudPlatform/fix_sandboxctl_timeout
Browse files Browse the repository at this point in the history
Fix sandboxctl destroy timeout
  • Loading branch information
Ayelet41 committed Jun 17, 2021
2 parents 1dff784 + 2380881 commit 21bb114
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
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())
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)


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

0 comments on commit 21bb114

Please sign in to comment.