google-cloud-go
google-cloud-go copied to clipboard
metadata: support cancellation of GCE platform detection
Is your feature request related to a problem? Please describe.
Currently the OnGCE call can block for an indeterminate amount of time, depending on the result of resolving the metadata IP address and/or its DNS record. This cannot be canceled via any mechanism by the caller presently, which prevents the caller from putting a ceiling on the call duration for a more reliable experience.
Describe the solution you'd like
Similar to other context-aware functions in the package, OnGCE should take a context.
Describe alternatives you've considered
There is no other way to prevent this situation currently, unless the caller executes this in an entirely different process.
Additional context
n/a
@diurnalist Thank you for opening this issue and the accompanying PR. We will look at it this week. Much appreciated.