Skip to content

Commit 22825f9

Browse files
committed
NC | Lifecycle | Add status, events, timeout
Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com>
1 parent 26968f8 commit 22825f9

File tree

9 files changed

+727
-196
lines changed

9 files changed

+727
-196
lines changed

config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,8 @@ config.NC_DISABLE_SCHEMA_CHECK = false;
10111011

10121012
////////// NC LIFECYLE //////////
10131013

1014-
config.LIFECYCLE_LOGS_DIR = '/var/log/noobaa/lifecycle';
1014+
config.NC_LIFECYCLE_LOGS_DIR = '/var/log/noobaa/lifecycle';
1015+
config.NC_LIFECYCLE_TIMEOUT_MS = 6 * 60 * 60 * 1000;
10151016

10161017
// NC_LIFECYCLE_RUN_TIME must be of the format hh:mm which specifies
10171018
// when NooBaa should allow running nc lifecycle process

src/cmd/manage_nsfs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,8 @@ async function list_connections() {
883883
async function lifecycle_management(args) {
884884
const disable_service_validation = get_boolean_or_string_value(args.disable_service_validation);
885885
const disable_runtime_validation = get_boolean_or_string_value(args.disable_runtime_validation);
886-
await noobaa_cli_lifecycle.run_lifecycle_under_lock(config_fs, disable_service_validation, disable_runtime_validation);
886+
const short = get_boolean_or_string_value(args.short);
887+
await noobaa_cli_lifecycle.run_lifecycle_under_lock(config_fs, { disable_service_validation, disable_runtime_validation, short });
887888
}
888889

889890
exports.main = main;

src/manage_nsfs/manage_nsfs_cli_errors.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,18 @@ ManageCLIError.NooBaaServiceIsNotActive = Object.freeze({
534534
http_code: 400,
535535
});
536536

537+
ManageCLIError.LifecycleFailed = Object.freeze({
538+
code: 'LifecycleFailed',
539+
message: 'Lifecycle worker run failed.',
540+
http_code: 400,
541+
});
542+
543+
ManageCLIError.LifecycleWorkerReachedTimeout = Object.freeze({
544+
code: 'LifecycleWorkerReachedTimeout',
545+
message: `Lifecycle worker reached timeout - configured timeout is ${config.NC_LIFECYCLE_TIMEOUT_MS} ms`,
546+
http_code: 400,
547+
});
548+
537549
///////////////////////////////
538550
// ERRORS MAPPING //
539551
///////////////////////////////
@@ -556,7 +568,8 @@ ManageCLIError.RPC_ERROR_TO_MANAGE = Object.freeze({
556568
NO_SUCH_USER: ManageCLIError.InvalidAccountDistinguishedName,
557569
INVALID_MASTER_KEY: ManageCLIError.InvalidMasterKey,
558570
INVALID_BUCKET_NAME: ManageCLIError.InvalidBucketName,
559-
CONFIG_DIR_VERSION_MISMATCH: ManageCLIError.ConfigDirUpdateBlocked
571+
CONFIG_DIR_VERSION_MISMATCH: ManageCLIError.ConfigDirUpdateBlocked,
572+
LIFECYCLE_WORKER_TIMEOUT: ManageCLIError.LifecycleWorkerReachedTimeout
560573
});
561574

562575
const NSFS_CLI_ERROR_EVENT_MAP = {
@@ -569,7 +582,9 @@ const NSFS_CLI_ERROR_EVENT_MAP = {
569582
BucketSetForbiddenBucketOwnerNotExists: NoobaaEvent.UNAUTHORIZED, // GAP - add event
570583
BucketSetForbiddenBucketOwnerIsIAMAccount: NoobaaEvent.UNAUTHORIZED, // // GAP - add event
571584
LoggingExportFailed: NoobaaEvent.LOGGING_FAILED,
572-
UpgradeFailed: NoobaaEvent.CONFIG_DIR_UPGRADE_FAILED
585+
UpgradeFailed: NoobaaEvent.CONFIG_DIR_UPGRADE_FAILED,
586+
LifecycleFailed: NoobaaEvent.LIFECYCLE_FAILED,
587+
LifecycleWorkerReachedTimeout: NoobaaEvent.LIFECYCLE_TIMEOUT
573588
};
574589

575590
exports.ManageCLIError = ManageCLIError;

src/manage_nsfs/manage_nsfs_cli_responses.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* Copyright (C) 2016 NooBaa */
22
'use strict';
33

4+
const config = require('../../config');
5+
46
const NoobaaEvent = require('../manage_nsfs/manage_nsfs_events_utils').NoobaaEvent;
57

68
// TODO : define list & status types
@@ -197,6 +199,24 @@ ManageCLIResponse.ConnectionList = Object.freeze({
197199
list: {}
198200
});
199201

202+
///////////////////////////////
203+
// LIFECYCLE RESPONSES //
204+
///////////////////////////////
205+
206+
ManageCLIResponse.LifecycleSuccessful = Object.freeze({
207+
code: 'LifecycleSuccessful',
208+
message: 'Lifecycle worker run finished successfully',
209+
status: {}
210+
});
211+
212+
ManageCLIResponse.LifecycleWorkerNotRunning = Object.freeze({
213+
code: 'LifecycleWorkerNotRunning',
214+
message: `Lifecycle worker must run at ${config.NC_LIFECYCLE_RUN_TIME} ` +
215+
`with delay of ${config.NC_LIFECYCLE_RUN_DELAY_LIMIT_MINS} minutes ` +
216+
`in timezone ${config.NC_LIFECYCLE_TZ}`,
217+
status: {}
218+
});
219+
200220
///////////////////////////////
201221
// RESPONSES-EVENT MAPPING //
202222
///////////////////////////////
@@ -209,7 +229,8 @@ const NSFS_CLI_SUCCESS_EVENT_MAP = {
209229
WhiteListIPUpdated: NoobaaEvent.WHITELIST_UPDATED,
210230
LoggingExported: NoobaaEvent.LOGGING_EXPORTED,
211231
UpgradeStarted: NoobaaEvent.CONFIG_DIR_UPGRADE_STARTED,
212-
UpgradeSuccessful: NoobaaEvent.CONFIG_DIR_UPGRADE_SUCCESSFUL
232+
UpgradeSuccessful: NoobaaEvent.CONFIG_DIR_UPGRADE_SUCCESSFUL,
233+
LifecycleSuccessful: NoobaaEvent.LIFECYCLE_SUCCESSFUL
213234
};
214235

215236
exports.ManageCLIResponse = ManageCLIResponse;

src/manage_nsfs/manage_nsfs_constants.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const VALID_OPTIONS_CONNECTION = {
9696
'status': new Set(['name', 'decrypt', ...CLI_MUTUAL_OPTIONS]),
9797
};
9898

99-
const VALID_OPTIONS_LIFECYCLE = new Set(['disable_service_validation', 'disable_runtime_validation', ...CLI_MUTUAL_OPTIONS]);
99+
const VALID_OPTIONS_LIFECYCLE = new Set(['disable_service_validation', 'disable_runtime_validation', 'short', ...CLI_MUTUAL_OPTIONS]);
100100

101101
const VALID_OPTIONS_WHITELIST = new Set(['ips', ...CLI_MUTUAL_OPTIONS]);
102102

@@ -158,6 +158,7 @@ const OPTION_TYPE = {
158158
// lifecycle options
159159
disable_service_validation: 'boolean',
160160
disable_runtime_validation: 'boolean',
161+
short: 'boolean',
161162
//connection
162163
notification_protocol: 'string',
163164
agent_request_object: 'string',
@@ -170,7 +171,7 @@ const OPTION_TYPE = {
170171

171172
const BOOLEAN_STRING_VALUES = ['true', 'false'];
172173
const BOOLEAN_STRING_OPTIONS = new Set(['allow_bucket_creation', 'regenerate', 'wide', 'show_secrets', 'force',
173-
'force_md5_etag', 'iam_operate_on_root_account', 'all_account_details', 'all_bucket_details', 'anonymous', 'disable_service_validation', 'disable_runtime_validation']);
174+
'force_md5_etag', 'iam_operate_on_root_account', 'all_account_details', 'all_bucket_details', 'anonymous', 'disable_service_validation', 'disable_runtime_validation', 'short']);
174175

175176
// CLI UNSET VALUES
176177
const CLI_EMPTY_STRING = '';

src/manage_nsfs/manage_nsfs_events_utils.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,52 @@ NoobaaEvent.NOTIFICATION_FAILED = Object.freeze({
410410
state: 'HEALTHY',
411411
});
412412

413+
////////////////////////////
414+
// LIFECYCLE EVENTS //
415+
////////////////////////////
416+
417+
NoobaaEvent.LIFECYCLE_STARTED = Object.freeze({
418+
event_code: 'noobaa_lifecycle_worker_started',
419+
entity_type: 'NODE',
420+
event_type: 'INFO',
421+
message: 'NooBaa Lifecycle worker run started.',
422+
description: 'NooBaa Lifecycle worker run started.',
423+
scope: 'NODE',
424+
severity: 'INFO',
425+
state: 'HEALTHY',
426+
});
427+
428+
NoobaaEvent.LIFECYCLE_SUCCESSFUL = Object.freeze({
429+
event_code: 'noobaa_lifecycle_worker_finished_successfully',
430+
entity_type: 'NODE',
431+
event_type: 'INFO',
432+
message: 'NooBaa Lifecycle worker run finished successfully.',
433+
description: 'NooBaa Lifecycle worker finished successfully.',
434+
scope: 'NODE',
435+
severity: 'INFO',
436+
state: 'HEALTHY',
437+
});
438+
439+
NoobaaEvent.LIFECYCLE_FAILED = Object.freeze({
440+
event_code: 'noobaa_lifecycle_worker_failed',
441+
message: 'NooBaa Failed to run lifecycle worker.',
442+
description: 'NooBaa Lifecycle worker run failed due to an error.',
443+
entity_type: 'NODE',
444+
event_type: 'ERROR',
445+
scope: 'NODE',
446+
severity: 'ERROR',
447+
state: 'DEGRADED',
448+
});
449+
450+
NoobaaEvent.LIFECYCLE_TIMEOUT = Object.freeze({
451+
event_code: 'noobaa_lifecycle_worker_timeout',
452+
message: 'NooBaa lifecycle worker run timed out.',
453+
description: 'NooBaa Lifecycle worker run timed out.',
454+
entity_type: 'NODE',
455+
event_type: 'ERROR',
456+
scope: 'NODE',
457+
severity: 'ERROR',
458+
state: 'DEGRADED',
459+
});
460+
413461
exports.NoobaaEvent = NoobaaEvent;

0 commit comments

Comments
 (0)