-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update compute metadata hanging get example to use "wait_for_change". #332
Conversation
…ge". We need to include "wait_for_change" in order to perform a hanging get. In addition, we should deal with possible errors (like too many hanging gets). Finally, this change allows for any of the maintenance event supported by the metadata server.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
headers=METADATA_HEADERS) | ||
|
||
# During maintenance the service can return a 503, so these should | ||
# be retried. | ||
if r.status_code == 503: | ||
time.sleep(1) | ||
continue | ||
elif r.status_code != requests.codes.ok: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only status the docs mention that we should explicitly check for is 503. Any other error is better surfaced through the standard exception infrastructure rather than just sleeping and trying again.
Why not remove this and just use r.raise_for_status()
?
…ge". We need to include "wait_for_change" in order to perform a hanging get. In addition, we should deal with possible errors (like too many hanging gets). Finally, this change allows for any of the maintenance event supported by the metadata server.
|
||
last_etag = r.headers['etag'] | ||
# [END hanging_get] | ||
|
||
if r.text == 'MIGRATE_ON_HOST_MAINTENANCE': | ||
in_maintenance = True | ||
if r.text != 'NONE': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you've added an else, please switch the logic here.
@Galabar001 please register your github username internally to tell CLAbot about it and reply "I signed it" to get it to check again. |
…ge". We need to include "wait_for_change" in order to perform a hanging get. In addition, we should deal with possible errors (like too many hanging gets). Finally, this change allows for any of the maintenance event supported by the metadata server.
* chore(deps): update all dependencies * revert update for google-auth * add pin for google-cloud-storage for py < 3.7 Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* chore(deps): update all dependencies * remove pin for python 3.6 Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* chore(deps): update all dependencies * remove pin for python 3.6 Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* chore(deps): update all dependencies * revert Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* chore(deps): update all dependencies * revert Co-authored-by: Anthonios Partheniou <partheniou@google.com>
* chore: update copyright year to 2022 PiperOrigin-RevId: 431037888 Source-Link: googleapis/googleapis@b3397f5 Source-Link: https://github.com/googleapis/googleapis-gen/commit/510b54e1cdefd53173984df16645081308fe897e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTEwYjU0ZTFjZGVmZDUzMTczOTg0ZGYxNjY0NTA4MTMwOGZlODk3ZSJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
We need to include "wait_for_change" in order to perform a hanging get. In
addition, we should deal with possible errors (like too many hanging gets).
Finally, this change allows for any of the maintenance event supported by
the metadata server.