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

Adds more resilient GCE checking #1292

Merged
merged 1 commit into from
Nov 20, 2018
Merged

Adds more resilient GCE checking #1292

merged 1 commit into from
Nov 20, 2018

Conversation

nathenharvey
Copy link
Contributor

Description

Check the system information to determine if this system is running on Google Compute Engine.

See also the Google Cloud Documentation for detecting if you are running in Compute Engine.

Check List

Signed-off-by: Nathen Harvey nathenharvey@google.com

@nathenharvey nathenharvey requested a review from a team November 19, 2018 18:58
@nathenharvey nathenharvey requested a review from a team as a code owner November 19, 2018 18:58
RELEASE_NOTES.md Outdated Show resolved Hide resolved
@tas50
Copy link
Contributor

tas50 commented Nov 20, 2018

@nathenharvey you have a slight chefstyle error. If you auto correct it that should get cleared up

# Identifies gce
#
# === Return
# true:: If gce can be identified
# false:: Otherwise
def looks_like_gce?
hint?("gce") || has_gce_metadata?
hint?("gce") || has_gce_dmi? || has_gce_system_info? || has_gce_metadata?
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably get refactored to be more like what we're doing in AWS

https://github.com/chef/ohai/blob/master/lib/ohai/plugins/ec2.rb#L108

Then you can just kill off has_gce_metadata?

Also this will make it so that we're only attempting to connect to metadata when we really look like gce. That allows us to switch over to the IP vs. name based URL as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactored. This will now only attempt to connect to the metadata server when the system info indicates that this node is on GCE. Would you like to switch to IP based GCE_METADATA_ADDR in the same PR?

Copy link
Contributor

@tas50 tas50 left a comment

Choose a reason for hiding this comment

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

Getting close. Take a look at the comment I left for the ordering of when we try to metadata connect

Check the system information to determine if this system is running on Google Compute Engine.

See also the Google Cloud Documentation for [detecting if you are running in Compute Engine](https://cloud.google.com/compute/docs/instances/managing-instances#dmi).

Signed-off-by: Nathen Harvey <nathenharvey@google.com>

Update release notes

Signed-off-by: Nathen Harvey <nathenharvey@google.com>
@tas50 tas50 merged commit b40f669 into chef:master Nov 20, 2018
@tas50
Copy link
Contributor

tas50 commented Nov 20, 2018

Looks great. Thanks @nathenharvey

@nathenharvey nathenharvey deleted the gce/dmi branch November 20, 2018 17:17
@lock
Copy link

lock bot commented Jan 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2019
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.

None yet

4 participants