diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 38d5201e..e2be4f40 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -107,7 +107,7 @@ jobs: warpscript.maxops: '10000000' ENABLE_SENSISION: 't' options: >- - --health-cmd "curl localhost:4802/api/v0/check" + --health-cmd "curl 127.0.0.1:4802/api/v0/check" --health-interval 10s --health-timeout 5s --health-retries 10 @@ -188,7 +188,7 @@ jobs: - 8082:8082 - 9718:9718 options: >- - --health-cmd "curl localhost:4802/api/v0/check" + --health-cmd "curl 127.0.0.1:4802/api/v0/check" --health-interval 10s --health-timeout 5s --health-retries 10 @@ -201,7 +201,7 @@ jobs: - 8700:8700 - 8800:8800 options: >- - --health-cmd "curl http://localhost:8500/_/healthcheck" + --health-cmd "curl http://127.0.0.1:8500/_/healthcheck" --health-interval 10s --health-timeout 5s --health-retries 10 @@ -309,7 +309,7 @@ jobs: - 8082:8082 - 9718:9718 options: >- - --health-cmd "curl localhost:4802/api/v0/check" + --health-cmd "curl 127.0.0.1:4802/api/v0/check" --health-interval 10s --health-timeout 5s --health-retries 10 @@ -322,7 +322,7 @@ jobs: - 8700:8700 - 8800:8800 options: >- - --health-cmd "curl http://localhost:8500/_/healthcheck" + --health-cmd "curl http://127.0.0.1:8500/_/healthcheck" --health-interval 10s --health-timeout 5s --health-retries 10 diff --git a/README.md b/README.md index d4181c22..0da643ec 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,11 @@ const { UtapiClient } = require('utapi'); const config = { redis: { - host: 'localhost', + host: '127.0.0.1', port: 6379 }, localCache: { - host: 'localhost', + host: '127.0.0.1', port: 6379 } } @@ -276,7 +276,7 @@ deployment would be ``` node bin/list_metrics --metric buckets --buckets demo --start 1476231300000 ---end 1476233099999 -a myAccessKey -k mySecretKey -h localhost -p 8100 --ssl +--end 1476233099999 -a myAccessKey -k mySecretKey -h 127.0.0.1 -p 8100 --ssl ``` Both start and end times are time expressed as UNIX epoch timestamps **expressed diff --git a/bin/ensureServiceUser b/bin/ensureServiceUser index 210a6ea7..d3737e30 100755 --- a/bin/ensureServiceUser +++ b/bin/ensureServiceUser @@ -258,7 +258,7 @@ program.version(version); ].forEach(cmd => { program .command(cmd.name) - .option('--iam-endpoint ', 'IAM endpoint', 'http://localhost:8600') + .option('--iam-endpoint ', 'IAM endpoint', 'http://127.0.0.1:8600') .option('--log-level ', 'log level', 'info') .option('--log-dump-level ', 'log level that triggers a dump of the debug buffer', 'error') .action(wrapAction.bind(null, cmd.actionFunc)); diff --git a/images/warp10/s6/services.d/sensision-exporter/run b/images/warp10/s6/services.d/sensision-exporter/run index 63babf75..585eb4a7 100644 --- a/images/warp10/s6/services.d/sensision-exporter/run +++ b/images/warp10/s6/services.d/sensision-exporter/run @@ -1,6 +1,6 @@ #!/usr/bin/with-contenv sh -EXPORTER_CMD="warp10_sensision_exporter --warp10.url=http://localhost:${SENSISION_PORT}/metrics" +EXPORTER_CMD="warp10_sensision_exporter --warp10.url=http://127.0.0.1:${SENSISION_PORT}/metrics" if [ -f "/usr/local/bin/warp10_sensision_exporter" -a -n "$ENABLE_SENSISION" ]; then echo "Starting Sensision exporter with $EXPORTER_CMD ..." diff --git a/libV2/client/index.js b/libV2/client/index.js index 41400c38..c1b631ba 100644 --- a/libV2/client/index.js +++ b/libV2/client/index.js @@ -72,7 +72,7 @@ class Uploader extends Transform { class UtapiClient { constructor(config) { - this._host = (config && config.host) || 'localhost'; + this._host = (config && config.host) || '127.0.0.1'; this._port = (config && config.port) || '8100'; this._tls = (config && config.tls) || {}; this._transport = (config && config.tls) ? 'https' : 'http'; diff --git a/libV2/config/defaults.json b/libV2/config/defaults.json index 74f38ddb..8a47438b 100644 --- a/libV2/config/defaults.json +++ b/libV2/config/defaults.json @@ -38,7 +38,7 @@ "repairSchedule": "0 */5 * * * *", "reindexSchedule": "0 0 0 * * Sun", "diskUsageSchedule": "0 */15 * * * *", - "bucketd": [ "localhost:9000" ], + "bucketd": [ "127.0.0.1:9000" ], "reindex": { "enabled": true, "schedule": "0 0 0 * * 6" @@ -57,7 +57,7 @@ }, "metrics" : { "enabled": false, - "host": "localhost", + "host": "127.0.0.1", "ingestPort": 10902, "checkpointPort": 10903, "snapshotPort": 10904, diff --git a/libV2/models/RequestContext.js b/libV2/models/RequestContext.js index be89df75..3951fd51 100644 --- a/libV2/models/RequestContext.js +++ b/libV2/models/RequestContext.js @@ -29,7 +29,7 @@ const RequestContextModel = buildModel('RequestContext', contextSchema); class RequestContext extends RequestContextModel { constructor(request) { - const host = request.headers.host || 'localhost'; + const host = request.headers.host || '127.0.0.1'; const protocol = RequestContext._determineProtocol(request); const encrypted = protocol === 'https'; const url = `${protocol}://${host}${request.url}`; diff --git a/libV2/tasks/BaseTask.js b/libV2/tasks/BaseTask.js index de37f036..36d8e913 100644 --- a/libV2/tasks/BaseTask.js +++ b/libV2/tasks/BaseTask.js @@ -25,7 +25,7 @@ class BaseTask extends Process { this._defaultSchedule = Now; this._defaultLag = 0; this._enableMetrics = options.enableMetrics || false; - this._metricsHost = options.metricsHost || 'localhost'; + this._metricsHost = options.metricsHost || '127.0.0.1'; this._metricsPort = options.metricsPort || 9001; this._metricsHandlers = null; this._probeServer = null; diff --git a/libV2/tasks/ManualAdjust.js b/libV2/tasks/ManualAdjust.js index f3efd906..a9ed0add 100644 --- a/libV2/tasks/ManualAdjust.js +++ b/libV2/tasks/ManualAdjust.js @@ -16,7 +16,7 @@ class ManualAdjust extends BaseTask { // Don't include default flags await super._setup(false); this._program - .option('-h, --host ', 'Utapi server host', 'localhost') + .option('-h, --host ', 'Utapi server host', '127.0.0.1') .option('-p, --port ', 'Utapi server port', '8100', parseInt) .option('-b, --bucket ', 'target these buckets', collectArgs, []) .option('-a, --account ', 'target these accounts', collectArgs, []) diff --git a/libV2/warp10.js b/libV2/warp10.js index 343bbfa0..a2a48f6b 100644 --- a/libV2/warp10.js +++ b/libV2/warp10.js @@ -17,7 +17,7 @@ class Warp10Client { const proto = (config && config.tls) ? 'https' : 'http'; this._requestTimeout = (config && config.requestTimeout) || 30000; this._connectTimeout = (config && config.connectTimeout) || 30000; - const host = (config && config.host) || 'localhost'; + const host = (config && config.host) || '127.0.0.1'; const port = (config && config.port) || 4802; this._client = new Warp10().endpoint(`${proto}://${host}:${port}`, this._requestTimeout, this._connectTimeout); } diff --git a/tests/functional/server/testInvalidRequests.js b/tests/functional/server/testInvalidRequests.js index 47a40c35..4287ebed 100644 --- a/tests/functional/server/testInvalidRequests.js +++ b/tests/functional/server/testInvalidRequests.js @@ -18,7 +18,7 @@ describe('Invalid requests', () => { { describe: 'should forbid a GET request ', header: { - host: 'localhost', + host: '127.0.0.1', port: 8100, method: 'GET', service: 's3', @@ -30,7 +30,7 @@ describe('Invalid requests', () => { { describe: 'should forbid a GET request ', header: { - host: 'localhost', + host: '127.0.0.1', port: 8100, method: 'GET', service: 's3', diff --git a/tests/functional/v2/server/testHealthcheck.js b/tests/functional/v2/server/testHealthcheck.js index d0933607..ca486c39 100644 --- a/tests/functional/v2/server/testHealthcheck.js +++ b/tests/functional/v2/server/testHealthcheck.js @@ -4,7 +4,7 @@ const needle = require('needle'); describe('Test healthcheck handler', () => { it('should return true', async () => { - const res = await needle('get', 'http://localhost:8100/_/healthcheck'); + const res = await needle('get', 'http://127.0.0.1:8100/_/healthcheck'); assert.strictEqual(res.statusCode, 200); assert.strictEqual(res.statusMessage, 'OK'); }); diff --git a/tests/functional/v2/server/testIngestMetric.js b/tests/functional/v2/server/testIngestMetric.js index f75bac39..68a47a06 100644 --- a/tests/functional/v2/server/testIngestMetric.js +++ b/tests/functional/v2/server/testIngestMetric.js @@ -6,7 +6,7 @@ const { generateFakeEvents } = require('../../../utils/v2Data'); function utapiRequest(events) { return needle( 'post', - 'http://localhost:8100/v2/ingest', + 'http://127.0.0.1:8100/v2/ingest', events, ); } diff --git a/tests/functional/v2/server/testListMetrics.js b/tests/functional/v2/server/testListMetrics.js index 001d6a2c..432ef13b 100644 --- a/tests/functional/v2/server/testListMetrics.js +++ b/tests/functional/v2/server/testListMetrics.js @@ -41,7 +41,7 @@ async function listMetrics(level, resources, start, end, credentials) { } const headers = { - host: 'localhost', + host: '127.0.0.1', port: 8100, method: 'POST', service: 's3', @@ -49,6 +49,7 @@ async function listMetrics(level, resources, start, end, credentials) { headers: { 'Content-Type': 'application/json', }, + get: true; }; const { accessKey: accessKeyId, secretKey: secretAccessKey } = credentials; @@ -58,10 +59,9 @@ async function listMetrics(level, resources, start, end, credentials) { }; const sig = aws4.sign(headers, _credentials); - return needle( 'post', - `http://localhost:8100/${level}?Action=ListMetrics`, + `http://127.0.0.1:8100/${level}?Action=ListMetrics`, body, { diff --git a/tests/functional/v2/server/testPrometheusMetrics.js b/tests/functional/v2/server/testPrometheusMetrics.js index 2068446a..d3f1bcdc 100644 --- a/tests/functional/v2/server/testPrometheusMetrics.js +++ b/tests/functional/v2/server/testPrometheusMetrics.js @@ -15,9 +15,9 @@ const testMetrics = async pair => { describe('Test Prometheus Metrics', () => { const nameUrlPairs = [ - ['utapi nodejs service exporter', 'http://localhost:8100/_/metrics'], - ['sensision exporter', 'http://localhost:9718/metrics'], - ['redis exporter', 'http://localhost:9121/metrics'], + ['utapi nodejs service exporter', 'http://127.0.0.1:8100/_/metrics'], + ['sensision exporter', 'http://127.0.0.1:9718/metrics'], + ['redis exporter', 'http://127.0.0.1:9121/metrics'], ]; nameUrlPairs.forEach(pair => testMetrics(pair)); }); diff --git a/tests/functional/v2/task/testBaseTask.js b/tests/functional/v2/task/testBaseTask.js index 4236c71f..802ff0b6 100644 --- a/tests/functional/v2/task/testBaseTask.js +++ b/tests/functional/v2/task/testBaseTask.js @@ -48,7 +48,7 @@ describe('Test BaseTask metrics', () => { it('should start a metrics server on the provided port', async () => { const res = await needle( 'get', - `http://localhost:${METRICS_SERVER_PORT}${DEFAULT_METRICS_ROUTE}`, + `http://127.0.0.1:${METRICS_SERVER_PORT}${DEFAULT_METRICS_ROUTE}`, ); const lines = res.body.split('\n'); const first = lines[0]; diff --git a/tests/unit/testUtapiClient.js b/tests/unit/testUtapiClient.js index 7cdfed16..bd102867 100644 --- a/tests/unit/testUtapiClient.js +++ b/tests/unit/testUtapiClient.js @@ -15,7 +15,7 @@ const metricTypes = { accountId: 'foo-account', userId: 'foo-user', }; -const redisLocal = { host: 'localhost', port: 6379 }; +const redisLocal = { host: '127.0.0.1', port: 6379 }; const config = { redis: redisLocal, localCache: redisLocal, diff --git a/tests/utils/utils.js b/tests/utils/utils.js index cc5b2434..02242839 100644 --- a/tests/utils/utils.js +++ b/tests/utils/utils.js @@ -100,7 +100,7 @@ function buildMockResponse({ start, end, val }) { function makeUtapiClientRequest({ timeRange, resource }, cb) { const header = { - host: 'localhost', + host: '127.0.0.1', port: 8100, method: 'POST', service: 's3', @@ -125,7 +125,7 @@ function makeUtapiClientRequest({ timeRange, resource }, cb) { function makeUtapiGenericClientRequest(reqHeader, reqBody, cb) { const header = Object.assign({ - host: 'localhost', + host: '127.0.0.1', port: 8100, service: 's3', }, reqHeader); @@ -173,7 +173,7 @@ function _buildRequestBody(resource) { function listMetrics(resource, cb) { const requestBody = _buildRequestBody(resource); const header = { - host: 'localhost', + host: '127.0.0.1', port: 8100, method: 'POST', service: 's3', diff --git a/tests/utils/vaultclient.js b/tests/utils/vaultclient.js index 8a24f1b6..cfba875a 100644 --- a/tests/utils/vaultclient.js +++ b/tests/utils/vaultclient.js @@ -109,7 +109,7 @@ class VaultClient { } static getIAMClient(credentials) { - const endpoint = process.env.VAULT_ENDPOINT || 'http://localhost:8600'; + const endpoint = process.env.VAULT_ENDPOINT || 'http://127.0.0.1:8600'; const info = { endpoint, sslEnabled: false, diff --git a/tests/utils/wait_for_local_port.bash b/tests/utils/wait_for_local_port.bash index 0ec47be5..3fa73651 100644 --- a/tests/utils/wait_for_local_port.bash +++ b/tests/utils/wait_for_local_port.bash @@ -7,7 +7,7 @@ wait_for_local_port() { local ret=1 echo "waiting for UtapiServer:$port" while [[ "$ret" -eq "1" && "$count" -lt "$timeout" ]] ; do - nc -z -w 1 localhost $port + nc -z -w 1 127.0.0.1 $port ret=$? if [ ! "$ret" -eq "0" ]; then echo -n . diff --git a/warpscript/utapi/getMetrics.mc2 b/warpscript/utapi/getMetrics.mc2 index 1f156332..871f1f69 100644 --- a/warpscript/utapi/getMetrics.mc2 +++ b/warpscript/utapi/getMetrics.mc2 @@ -1,4 +1,4 @@ -// @endpoint http://localhost:4802/api/v0/exec +// @endpoint http://127.0.0.1:4802/api/v0/exec { 'name' 'utapi/getMetrics' diff --git a/warpscript/utapi/getMetricsAt.mc2 b/warpscript/utapi/getMetricsAt.mc2 index a3b4a418..2b93e74a 100644 --- a/warpscript/utapi/getMetricsAt.mc2 +++ b/warpscript/utapi/getMetricsAt.mc2 @@ -1,4 +1,4 @@ -// @endpoint http://localhost:4802/api/v0/exec +// @endpoint http://127.0.0.1:4802/api/v0/exec { 'name' 'utapi/getMetricsAt' 'desc' diff --git a/warpscript/util/sumRecord.mc2 b/warpscript/util/sumRecord.mc2 index 9d72916e..7e90a95b 100644 --- a/warpscript/util/sumRecord.mc2 +++ b/warpscript/util/sumRecord.mc2 @@ -1,4 +1,4 @@ -// @endpoint http://localhost:4802/api/v0/exec +// @endpoint http://127.0.0.1:4802/api/v0/exec {