Skip to content

Commit 7931c7d

Browse files
committed
NC | Online Upgrade events
Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com>
1 parent cf83c72 commit 7931c7d

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

src/manage_nsfs/manage_nsfs_cli_errors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ const NSFS_CLI_ERROR_EVENT_MAP = {
520520
BucketSetForbiddenBucketOwnerNotExists: NoobaaEvent.UNAUTHORIZED, // GAP - add event
521521
BucketSetForbiddenBucketOwnerIsIAMAccount: NoobaaEvent.UNAUTHORIZED, // // GAP - add event
522522
LoggingExportFailed: NoobaaEvent.LOGGING_FAILED,
523+
UpgradeFailed: NoobaaEvent.CONFIG_DIR_UPGRADE_FAILED
523524
};
524525

525526
exports.ManageCLIError = ManageCLIError;

src/manage_nsfs/manage_nsfs_cli_responses.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ const NSFS_CLI_SUCCESS_EVENT_MAP = {
155155
BucketDeleted: NoobaaEvent.BUCKET_DELETE,
156156
WhiteListIPUpdated: NoobaaEvent.WHITELIST_UPDATED,
157157
LoggingExported: NoobaaEvent.LOGGING_EXPORTED,
158+
UpgradeStarted: NoobaaEvent.CONFIG_DIR_UPGRADE_STARTED,
159+
UpgradeSuccessful: NoobaaEvent.CONFIG_DIR_UPGRADE_SUCCESSFUL
158160
};
159161

160162
exports.ManageCLIResponse = ManageCLIResponse;

src/manage_nsfs/manage_nsfs_events_utils.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,41 @@ NoobaaEvent.LOGGING_FAILED = Object.freeze({
347347
state: 'DEGRADED',
348348
});
349349

350+
/////////////////////////////////////
351+
// CONFIG DIRECTORY UPGRADE EVENTS //
352+
/////////////////////////////////////
353+
354+
NoobaaEvent.CONFIG_DIR_UPGRADE_STARTED = Object.freeze({
355+
event_code: 'config_dir_upgrade_started',
356+
entity_type: 'NODE',
357+
event_type: 'INFO',
358+
message: 'Config directory upgrade started.',
359+
description: 'Config directory upgrade started.',
360+
scope: 'NODE',
361+
severity: 'INFO',
362+
state: 'HEALTHY',
363+
});
364+
365+
NoobaaEvent.CONFIG_DIR_UPGRADE_SUCCESSFUL = Object.freeze({
366+
event_code: 'config_dir_upgrade_successful',
367+
entity_type: 'NODE',
368+
event_type: 'INFO',
369+
message: 'Config directory upgrade finished successfully.',
370+
description: 'Config directory upgrade finished successfully.',
371+
scope: 'NODE',
372+
severity: 'INFO',
373+
state: 'HEALTHY',
374+
});
375+
376+
NoobaaEvent.CONFIG_DIR_UPGRADE_FAILED = Object.freeze({
377+
event_code: 'config_dir_upgrade_failed',
378+
entity_type: 'NODE',
379+
event_type: 'ERROR',
380+
message: 'Config directory upgrade failed.',
381+
description: 'Config directory upgrade failed due to an error',
382+
scope: 'NODE',
383+
severity: 'ERROR',
384+
state: 'DEGRADED',
385+
});
386+
350387
exports.NoobaaEvent = NoobaaEvent;

src/manage_nsfs/upgrade.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const { UPGRADE_ACTIONS } = require('./manage_nsfs_constants');
88
const { NCUpgradeManager } = require('../upgrade/nc_upgrade_manager');
99
const { ManageCLIResponse } = require('../manage_nsfs/manage_nsfs_cli_responses');
1010
const { throw_cli_error, write_stdout_response } = require('./manage_nsfs_cli_utils');
11+
const { NoobaaEvent } = require('./manage_nsfs_events_utils');
1112

1213
/**
1314
* manage_upgrade_operations handles cli upgrade operations
@@ -45,16 +46,18 @@ async function start_config_dir_upgrade(user_input, config_fs) {
4546
const expected_hosts = user_input.expected_hosts && user_input.expected_hosts.split(',').filter(host => !_.isEmpty(host));
4647
const custom_upgrade_scripts_dir = user_input.custom_upgrade_scripts_dir;
4748

49+
new NoobaaEvent(NoobaaEvent.CONFIG_DIR_UPGRADE_STARTED).create_event(undefined, { expected_version, expected_hosts }, undefined);
50+
4851
if (!expected_version) throw new Error('expected_version flag is required');
4952
if (!expected_hosts) throw new Error('expected_hosts flag is required');
5053

5154
const nc_upgrade_manager = new NCUpgradeManager(config_fs, { custom_upgrade_scripts_dir });
5255
const upgrade_res = await nc_upgrade_manager.upgrade_config_dir(expected_version, expected_hosts, { skip_verification });
5356
if (!upgrade_res) throw new Error('Upgrade config directory failed', { cause: upgrade_res });
54-
write_stdout_response(ManageCLIResponse.UpgradeSuccessful, upgrade_res);
57+
write_stdout_response(ManageCLIResponse.UpgradeSuccessful, upgrade_res, { expected_version, expected_hosts });
5558
} catch (err) {
56-
dbg.error('could not upgrade config directory successfully - err', err);
57-
throw_cli_error({ ...ManageCLIError.UpgradeFailed, cause: err });
59+
dbg.error('could not upgrade config directory successfully - error', err);
60+
throw_cli_error({ ...ManageCLIError.UpgradeFailed, cause: err }, undefined, { error: err.stack || err });
5861
}
5962
}
6063

0 commit comments

Comments
 (0)