Skip to content

Commit e1a25ef

Browse files
committed
NC | Lifecycle | Add status, events, timeout
Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com> (cherry picked from commit 22825f9)
1 parent a3d32f5 commit e1a25ef

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
@@ -1000,7 +1000,8 @@ config.NC_DISABLE_SCHEMA_CHECK = false;
10001000

10011001
////////// NC LIFECYLE //////////
10021002

1003-
config.LIFECYCLE_LOGS_DIR = '/var/log/noobaa/lifecycle';
1003+
config.NC_LIFECYCLE_LOGS_DIR = '/var/log/noobaa/lifecycle';
1004+
config.NC_LIFECYCLE_TIMEOUT_MS = 6 * 60 * 60 * 1000;
10041005

10051006
// NC_LIFECYCLE_RUN_TIME must be of the format hh:mm which specifies
10061007
// 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
@@ -805,7 +805,8 @@ async function connection_management(action, user_input) {
805805
async function lifecycle_management(args) {
806806
const disable_service_validation = get_boolean_or_string_value(args.disable_service_validation);
807807
const disable_runtime_validation = get_boolean_or_string_value(args.disable_runtime_validation);
808-
await noobaa_cli_lifecycle.run_lifecycle_under_lock(config_fs, disable_service_validation, disable_runtime_validation);
808+
const short = get_boolean_or_string_value(args.short);
809+
await noobaa_cli_lifecycle.run_lifecycle_under_lock(config_fs, { disable_service_validation, disable_runtime_validation, short });
809810
}
810811

811812
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
@@ -516,6 +516,18 @@ ManageCLIError.NooBaaServiceIsNotActive = Object.freeze({
516516
http_code: 400,
517517
});
518518

519+
ManageCLIError.LifecycleFailed = Object.freeze({
520+
code: 'LifecycleFailed',
521+
message: 'Lifecycle worker run failed.',
522+
http_code: 400,
523+
});
524+
525+
ManageCLIError.LifecycleWorkerReachedTimeout = Object.freeze({
526+
code: 'LifecycleWorkerReachedTimeout',
527+
message: `Lifecycle worker reached timeout - configured timeout is ${config.NC_LIFECYCLE_TIMEOUT_MS} ms`,
528+
http_code: 400,
529+
});
530+
519531
///////////////////////////////
520532
// ERRORS MAPPING //
521533
///////////////////////////////
@@ -538,7 +550,8 @@ ManageCLIError.RPC_ERROR_TO_MANAGE = Object.freeze({
538550
NO_SUCH_USER: ManageCLIError.InvalidAccountDistinguishedName,
539551
INVALID_MASTER_KEY: ManageCLIError.InvalidMasterKey,
540552
INVALID_BUCKET_NAME: ManageCLIError.InvalidBucketName,
541-
CONFIG_DIR_VERSION_MISMATCH: ManageCLIError.ConfigDirUpdateBlocked
553+
CONFIG_DIR_VERSION_MISMATCH: ManageCLIError.ConfigDirUpdateBlocked,
554+
LIFECYCLE_WORKER_TIMEOUT: ManageCLIError.LifecycleWorkerReachedTimeout
542555
});
543556

544557
const NSFS_CLI_ERROR_EVENT_MAP = {
@@ -551,7 +564,9 @@ const NSFS_CLI_ERROR_EVENT_MAP = {
551564
BucketSetForbiddenBucketOwnerNotExists: NoobaaEvent.UNAUTHORIZED, // GAP - add event
552565
BucketSetForbiddenBucketOwnerIsIAMAccount: NoobaaEvent.UNAUTHORIZED, // // GAP - add event
553566
LoggingExportFailed: NoobaaEvent.LOGGING_FAILED,
554-
UpgradeFailed: NoobaaEvent.CONFIG_DIR_UPGRADE_FAILED
567+
UpgradeFailed: NoobaaEvent.CONFIG_DIR_UPGRADE_FAILED,
568+
LifecycleFailed: NoobaaEvent.LIFECYCLE_FAILED,
569+
LifecycleWorkerReachedTimeout: NoobaaEvent.LIFECYCLE_TIMEOUT
555570
};
556571

557572
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
@@ -172,6 +174,24 @@ ManageCLIResponse.ConnectionList = Object.freeze({
172174
list: {}
173175
});
174176

177+
///////////////////////////////
178+
// LIFECYCLE RESPONSES //
179+
///////////////////////////////
180+
181+
ManageCLIResponse.LifecycleSuccessful = Object.freeze({
182+
code: 'LifecycleSuccessful',
183+
message: 'Lifecycle worker run finished successfully',
184+
status: {}
185+
});
186+
187+
ManageCLIResponse.LifecycleWorkerNotRunning = Object.freeze({
188+
code: 'LifecycleWorkerNotRunning',
189+
message: `Lifecycle worker must run at ${config.NC_LIFECYCLE_RUN_TIME} ` +
190+
`with delay of ${config.NC_LIFECYCLE_RUN_DELAY_LIMIT_MINS} minutes ` +
191+
`in timezone ${config.NC_LIFECYCLE_TZ}`,
192+
status: {}
193+
});
194+
175195
///////////////////////////////
176196
// RESPONSES-EVENT MAPPING //
177197
///////////////////////////////
@@ -184,7 +204,8 @@ const NSFS_CLI_SUCCESS_EVENT_MAP = {
184204
WhiteListIPUpdated: NoobaaEvent.WHITELIST_UPDATED,
185205
LoggingExported: NoobaaEvent.LOGGING_EXPORTED,
186206
UpgradeStarted: NoobaaEvent.CONFIG_DIR_UPGRADE_STARTED,
187-
UpgradeSuccessful: NoobaaEvent.CONFIG_DIR_UPGRADE_SUCCESSFUL
207+
UpgradeSuccessful: NoobaaEvent.CONFIG_DIR_UPGRADE_SUCCESSFUL,
208+
LifecycleSuccessful: NoobaaEvent.LIFECYCLE_SUCCESSFUL
188209
};
189210

190211
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

@@ -156,6 +156,7 @@ const OPTION_TYPE = {
156156
// lifecycle options
157157
disable_service_validation: 'boolean',
158158
disable_runtime_validation: 'boolean',
159+
short: 'boolean',
159160
//connection
160161
notification_protocol: 'string',
161162
agent_request_object: 'string',
@@ -168,7 +169,7 @@ const OPTION_TYPE = {
168169

169170
const BOOLEAN_STRING_VALUES = ['true', 'false'];
170171
const BOOLEAN_STRING_OPTIONS = new Set(['allow_bucket_creation', 'regenerate', 'wide', 'show_secrets', 'force',
171-
'force_md5_etag', 'iam_operate_on_root_account', 'all_account_details', 'all_bucket_details', 'anonymous', 'disable_service_validation', 'disable_runtime_validation']);
172+
'force_md5_etag', 'iam_operate_on_root_account', 'all_account_details', 'all_bucket_details', 'anonymous', 'disable_service_validation', 'disable_runtime_validation', 'short']);
172173

173174
//options that can be unset using ''
174175
const LIST_UNSETABLE_OPTIONS = ['fs_backend', 's3_policy', 'force_md5_etag'];

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)