MT#15803 HA: support shared storage check in 'ngcpcfg check'

This allows us to abort in 'ngcpcfg status' whenever there are
outstanding changes to pull/push from the shared storage. Using
the --no-action-failure option allows the user to continue anyway.

Change-Id: I4062d5bb627bb553b98705bb122575651b035849
changes/69/2969/6
Michael Prokop 11 years ago
parent d7d48e15a1
commit 7adf2b23e2

@ -181,6 +181,17 @@ Run actions (see next section) in verbose mode, useful for debugging.
Display usage information and exit.
**--no-action-failure**::
The _check_ and _apply_ actions check for any possibly outstanding push/pull
actions on the shared storage. If any outstanding actions are identified then
the script aborts to avoid running into tricky configuration merge situations.
If this option is enabled then ngcpcfg instead doesn't abort on outstanding
push/pull actions. This option should be used with care and only if you know
what you're doing.
Note: This option is available in the High Availability setup only.
**--no-validate**::
Ignore schema validation results for YAML files (syntax check is still performed).
@ -201,6 +212,8 @@ the most commonly executed commands.
**check** [<config_files_or_directories>|<pattern>]::
Check syntax of YAML files and validate schema before performing any further actions.
In the High Availability setup possibly outstanding push/pull actions are
checked as well.
**build** [--modified-only] [<files_or_directories>|<pattern>]::

@ -154,6 +154,7 @@ case ${1:-} in
--debug) export DEBUG=1 ; shift ; $0 $* ;;
--no-db-sync) export NO_DB_SYNC=1 ; shift ; $0 $* ;;
--no-validate) export NO_VALIDATE=1; shift ; $0 $* ;;
--no-action-failure) export NO_ACTION_FAILURE=1; shift ; $0 $* ;;
-h|--help|help) usage ; exit 0;;
-v|--version|version) version ; exit 0;;
*) usage 1; exit 1;;

@ -94,6 +94,35 @@ check_configs_conflicts() {
fi
}
check_shared_storage() {
# ensure there are no outstanding pull/push actions,
# unless --no-action-failure is used (ignore then)
if ! type -p execute_check_shared_storage &>/dev/null ; then
log_debug "execute_check_shared_storage not available"
return 0
fi
log_debug "execute_check_shared_storage function"
if [ "${NO_ACTION_FAILURE:-}" = "1" ] ; then
if execute_check_shared_storage ; then
log_debug "No outstanding actions identified (NO_ACTION_FAILURE=1)."
else
log_info "Ignoring outstanding push/pull actions as --no-action-failure option is enabled."
fi
return 0
fi
execute_check_shared_storage && RC=0 || RC=$?
if [ "$RC" = "0" ] ; then
log_debug "No outstanding actions identified (NO_ACTION_FAILURE unset)."
else
log_info "Outstanding push/pull actions have been identified (see ACTION_NEEDED), exiting."
log_info "TIP: '--no-action-failure' forces execution within 'apply' anyway (use with care!)."
return $RC
fi
}
if [ "$*" = "" ] ; then
config_files="${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ${CONSTANTS_CONFIG:-}"
else
@ -106,6 +135,8 @@ if "${VALIDATE_SCHEMA:-false}" ; then
fi
check_configs_conflicts
check_shared_storage || exit $?
exit 0
## END OF FILE #################################################################

Loading…
Cancel
Save