Skip to content

fix(traefik): allow disabling backend connection reuse for Swarm services - #5702

Open
WilliamAGH wants to merge 7 commits into
Dokploy:canaryfrom
WilliamAGH:fix/5281-traefik-vip-connection-reuse
Open

WilliamAGH wants to merge 7 commits into
Dokploy:canaryfrom
WilliamAGH:fix/5281-traefik-vip-connection-reuse

Conversation

@WilliamAGH

@WilliamAGH WilliamAGH commented Oct 18, 2026 •

Copy link
Copy Markdown

Dokploy routes application domains to their Swarm service VIP (http://<appName>:<port>). A pooled backend connection can remain attached to a task during a rolling update, while a new connection goes through the VIP's current service membership. This adds Reuse backend connections under Advanced → Cluster Settings so application owners can disable idle backend connection reuse for generated routes. The setting defaults to enabled, preserving existing behavior.

When reuse is disabled, Dokploy writes an application-owned serversTransport named <appName>-swarm-vip with maxIdleConnsPerHost: -1. Generated load balancers without an existing transport reference it. Re-enabling reuse removes that owned transport and its references. Settings reconciliation preserves hand-set custom transport references and unrelated routers and services; those custom transports retain their own connection policy.

Saving Cluster Settings reconciles the application's existing primary and preview route files before persisting the application setting, including when the requested value matches the stored value. An application without route entries does not get an empty route file. New or regenerated domain routes also apply the selected policy. Application and preview domain updates now publish their route changes through updateDomainById before persisting domain fields, including enablement and forward-auth flags. Redirect creation awaits middleware publication inside its existing database transaction.

Read, parse and write errors from the configuration helpers propagate to callers. If reconciliation fails before the application database update, its stored setting stays unchanged. Earlier route files may already have been changed, however: these writes use Dokploy's existing local file and remote SFTP helpers directly, with no staged replacement, per-file atomicity guarantee, or transaction spanning route files and the database. After the underlying error is resolved, saving either value again reconciles the readable route files to that policy. A failed Cluster Settings save retains the entered values and displays the server error; unchanged polling preserves edits, while changing resources resets the form.

The transport setting targets Traefik's standard proxy. The implementation does not inspect the running proxy configuration, call the support-dump API, reject FastProxy, or run a destination compatibility preflight for application transfers. Those are not guarantees of this PR.

The migration adds application.swarmVipConnectionReuse as NOT NULL DEFAULT true. Its generated output also includes the webServerSettings.whitelabelingConfig default already declared by the schema; that generated default change is retained.

Regression coverage includes transport rendering/removal, custom transport and unrelated-route preservation, absent route files, actual filesystem write errors, remote read failures, primary/preview reconciliation before persistence, and retrying after preview or database failure. The remote read test runs the generated command against the local shell and filesystem in place of the SSH boundary; it does not establish live SSH or proxy-mode compatibility.

Closes #5281

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues were found.

Summary

Adds an application setting to disable backend connection reuse for generated Swarm routes.

  • Application owners can turn off backend connection reuse for generated Swarm routes.
  • Domain edits publish application and preview routes before saving their fields.
  • Route configuration read and write failures now reach their callers.

Reviews (2) · Last reviewed commit: "fix(traefik): report route configuration..." · Reviewed by Greptile

…ices

Traefik pools idle backend connections by dial address, so a connection
opened to http://<appName>:<port> stays bound to the task it first reached
after Swarm removes that task from the service VIP during a rolling update.

Add an application setting, on by default, that when turned off renders an
application-owned serversTransport with maxIdleConnsPerHost: -1 and points
every generated service for the application at it. Changing the setting
rewrites the existing primary and preview route files.

Fixes Dokploy#5281

Agent-Session: 9844533d-f186-4fe0-9641-6a1c2b9baf44
The application page refetches every 5 seconds, so resetting the form on every new data object discarded edits made during a deployment. Reset only when a field the form shows changes.

Agent-Session: 9844533d-f186-4fe0-9641-6a1c2b9baf44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T00:26:41.936347Z f5665e5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5665e56d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/server/src/utils/traefik/domain.ts
Comment thread packages/server/src/utils/traefik/domain.ts
Comment thread packages/server/src/utils/traefik/domain.ts Outdated
Comment thread packages/server/src/services/application.ts Outdated
Turning off backend connection reuse no longer replaces a serversTransport
the user set on a generated service; only services without one get the
application-owned transport.

Reconciling existing route files now reads and writes strictly, so an SSH
failure rejects instead of returning an empty config. updateApplication
rewrites the route files before saving the setting, so a failed rewrite
leaves the stored value unchanged and saving again retries it.

Agent-Session: fa314523-0de1-4a36-b77d-ebc454f606fb
A save that failed after rewriting some route files left them on the new policy while the stored value kept the old one. Saving the old value again skipped the rewrite because it matched the stored value. The rewrite is idempotent, so run it whenever the setting is sent.

Agent-Session: fa314523-0de1-4a36-b77d-ebc454f606fb
Address Codex and OpenCode review findings before finalizing PR Dokploy#5702.
Reject loaded FastProxy before publishing a negative idle-pool limit,
including destination transfers. Stage local and remote route replacements
before atomic publication, preserving live routes and failure causes.

Keep rejected Cluster Settings values for retry. Apply domain and auth
route checks before persisting their new state, without holding a database
transaction connection during Docker/SSH work. Remove duplicate callers.

Verified with 99 focused tests, both package typechecks, scoped Biome,
real Traefik 3.6.25 standard/FastProxy probes, PostgreSQL 17 rejection and
retry probes, and actual-component browser checks. Local deep adversarial
review findings were repaired before this single final commit.

Agent-Session: ses_ea8c77953ffe2kMVc88YLK31nt
… config helpers

Replace custom route file writing and runtime proxy inspection with
Dokploy's standard Traefik configuration utilities. Consolidate test
suites to verify core serversTransport generation and preview deployment
cascades.

Agent-Session: 4e0ead16-f511-445f-9075-4b7c62c7b37a
Propagate route read and write failures before persisting application
settings. Keep missing remote route files empty without hiding failed
reads, and await redirect middleware publication inside its transaction.

Cover the shared helpers with real filesystem and shell I/O regressions.

Agent-Session: ses_ea5a5b8fdffebkE34w8Vem0N6A
WilliamAGH added a commit to WilliamAGH/website that referenced this pull request Oct 20, 2026
Document the default, custom transport behavior, and save-time route updates
introduced in Dokploy/dokploy#5702. Explain that a failed update can be retried
by saving either value after resolving the error.

Agent-Session: ses_eaa141796ffebTef9qdyk8BK92
@imrja8

imrja8 commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

@greptileai review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Traefik backend connections can outlive Swarm task membership during rolling updates

2 participants