From 176fb6565ed4ff6d21d1db755bea2866bfc98fe3 Mon Sep 17 00:00:00 2001 From: lukken <lukken@astron.nl> Date: Mon, 24 Oct 2022 11:04:18 +0000 Subject: [PATCH] L2SS-988: Prevent waiting on services without health property --- docker-compose/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docker-compose/Makefile b/docker-compose/Makefile index 102569164..9e0949fa7 100644 --- a/docker-compose/Makefile +++ b/docker-compose/Makefile @@ -224,16 +224,20 @@ restart: ## restart a service (usage: make restart <servicename>) attach: ## attach a service to an existing Tango network $(DOCKER_COMPOSE_ARGS) docker-compose $(ATTACH_COMPOSE_FILE_ARGS) up --no-recreate -d $(SERVICE) +time := 0 await: ## Await every container with total max timeout of 300, do not reset timeout - time=0 for i in $(SERVICE); do \ current_service=$$($(DOCKER_COMPOSE_ARGS) docker-compose $(COMPOSE_FILE_ARGS) ps -q $${i}); \ if [ -z "$${current_service}" ]; then \ continue; \ + fi; \ + service_has_health=$$(docker inspect -f '{{.State.Health.Status}}' $${current_service}); \ + if [ -z "$${service_has_health}" ]; then \ + continue; \ fi; \ while [ "$$(docker inspect -f '{{.State.Health.Status}}' $${current_service})" != "healthy" ] ; do \ sleep 1; \ - time=$$(expr $${time} + 1); \ + time=$$(expr $$time + 1); \ if [ $${time} -gt $(TIMEOUT) ]; then \ echo "Timeout reached waiting for $${i} to become healthy"; \ exit 1; \ -- GitLab