From 4d8943baa7cf123c83bf5df55577b0eae8db0b39 Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez Date: Wed, 23 Jun 2021 23:47:11 +0000 Subject: [PATCH] [Identity] node-fetch takes above 2 seconds to send the request on some environments --- .../src/credentials/managedIdentityCredential/imdsMsi.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts b/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts index f27c43d12f73..a26566ed3ed0 100644 --- a/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts +++ b/sdk/identity/identity/src/credentials/managedIdentityCredential/imdsMsi.ts @@ -90,7 +90,11 @@ export const imdsMsi: MSI = { // not having a "Metadata" header should cause an error to be // returned quickly from the endpoint, proving its availability. const webResource = identityClient.createWebResource(request); - webResource.timeout = updatedOptions?.requestOptions?.timeout || 500; + + // In Kubernetes pods, node-fetch (used by core-http) takes longer than 2 seconds to begin sending the network request, + // So smaller timeouts will cause this credential to be immediately aborted. + // This won't be a problem once we move Identity to core-rest-pipeline. + webResource.timeout = updatedOptions?.requestOptions?.timeout || 3000; try { logger.info(`Pinging IMDS endpoint`);