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

credentials/alts: fix panic detecting GCP environment #2996

Merged
merged 1 commit into from
Aug 27, 2019

Conversation

mwhudson
Copy link
Contributor

@mwhudson mwhudson commented Aug 26, 2019

Assume not running on GCP if dmi not present.

fixes #2995

@thelinuxfoundation
Copy link

Thank you for your pull request. Before we can look at your contribution, we need to ensure all contributors are covered by a Contributor License Agreement.

After the following items are addressed, please respond with a new comment here, and the automated system will re-verify.

Regards,
CLA GitHub bot

@mwhudson
Copy link
Contributor Author

FWIW I'm an employee of Canonical and I don't know if we have signed the CLA. I'm also happy for someone else to fix this issue any other way...

@mwhudson
Copy link
Contributor Author

Ah, turns out we have and I have now set up all the links required to let the system know.

Copy link
Contributor

@cesarghali cesarghali left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Just a couple of comments.

@@ -51,22 +52,39 @@ func TestIsRunningOnGCP(t *testing.T) {
}
reverseFunc()
}
reverseFunc := setupError("linux", os.ErrNotExist)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is not the same logic as the rest of the test and it's not really worth it to change the test to include this case in the loop, can you please move it to a separate test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done. I guess one could have changed testReader in the anonymous struct to be an interface{} and done a type switch in setup to have kept everything in the loop but well.

}

func setup(testOS string, testReader io.Reader) func() {
func setupManufacturerReader(testOS string, reader func() (io.Reader, error)) func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, can you please move setupManufacturerReader, setup and setupError to the beginning, before TestIsRunningOnGCP? Thanks!

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.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 26, 2019

CLA Check
The committers are authorized under a signed CLA.

Copy link
Contributor

@cesarghali cesarghali left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes.

@cesarghali cesarghali merged commit d5a36f0 into grpc:master Aug 27, 2019
@dfawley dfawley added this to the 1.24 Release milestone Aug 29, 2019
@dfawley dfawley changed the title credentials/alts: assume not running on GCP if dmi not present credentials/alts: fix panic detecting GCP environment Aug 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

credentials/alts: isRunningOnGCP fatalf's if /sys/class/dmi/id/product_name does not exist
4 participants