From 203d60e9b57d5c447cc3a021c712c121f0a8c91a Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 13 Dec 2018 19:36:53 +0100 Subject: [PATCH] TT#43700 Fix services handling The previous logic had several issues that need to be addressed, when doing an early exit: - The temporary file was not getting removed. - The services sync-state step was not being executed. This makes the code more future-proof, and fixes the above problems, by moving the sync-state into its own function, removing the early exit, and making the service explicit state changes conditional on the previous early exit conditional. Change-Id: Ie420cbb94ea6d16a83c7ae3f546cd3eb38435dd8 --- scripts/services | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/services b/scripts/services index 1db69744..99e48ca1 100755 --- a/scripts/services +++ b/scripts/services @@ -83,7 +83,9 @@ execute() { log_info "Executing enqueued services actions" ngcp-service queue-run +} +services_sync_state() { log_info "Synchronizing current with expected services state" ngcp-service sync-state } @@ -202,19 +204,21 @@ for dir in ${CONFIG_POOL} ; do generate_list_to_process "${dir}" done -if [[ ! -s "${TMPFILE}" ]]; then - log_debug "No services file(s) reported - nothing to do." - exit 0 -fi +if [[ -s "${TMPFILE}" ]]; then + log_debug "normalize_files function" + normalize_files -log_debug "normalize_files function" -normalize_files + log_debug "sort_service_list function" + sort_service_list -log_debug "sort_service_list function" -sort_service_list + log_debug "execute function" + execute +else + log_debug "No services file(s) reported - no explicit service state changed." +fi -log_debug "execute function" -execute +log_debug "services_sync_state function" +services_sync_state if [[ -n "${DEBUG:-}" ]]; then log_debug "Not removing temporary files"