Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
Signed-off-by: Romy <35330373+romayalon@users.noreply.github.com>
  • Loading branch information
romayalon committed Dec 8, 2024
1 parent edd1766 commit 1742c11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
7 changes: 3 additions & 4 deletions docs/NooBaaNonContainerized/Health.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ The output of the Health CLI is a JSON object containing the following propertie
- Description: For TEMPORARY error types, NooBaa attempts multiple retries before updating the status to reflect an error. Currently, TEMPORARY error types are only observed in checks for invalid NooBaa endpoints.

- `config_directory`
- Type: { "phase": "CONFIG_DIR_UNLOCKED", "config_dir_version": "1.0.0",
"upgrade_package_version": "5.18.0",
"upgrade_status": { "message": "there is no in-progress upgrade" }
}
- Type: Object {"phase": "CONFIG_DIR_UNLOCKED" | "CONFIG_DIR_LOCKED","config_dir_version": String,
"upgrade_package_version": String, "upgrade_status": Object, "error": Object }.
- Description: An object that consists config directory information, config directory upgrade information etc.
- Example: { "phase": "CONFIG_DIR_UNLOCKED", "config_dir_version": "1.0.0", "upgrade_package_version": "5.18.0", "upgrade_status": { "message": "there is no in-progress upgrade" }}

## Example
```sh
Expand Down
20 changes: 9 additions & 11 deletions src/manage_nsfs/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class NSFSHealth {

let bucket_details;
let account_details;
const endpoint_response_code = endpoint_state ? endpoint_state.response?.response_code : 'NOT_RUNNING';
const endpoint_response_code = (endpoint_state && endpoint_state.response?.response_code) || 'UNKNOWN_ERROR';
const health_check_params = { service_status, pid, endpoint_response_code, config_directory_status };
const service_health = this._calc_health_status(health_check_params);
const error_code = this.get_error_code(health_check_params);
Expand All @@ -155,7 +155,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 @@ -259,7 +259,7 @@ class NSFSHealth {
const fork_count_response = await this.make_endpoint_health_request(url_path);
if (!fork_count_response) {
return {
response_code: fork_response_code.NOT_RUNNING,
response: fork_response_code.NOT_RUNNING,
total_fork_count: total_fork_count,
running_workers: worker_ids,
};
Expand Down Expand Up @@ -443,15 +443,16 @@ class NSFSHealth {
}

/**
* _get_config_dir_status returns the config directory phase, version and equivalent package_version
* _get_config_dir_status returns the config directory phase, version,
* matching package_version, upgrade_status and error if occured.
* @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' };
const config_dir_upgrade_status = this._get_config_dir_upgrade_status(system_data);
if (!config_dir_data) return { error: 'config directory data is missing, must upgrade config directory' };
const config_dir_upgrade_status = this._get_config_dir_upgrade_status(config_dir_data);
return {
phase: config_dir_data.phase,
config_dir_version: config_dir_data.config_dir_version,
Expand All @@ -466,13 +467,10 @@ class NSFSHealth {
* 1. the status of an ongoing upgrade, if valid it returns an object with upgrade details
* 2. if upgrade is not ongoing but config dir is locked, the error details of the upgrade's last_failure will return
* 3. if upgrade is not ongoing and config dir is unlocked, a corresponding message will return
* @param {Object} system_data
* @param {Object} config_dir_data
* @returns {Object}
*/
_get_config_dir_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, must upgrade config directory' };
_get_config_dir_upgrade_status(config_dir_data) {
if (config_dir_data.in_progress_upgrade) return { in_progress_upgrade: config_dir_data.in_progress_upgrade };
if (config_dir_data.phase === CONFIG_DIR_LOCKED) {
return { error: 'last_upgrade_failed', last_failure: config_dir_data.upgrade_history.last_failure };
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit_tests/test_nc_health.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ mocha.describe('nsfs nc health', function() {
upgrade_history: {
successful_upgrades: [],
},
in_progress_upgrade: { from_version: 'x', to_version: 'y'}
in_progress_upgrade: { from_version: '5.17.8', to_version: '5.18.0'}
};
await Health.config_fs.create_system_config_file(JSON.stringify(valid_system_json));
const health_status = await Health.nc_nsfs_health();
Expand Down

0 comments on commit 1742c11

Please sign in to comment.