diff --git a/Dockerfile b/Dockerfile index 1773939a43..858ab5ad1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,10 +38,11 @@ ENV no_proxy=localhost,127.0.0.1 EXPOSE 8000 EXPOSE 8002 -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ jq \ tini \ + python3-redis \ && rm -rf /var/lib/apt/lists/* WORKDIR /usr/src/app diff --git a/lib/utapi/utilities.js b/lib/utapi/utilities.js index 69626decab..32ea8432ac 100644 --- a/lib/utapi/utilities.js +++ b/lib/utapi/utilities.js @@ -1,6 +1,6 @@ const http = require('http'); const https = require('https'); -const commander = require('commander'); +const { program } = require('commander'); const { auth } = require('arsenal'); const { UtapiClient, utapiVersion } = require('utapi'); const logger = require('../utilities/logger'); @@ -123,7 +123,7 @@ function _listMetrics(host, * @return {undefined} */ function listMetrics(metricType) { - commander + program .version('0.0.1') .option('-a, --access-key ', 'Access key id') .option('-k, --secret-key ', 'Secret access key'); @@ -132,11 +132,11 @@ function listMetrics(metricType) { // bin/list_bucket_metrics.js when prior method of listing bucket metrics is // no longer supported. if (metricType === 'buckets') { - commander + program .option('-b, --buckets ', 'Name of bucket(s) with ' + 'a comma separator if more than one'); } else { - commander + program .option('-m, --metric ', 'Metric type') .option('--buckets ', 'Name of bucket(s) with a comma ' + 'separator if more than one') @@ -146,7 +146,7 @@ function listMetrics(metricType) { 'more than one') .option('--service ', 'Name of service'); } - commander + program .option('-s, --start ', 'Start of time range') .option('-r, --recent', 'List metrics including the previous and ' + 'current 15 minute interval') @@ -157,41 +157,39 @@ function listMetrics(metricType) { .option('-v, --verbose') .parse(process.argv); - const { host, port, accessKey, secretKey, start, end, verbose, recent, - ssl } = - commander; + + const providedOptions = program.opts(); + const { host, port, accessKey, secretKey, start, end, verbose, recent, ssl, metric: metricLvl } = providedOptions; const requiredOptions = { host, port, accessKey, secretKey }; // If not old style bucket metrics, we require usage of the metric option if (metricType !== 'buckets') { - requiredOptions.metric = commander.metric; const validMetrics = ['buckets', 'accounts', 'users', 'service']; - if (validMetrics.indexOf(commander.metric) < 0) { - logger.error('metric must be \'buckets\', \'accounts\', ' + - '\'users\', or \'service\''); - commander.outputHelp(); + if (validMetrics.indexOf(metricLvl) < 0) { + logger.error("metric must be one of 'buckets', 'accounts', 'users', or 'service'"); + program.outputHelp(); process.exit(1); return; } } // If old style bucket metrics, `metricType` will be 'buckets'. Otherwise, - // `commander.metric` should be defined. - const metric = metricType === 'buckets' ? 'buckets' : commander.metric; - requiredOptions[metric] = commander[metric]; + // `metricLvl` should be defined. + const metric = metricType === 'buckets' ? 'buckets' : metricLvl; + requiredOptions[metric] = providedOptions[metric]; // If not recent listing, the start option must be provided if (!recent) { - requiredOptions.start = commander.start; + requiredOptions.start = providedOptions.start; } Object.keys(requiredOptions).forEach(option => { if (!requiredOptions[option]) { logger.error(`missing required option: ${option}`); - commander.outputHelp(); + program.outputHelp(); process.exit(1); } }); - // The string `commander[metric]` is a comma-separated list of resources + // The string `providedOptions[metric]` is a comma-separated list of resources // given by the user. - const resources = commander[metric].split(','); + const resources = providedOptions[metric].split(','); // Validate passed accounts to remove any canonicalIDs if (metric === 'accounts') { @@ -208,7 +206,7 @@ function listMetrics(metricType) { const numStart = Number.parseInt(start, 10); if (!numStart) { logger.error('start must be a number'); - commander.outputHelp(); + program.outputHelp(); process.exit(1); return; } @@ -217,7 +215,7 @@ function listMetrics(metricType) { const numEnd = Number.parseInt(end, 10); if (!numEnd) { logger.error('end must be a number'); - commander.outputHelp(); + program.outputHelp(); process.exit(1); return; } @@ -331,6 +329,11 @@ function pushMetric(action, log, metricObj) { oldByteLength, numberOfObjects, }; + + if (removedDeleteMarkers) { + utapiObj.numberOfObjects = numberOfObjects + removedDeleteMarkers; + } + // If `authInfo` is included by the API, get the account's canonical ID for // account-level metrics and the shortId for user-level metrics. Otherwise // check if the canonical ID is already provided for account-level metrics. diff --git a/package.json b/package.json index 2fae5d1c48..8f277636d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zenko/cloudserver", - "version": "9.0.32", + "version": "9.0.32-1", "description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol", "main": "index.js", "engines": { @@ -43,7 +43,7 @@ "request": "^2.88.2", "scubaclient": "git+https://github.com/scality/scubaclient.git#fb7375a9298bda7df0e9f9ed81d7fc5b363590a9", "sql-where-parser": "^2.2.1", - "utapi": "github:scality/utapi#8.2.3", + "utapi": "github:scality/utapi#8.2.4", "utf-8-validate": "^6.0.5", "utf8": "^3.0.0", "uuid": "^11.0.3", diff --git a/yarn.lock b/yarn.lock index fa723b6f34..65ec817b9a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6947,9 +6947,9 @@ url@0.10.3: punycode "1.3.2" querystring "0.2.0" -"utapi@github:scality/utapi#8.2.3": +"utapi@github:scality/utapi#8.2.4": version "8.2.4" - resolved "https://codeload.github.com/scality/utapi/tar.gz/f4366f8a40b3b009cdf016129f79bb13e2655ed2" + resolved "https://codeload.github.com/scality/utapi/tar.gz/0268bc1f00423648a456a633d27972e8c8d70c93" dependencies: "@hapi/joi" "^17.1.1" "@senx/warp10" "^2.0.3"