Skip to content

Commit

Permalink
NC | Online Upgrade | Health CLI update config directory and upgrade …
Browse files Browse the repository at this point in the history
…checks

Signed-off-by: Romy <[email protected]>
  • Loading branch information
romayalon committed Nov 14, 2024
1 parent aaeeb19 commit 45af106
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 105 deletions.
38 changes: 37 additions & 1 deletion src/manage_nsfs/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { TYPES } = require('./manage_nsfs_constants');
const { get_boolean_or_string_value, throw_cli_error, write_stdout_response, get_bucket_owner_account_by_id } = require('./manage_nsfs_cli_utils');
const { ManageCLIResponse } = require('./manage_nsfs_cli_responses');
const ManageCLIError = require('./manage_nsfs_cli_errors').ManageCLIError;
const { CONFIG_DIR_LOCKED } = require('../upgrade/nc_upgrade_manager');


const HOSTNAME = 'localhost';
Expand Down Expand Up @@ -125,6 +126,7 @@ class NSFSHealth {
const error_code = await this.get_error_code(service_status, pid, response_code);
if (this.all_bucket_details) bucket_details = await this.get_bucket_status();
if (this.all_account_details) account_details = await this.get_account_status();
const system_data = await this.config_fs.get_system_config_file({ silent_if_missing: true });
const health = {
service_name: NOOBAA_SERVICE,
status: service_health,
Expand All @@ -136,6 +138,8 @@ class NSFSHealth {
endpoint_state,
error_type: health_errors_tyes.TEMPORARY,
},
config_directory_status: this._get_config_dir_status(system_data),
upgrade_status: this._get_upgrade_status(system_data),
accounts_status: {
invalid_accounts: account_details === undefined ? undefined : account_details.invalid_storages,
valid_accounts: account_details === undefined ? undefined : account_details.valid_storages,
Expand All @@ -145,7 +149,7 @@ class NSFSHealth {
invalid_buckets: bucket_details === undefined ? undefined : bucket_details.invalid_storages,
valid_buckets: bucket_details === undefined ? undefined : bucket_details.valid_storages,
error_type: health_errors_tyes.PERSISTENT,
}
},
}
};
if (!this.all_account_details) delete health.checks.accounts_status;
Expand Down Expand Up @@ -421,6 +425,38 @@ class NSFSHealth {
err_obj
};
}

/**
* _get_config_dir_status returns the config directory phase, version and equivalent package_version
* @param {Object} system_data
* @returns {Object}
*/
_get_config_dir_status(system_data) {
if (!system_data) return { error: 'system data is missing' };
const config_dir_data = system_data.config_directory;
if (!config_dir_data) return { error: 'config directory data is missing' };
return {
phase: config_dir_data.phase,
config_dir_version: config_dir_data.config_dir_version,
upgrade_package_version: config_dir_data.upgrade_package_version,
in_progress_upgrade: config_dir_data.in_progress_upgrade
};
}

/**
* get_upgrade_status returns the status of an ongoing upgrade, if valid it returns an object with upgrade details
* if upgrade is not ongoing but config dir is locked in one of the hosts, the error details will return
* @param {Object} system_data
* @returns {Object}
*/
_get_upgrade_status(system_data) {
if (!system_data) return { error: 'system data is missing' };
const config_dir_data = system_data.config_directory;
if (!config_dir_data) return { error: 'config directory data is missing' };
if (!config_dir_data.in_progress_upgrade && config_dir_data.phase === CONFIG_DIR_LOCKED) {
return config_dir_data.upgrade_history.last_failure;
}
}
}

async function get_health_status(argv, config_fs) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit_tests/nc_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require('./test_chunk_fs');
require('./test_namespace_fs_mpu');
require('./test_nb_native_fs');
require('./test_nc_nsfs_cli');
require('./test_nc_nsfs_health');
require('./test_nc_health');
require('./test_nsfs_access');
require('./test_bucketspace');
require('./test_bucketspace_fs');
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit_tests/sudo_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ require('./test_bucketspace_versioning');
require('./test_bucketspace_fs');
require('./test_nsfs_versioning');
require('./test_nc_nsfs_cli');
require('./test_nc_nsfs_health');
require('./test_nc_health');

Loading

0 comments on commit 45af106

Please sign in to comment.