From f382765f2904c7202539b801b2fd42ba42b67b63 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 18 Mar 2021 19:45:30 +0100 Subject: [PATCH] Show correct status for missing contexts Closes https://git.autonomic.zone/coop-cloud/abra/issues/99. --- abra | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/abra b/abra index d859e76..82938c9 100755 --- a/abra +++ b/abra @@ -755,12 +755,13 @@ sub_app_list (){ fi local -a DEPLOYED_APPS # array + local -a CHECKED_SERVERS # array warning "Loading status from ${#SERVERS[@]} server(s), patience advised.." for SERVER in "${SERVERS[@]}"; do SERVER="${SERVER##*/}" # basename - mapfile -t SERVER_APPS < <(DOCKER_CONTEXT="$SERVER" docker stack ls --format '{{ .Name }}') + mapfile -t SERVER_APPS < <(DOCKER_CONTEXT="$SERVER" docker stack ls --format '{{ .Name }}' 2>/dev/null) # add $SERVER~ to the start of each DEPLOYED_APPS DEPLOYED_APPS+=("${SERVER_APPS[@]/#/$SERVER~}") done @@ -800,6 +801,12 @@ sub_app_list (){ fi if [ -n "$STATUS" ]; then APP_STATUS=$( printf '%s\n' "${DEPLOYED_APPS[@]}" | grep -qP "^${SERVER}~${APP_STACK_NAME}$" && echo "deployed" || echo "inactive") + if [[ "$APP_STATUS" == "inactive" ]] && [[ ! ${CHECKED_SERVERS[*]} =~ ${SERVER} ]]; then + CHECKED_SERVERS+=("$SERVER") + if ! docker context inspect "$SERVER" > /dev/null 2>&1; then + APP_STATUS="unknown" + fi + fi fi printf " %s\t%s\t%s%s\n" "$DOMAIN" "$TYPE" "$SERVER" "${STATUS:+ }${APP_STATUS}" done | column -s' ' -t