Skip to content
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

Closed
wants to merge 5 commits into from

Conversation

Galabar001
Copy link
Contributor

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.

…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.
@googlebot
Copy link

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. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label May 6, 2016
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:
Copy link
Contributor

@theacodes theacodes May 6, 2016

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':
Copy link
Contributor

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.

@theacodes
Copy link
Contributor

@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.
@theacodes theacodes closed this May 6, 2016
msampathkumar pushed a commit that referenced this pull request Nov 14, 2022
* 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>
arbrown pushed a commit that referenced this pull request Nov 14, 2022
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
dandhlee pushed a commit that referenced this pull request Nov 15, 2022
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
arbrown pushed a commit that referenced this pull request Nov 17, 2022
* chore(deps): update all dependencies

* remove pin for python 3.6

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
dandhlee pushed a commit that referenced this pull request Nov 17, 2022
* chore(deps): update all dependencies

* remove pin for python 3.6

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
telpirion pushed a commit that referenced this pull request Dec 2, 2022
* chore(deps): update all dependencies

* revert

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
dandhlee pushed a commit that referenced this pull request Dec 2, 2022
* chore(deps): update all dependencies

* revert

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Sita04 pushed a commit that referenced this pull request Feb 7, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: no This human has *not* signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants