From 7adf2b23e23bd53e54cd48c99ee1755d827e8612 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 16 Oct 2015 16:04:54 +0200 Subject: [PATCH] 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 --- docs/ngcpcfg.txt | 13 +++++++++++++ sbin/ngcpcfg | 1 + scripts/check | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/docs/ngcpcfg.txt b/docs/ngcpcfg.txt index 7641e9a4..eca9a037 100644 --- a/docs/ngcpcfg.txt +++ b/docs/ngcpcfg.txt @@ -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** [|]:: 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] [|]:: diff --git a/sbin/ngcpcfg b/sbin/ngcpcfg index 329ec438..b545a44f 100755 --- a/sbin/ngcpcfg +++ b/sbin/ngcpcfg @@ -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;; diff --git a/scripts/check b/scripts/check index 3573458b..0f7448cd 100755 --- a/scripts/check +++ b/scripts/check @@ -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 #################################################################