Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not kill services if image download fails #34

Merged
merged 1 commit into from
Apr 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions shepherd
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,24 @@ update_services() {
if [[ " $blacklist " != *" $name "* ]]; then
image_with_digest="$(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')"
image=$(echo "$image_with_digest" | cut -d@ -f1)
echo "Trying to update service $name with image $image"
docker service update "$name" $detach_option $registry_auth --image="$image" > /dev/null

previousImage=$(docker service inspect "$name" -f '{{.PreviousSpec.TaskTemplate.ContainerSpec.Image}}')
currentImage=$(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')
if [ "$previousImage" == "$currentImage" ]; then
echo "No updates to service $name!"
if ! DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $image > /dev/null; then
echo "Error updating service $name! Image $image does not exist or it is not available"
else
echo "Service $name was updated!"
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name updated"
body="Service $name was updated from $previousImage to $currentImage"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
echo "Trying to update service $name with image $image"
docker service update "$name" $detach_option $registry_auth --image="$image" > /dev/null

previousImage=$(docker service inspect "$name" -f '{{.PreviousSpec.TaskTemplate.ContainerSpec.Image}}')
currentImage=$(docker service inspect "$name" -f '{{.Spec.TaskTemplate.ContainerSpec.Image}}')
if [ "$previousImage" == "$currentImage" ]; then
echo "No updates to service $name!"
else
echo "Service $name was updated!"
if [[ "$apprise_sidecar_url" != "" ]]; then
title="[Shepherd] Service $name updated"
body="Service $name was updated from $previousImage to $currentImage"
curl -X POST -H "Content-Type: application/json" --data "{\"title\": \"$title\", \"body\": \"$body\"}" "$apprise_sidecar_url"
fi
fi
fi
fi
Expand Down