Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 25 additions & 22 deletions lib/utapi/utilities.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -123,7 +123,7 @@ function _listMetrics(host,
* @return {undefined}
*/
function listMetrics(metricType) {
commander
program
.version('0.0.1')
.option('-a, --access-key <accessKey>', 'Access key id')
.option('-k, --secret-key <secretKey>', 'Secret access key');
Expand All @@ -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 <buckets>', 'Name of bucket(s) with ' +
'a comma separator if more than one');
} else {
commander
program
.option('-m, --metric <metric>', 'Metric type')
.option('--buckets <buckets>', 'Name of bucket(s) with a comma ' +
'separator if more than one')
Expand All @@ -146,7 +146,7 @@ function listMetrics(metricType) {
'more than one')
.option('--service <service>', 'Name of service');
}
commander
program
.option('-s, --start <start>', 'Start of time range')
.option('-r, --recent', 'List metrics including the previous and ' +
'current 15 minute interval')
Expand All @@ -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') {
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading