Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Don't attempt to reconnect if the instance is no longer RUNNING. #1368

Merged
merged 2 commits into from
May 17, 2017

Conversation

jimmc
Copy link
Contributor

@jimmc jimmc commented May 17, 2017

This fixes #1111. If the instance is no longer RUNNING when it is time to attempt to reconnect, it just prints a message and exits.

@jimmc jimmc requested a review from ojarjur May 17, 2017 00:28
ojarjur
ojarjur previously approved these changes May 17, 2017
# Before we try to reconnect, check to see if the VM is still running.
status, metadata_items = utils.describe_instance(
args, gcloud_compute, instance)
if status != 'RUNNING':
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we are using 'RUNNING' in two different places, perhaps we should define a constant for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -277,6 +277,13 @@ def connect_and_check():
return
if remaining_reconnects == 0:
return
# Before we try to reconnect, check to see if the VM is still running.
status, metadata_items = utils.describe_instance(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename metadata_items to unused_metadata_items to make it clear that we don't need that part of the return value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jimmc jimmc merged commit ad11cd7 into master May 17, 2017
@jimmc jimmc deleted the jimmc/1111-connect-shutdown branch May 17, 2017 19:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop trying to reconnect if an instance switches state
2 participants