-
Notifications
You must be signed in to change notification settings - Fork 80
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
romayalon
wants to merge
1
commit into
noobaa:master
Choose a base branch
from
romayalon:romy-online-upgrade-health
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+186
−105
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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; | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.