Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NC | Online Upgrade | Health CLI update config directory and upgrade checks #8532

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update health doc for newly added properties.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add error type for config and upgrad status?

};
}

/**
* 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do we return the "an object with upgrade details" I don't see it?

* @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