census-instrumentation/opencensus-node

FetchError: request to http://169.254.169.254/computeMetadata/v1/instance failed, reason: connect EHOSTDOWN 169.254.169.254:80 - Local

sanket0731 opened this issue · 7 comments

Please answer these questions before submitting a bug report.

What version of OpenCensus are you using?

"0.0.18"

What version of Node are you using?

v10.16.3

I am using opencensus-stackdriver-exportor to write traces to stackdriver backend with following configuration:

`const tracing = require('@opencensus/nodejs'); //ver: "0.0.18"
const {StackdriverTraceExporter} = require('@opencensus/exporter-stackdriver'); //ver: "0.0.18"
const exporter = new StackdriverTraceExporter({projectId: projectId, credentials: credentials });
const propagation = require('@opencensus/propagation-stackdriver'); //ver: "0.0.18"

tracing.start(
{
exporter: exporter,
samplingRate: 0.1,
logLevel: 1,
propagation: propagation.v1,
});`

Also, currently I am running application of local machine but I am getting same error on a AWS instance

What did you do?

If possible, provide a recipe for reproducing the error.
When I initialise the StackdriverTraceExporter it makes a call to get default resources:

and which calls detectResource() of resource-util package which is making the following call using gcp-metadata package which is failing as I am not able to connect to the ip.

Whenever I am trying to run my application I am getting following error:
{ FetchError: request to http://169.254.169.254/computeMetadata/v1/instance failed, reason: connect EHOSTDOWN 169.254.169.254:80 - Local (172.22.2.22:53339) at ClientRequest.<anonymous> (/Users/sanket/sharechat-services/block-service/node_modules/node-fetch/lib/index.js:1455:11) at ClientRequest.emit (events.js:198:13) at ClientRequest.EventEmitter.emit (domain.js:448:20) at Socket.socketErrorListener (_http_client.js:392:9) at Socket.emit (events.js:198:13) at Socket.EventEmitter.emit (domain.js:448:20) at emitErrorNT (internal/streams/destroy.js:91:8) at emitErrorAndCloseNT (internal/streams/destroy.js:59:3) at process._tickCallback (internal/process/next_tick.js:63:19) at Function.Module.runMain (internal/modules/cjs/loader.js:834:11) message: 'request to http://169.254.169.254/computeMetadata/v1/instance failed, reason: connect EHOSTDOWN 169.254.169.254:80 - Local (172.22.2.22:53339)', type: 'system', errno: 'EHOSTDOWN', code: 'EHOSTDOWN', config: { url: 'http://169.254.169.254/computeMetadata/v1/instance', headers: { 'Metadata-Flavor': 'Google' }, retryConfig: { noResponseRetries: 0, currentRetryAttempt: 0, retry: 3, retryDelay: 100, httpMethodsToRetry: [Array], statusCodesToRetry: [Array] }, responseType: 'text', timeout: 3000, params: [Object: null prototype] {}, paramsSerializer: [Function: paramsSerializer], validateStatus: [Function: validateStatus], method: 'GET' } }

What did you expect to see?

I am expecting for the server to start without any error.

But if I change line https://github.com/googleapis/gcp-metadata/blob/871a2cb4f28c65bf7f25d03ae1476fc3b371e647/src/index.ts#L12 in node_module
from 'http://169.254.169.254' -> 'http://metadata.internal.google' it works just

In "@opencensus/resource-util@0.0.18" package we are using gcp-metadata@2.0.4.
Is there a work around to disable this check or can we upgrade to working version of gcp-metadata ?

Thanks for reporting this issue! I am looking into it, mean time I sent PR to update the gcp-metadata to latest.

I have upgraded the gcp-metadata to v3 and ran against your shared example, looks to be working well (without any error), Please review #709 when you get a chance.

I have to modify few tests as v3 introduced some breaking change. Basically, isAvailable function now tries both DNS(http://metadata.google.internal.) and IP(http://169.254.169.254).

Thanks for looking into it. #709 looks good, also roughly when can we expect the release ?

I am planning to cut a release within 2-3 days, would like to include fix for #706. Let me know if you want me to release earlier than this.

That will work for me, thanks

Closed via #709

Published in 0.0.19, let us know if you encounter any issues!