Skip to content

Commit

Permalink
Detect if a service update fails
Browse files Browse the repository at this point in the history
`docker service update` will exit with `1` and write something like
`service update paused: update paused due to failure or early termination of task ...`
to stderr if the updated service fails to start or remains unhealthy.

With this change this event appears in the logs explicitly.
  • Loading branch information
andrasmaroy committed Jan 4, 2022
1 parent bdf6930 commit a449627
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ update_services() {
else
logger "Trying to update service $name with image $image" "true"

docker service update "$name" $detach_option $registry_auth $no_resolve_image_flag --image="$image" > /dev/null
if ! docker service update "$name" $detach_option $registry_auth $no_resolve_image_flag --image="$image" > /dev/null; then
logger "Service $name update failed!"
fi

previousImage=$(docker service inspect "$name" -f '{{.PreviousSpec.TaskTemplate.ContainerSpec.Image}}')
currentImage=$(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')
Expand Down

0 comments on commit a449627

Please sign in to comment.