wowu / docker-rollout

🚀 Zero Downtime Deployment for Docker Compose
https://github.com/Wowu/docker-rollout
MIT License
2.37k stars 66 forks source link

Scaling not working when old instance have status `Exited` #20

Open fikrapdso opened 9 months ago

fikrapdso commented 9 months ago

When the old instance has status Exited, rollout command not start the new instance. it trying to start the old instance instead and break because the old instance has error in it.

I expected it to ignore the error in old instance and start the new instance. Then re route the when the new instance is ready.

==> Service 'django' is not running. Starting the service.
Container xxx-django-13  Created
Container xxx-django-13  Starting
Container xxx-django-13  Started

after that line, no scaling happens for that service

wowu commented 9 months ago

@fikrapdso, if I understand the problem correctly, you have a container that crashes after starting, so you are not able to deploy new image version using docker rollout. Is that correct?

I think in this case docker rollout should recreate the container if it's not running instead of starting it, so it behaves the same as docker compose up.

Can you let me know if removing --no-recreate flag in line 89 solves the problem?

diff --git a/docker-rollout b/docker-rollout
index 5da1986..6040ab9 100755
--- a/docker-rollout
+++ b/docker-rollout
@@ -86,7 +86,7 @@ main() {
   # shellcheck disable=SC2086 # COMPOSE_FILES and ENV_FILES must be unquoted to allow multiple files
   if [[ "$($COMPOSE_COMMAND $COMPOSE_FILES $ENV_FILES ps --quiet "$SERVICE")" == "" ]]; then
     echo "==> Service '$SERVICE' is not running. Starting the service."
-    $COMPOSE_COMMAND $COMPOSE_FILES $ENV_FILES up --detach --no-recreate "$SERVICE"
+    $COMPOSE_COMMAND $COMPOSE_FILES $ENV_FILES up --detach "$SERVICE"
     exit 0
   fi