This commit is contained in:
parent
a019417fd2
commit
f151018f10
57
abra
57
abra
@ -787,49 +787,36 @@ output_version_summary() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Note(decentral1se): inspired by https://github.com/vitalets/docker-stack-wait-deploy
|
|
||||||
ensure_stack_deployed() {
|
ensure_stack_deployed() {
|
||||||
STACK_NAME=$1
|
local stack=$1
|
||||||
|
local deployed=false
|
||||||
|
|
||||||
warning "Polling deploy state to check for success"
|
warning "Waiting for new services to come up..."
|
||||||
|
|
||||||
|
local -a UNHEALTHY # mapping
|
||||||
|
|
||||||
|
services=$(docker stack services "${STACK_NAME}" --format "{{.ID}}")
|
||||||
|
echo "$services"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
all_services_done=1
|
for service in $(docker ps -f "name=$STACK_NAME" -q); do
|
||||||
has_errors=0
|
local logs=$(docker inspect --format "{{ if (eq .State.Health.Status \"unhealthy\") }} {{json .State.Health.Log}} {{end}}" "$service")
|
||||||
|
local name=$(docker inspect --format '{{ index .Config.Labels "com.docker.swarm.service.name"}}' $service)
|
||||||
|
|
||||||
service_ids=$(docker stack services -q "$STACK_NAME")
|
debug "Processing $service ($name)..."
|
||||||
|
|
||||||
for service_id in $service_ids; do
|
if [[ ${UNHEALTHY_SEEN[*]} =~ ${service} ]]; then
|
||||||
# see: https://github.com/moby/moby/issues/28012
|
debug "Already reported $name as failing, skipping..."
|
||||||
service_state=$(docker service inspect --format "{{if .UpdateStatus}}{{.UpdateStatus.State}}{{else}}created{{end}}" "$service_id")
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
debug "$service_id has state: $service_state"
|
if [[ -n "$logs" ]]; then
|
||||||
|
local exitcode="$(echo $logs | $JQ '.[-1] | .ExitCode')"
|
||||||
case "$service_state" in
|
warning "Healthcheck for new instance of $name is failing (exit code $exitcode)"
|
||||||
created|completed)
|
warning "$(echo $logs | $JQ -r '.[-1] | .Output')"
|
||||||
;;
|
fi
|
||||||
paused|rollback_completed)
|
|
||||||
has_errors=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
all_services_done=0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$all_services_done" == "1" ]; then
|
|
||||||
if [ "$has_errors" == "1" ]; then
|
|
||||||
warning "Deployment appears to have failed"
|
|
||||||
warning "Run \"abra app ${STACK_NAME} logs \" to see app logs"
|
|
||||||
warning "Run \"abra app ${STACK_NAME} ps \" to see app status"
|
|
||||||
break
|
|
||||||
else
|
|
||||||
warning "Deployment appears to have suceeded"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -865,7 +852,7 @@ load_instance() {
|
|||||||
APP="$abra__app_"
|
APP="$abra__app_"
|
||||||
|
|
||||||
# load all files matching "$APP.env" into ENV_FILES array
|
# load all files matching "$APP.env" into ENV_FILES array
|
||||||
mapfile -t ENV_FILES < <(find -L "$ABRA_DIR" -name "$APP.env")
|
mapfile -t ENV_FILES < <(find -L "$ABRA_DIR/servers/" -name "$APP.env")
|
||||||
# FIXME 3wc: requires bash 4, use for loop instead
|
# FIXME 3wc: requires bash 4, use for loop instead
|
||||||
|
|
||||||
case "${#ENV_FILES[@]}" in
|
case "${#ENV_FILES[@]}" in
|
||||||
|
5
makefile
5
makefile
@ -43,3 +43,8 @@ build:
|
|||||||
|
|
||||||
push: build
|
push: build
|
||||||
@docker push decentral1se/abra
|
@docker push decentral1se/abra
|
||||||
|
|
||||||
|
symlink:
|
||||||
|
@mkdir -p ~/.abra/servers/ && \
|
||||||
|
ln -srf tests/default ~/.abra/servers && \
|
||||||
|
ln -srf tests/apps/* ~/.abra/apps
|
||||||
|
31
tests/apps/works/compose.yml
Normal file
31
tests/apps/works/compose.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
version: "3.8"
|
||||||
|
services:
|
||||||
|
r1:
|
||||||
|
image: redis:alpine
|
||||||
|
deploy:
|
||||||
|
update_config:
|
||||||
|
failure_action: rollback
|
||||||
|
order: start-first
|
||||||
|
rollback_config:
|
||||||
|
order: start-first
|
||||||
|
restart_policy:
|
||||||
|
max_attempts: 3
|
||||||
|
healthcheck:
|
||||||
|
test: redis-cli ping
|
||||||
|
r2:
|
||||||
|
image: redis:alpine
|
||||||
|
deploy:
|
||||||
|
update_config:
|
||||||
|
failure_action: rollback
|
||||||
|
order: start-first
|
||||||
|
rollback_config:
|
||||||
|
order: start-first
|
||||||
|
restart_policy:
|
||||||
|
max_attempts: 3
|
||||||
|
healthcheck:
|
||||||
|
test: foobar
|
||||||
|
# test: redis-cli ping
|
||||||
|
start_period: 5s
|
||||||
|
interval: 2s
|
||||||
|
timeout: 3s
|
1
tests/default/works.env
Normal file
1
tests/default/works.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
TYPE=works
|
Reference in New Issue
Block a user