From 43b4a01f8a97d90c65723f9c1290effead277a29 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sun, 4 Jul 2021 21:51:55 +0200 Subject: [PATCH] Make logging reflect reality + do more debugging See https://git.autonomic.zone/coop-cloud/abra/issues/193. --- abra | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/abra b/abra index bded3d2..c2811af 100755 --- a/abra +++ b/abra @@ -800,25 +800,29 @@ ensure_stack_deployed() { idx=0 IFS=' ' read -r -a SERVICES <<< "$(docker stack services "${STACK_NAME}" --format "{{.ID}}" | tr '\n' ' ')" + debug "Considering the following service IDs: ${SERVICES} for ${STACK_NAME} deployment" while [ ! $(( ${#HEALTHY[@]} + ${#MISSING[@]} )) -eq ${#SERVICES[@]} ]; do for service in $(docker ps -f "name=$STACK_NAME" -q); do + debug "Polling $service for deployment status" + healthcheck=$(docker inspect --format "{{ json .State }}" "$service" | jq "try(.Health.Status // \"missing\")") name=$(docker inspect --format '{{ index .Config.Labels "com.docker.swarm.service.name" }}' "$service") if [[ ${MISSING[*]} =~ ${name} ]] || [[ ${HEALTHY[*]} =~ ${name} ]]; then + debug "$name already marked as missing healthcheck / healthy status" continue fi if [[ "$healthcheck" == "\"missing\"" ]] && [[ ! "${MISSING[*]}" =~ $name ]]; then MISSING+=("$name") - info "$name has no healthcheck configured, cannot guarantee this service comes up successfully..." + debug "No healthcheck configured for $name" continue fi if [[ "$healthcheck" == "\"healthy\"" ]] && [[ ! "${HEALTHY[*]}" =~ $name ]]; then HEALTHY+=("$name") - info "$name is healthy!" + debug "Marking $name with healthy status" continue fi @@ -837,9 +841,8 @@ ensure_stack_deployed() { fi sleep 1 - info "Deploying: $(( ${#HEALTHY[@]} + ${#MISSING[@]} ))/${#SERVICES[@]} (timeout: $idx/$TIMEOUT)" + debug "Deploying: $(( ${#HEALTHY[@]} + ${#MISSING[@]} ))/${#SERVICES[@]} (timeout: $idx/$TIMEOUT)" done - success "All services up! Deployment succeeded!" } ensure_domain_deployed() {