Repository navigation
fix(traefik): harden the Traefik update and rollback - #5881
Merged
Merged
Conversation
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR about?
Follow-up to #5756, which added the in-place Traefik update with automatic rollback. This builds on that flow to cover a few more real-world cases, so an update either finishes with everything carried over or leaves the old Traefik exactly as it was.
The first case came up on a production host, where the update stopped at its first step with:
When a running container on a swarm overlay network is renamed, Docker re-registers its DNS names in swarm's shared network table, and on some hosts that table is out of sync with the daemon. A stopped container is renamed without touching the network at all (see the
!ctr.State.Runningearly return in moby'sdaemon/rename.go), so the update now stops Traefik first. Traefik was being stopped right after the rename anyway, so downtime is unchanged. Nothing was lost on that host: Docker reverts the name and Traefik kept running.Changes
Update
dokploy-traefik-previous. If the rename fails, start it again before reporting the error.dokploy-network), with aliases, before starting it. If joining fails, the update rolls back.Restore after an interrupted update
writeTraefikSetup, whose restore step ran outside the queue. In the few seconds where only the backup exists, it could rename the backup back, and the update's rollback would then remove it.dokploy-traefikleft increatedstate (the update was interrupted before starting it) is removed and the backup brought back. A Traefik that ran and was stopped is left alone.Reconnecting isolated compose networks
docker network connectnow ends with|| true. Traefik can already be on those networks, and a compose network that no longer exists made the command exit non-zero, so a successful update showed "Last update failed".What an update keeps
Env vars, custom ports,
traefik.yml, dynamic config andacme.json(host files, mounted in),dokploy-network, isolated compose networks, and now any other network Traefik was on. As with Reload or a port/env change, extra volume mounts, labels, static IPs and host-IP-specific port bindings come from Dokploy's settings, not the old container.Tests
standalone-traefik-recreate.test.tsrejects renaming a running container with the same error, so every recreate test checks the order.Conflict: dokploy-traefik is already in usewithout the queue); a never-started container cleared; a stopped Traefik left alone; a running backup stopped before it's renamed back.pnpm typecheckand Biome pass.pnpm testpasses apart fromapplication.real.test.ts, which needs nixpacks installed locally.Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
Follow-up to #5756


Confidence Score: 5/5
The PR appears safe to merge; no new actionable issue was established.Summary
Hardens Traefik replacement and recovery after an interrupted update.
The earlier restart finding is addressed: recovery now uses
dokploy-traefik-nextto detect an update interrupted before the old container was renamed.Reviews (2) · Last reviewed commit: "fix(traefik): recover an update interrup..." · Reviewed by Greptile