Azure / azure-amqp-common-go

Azure AMQP abstractions for Golang contains common types and interfaces for use in Service Bus and Event Hubs.
MIT License
12 stars 25 forks source link

return the error when refresh fails, not the token #49

Closed serbrech closed 3 years ago

serbrech commented 3 years ago

Fix

This fixes the error message returned when refreshing the token fails. it currently returns the token :

failed to refersh token: &{{{ 0 0 0 } 0xcb74e8 {{ <nil> false } { <nil> false } {http <nil> 169.254.169.254 /metadata/identity
/oauth2/token false api-version=2018-02-01&client_id=XXXXX&resource=https%3A%2F%2Fservicebus.azure.net%2F } { 
<nil> false }} XXXXXXXXX https://servicebus.azure.net/ true 300000000000} 0xc0000cf800 0xc00017f740 <nil> [] 5}

changing it to return the actual error provides the right information:

 Error: Received unexpected error:
failed to refresh token: the MSI endpoint is not available. Failed HTTP request to MSI endpoint:
Get "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01": context deadline exceeded

Which in my case was a the IMDS endpoint timing out. This happens very easily when running a set of integration tests concurrently (just a dozen...), each authenticating to the IMDS endpoint. It seems that IMDS handles them very badly.

Environment

jhendrixMSFT commented 3 years ago

/azp run

azure-pipelines[bot] commented 3 years ago
No pipelines are associated with this pull request.
jhendrixMSFT commented 3 years ago

/azp run

azure-pipelines[bot] commented 3 years ago
Azure Pipelines successfully started running 1 pipeline(s).