Repository navigation
outposts: close docker client connection on exit - #28067
Merged
Merged
Conversation
DockerClient overrides docker.DockerClient.__exit__ to clean up its temporary TLS and SSH files, but never calls close(), which is what the upstream __exit__ does. For ssh:// service connections every outpost_service_connection_monitor and outpost_controller run therefore leaves a paramiko session and its transport thread behind. On my instance the worker held 363 threads and 350 SSH sessions to the outpost host after 3.5 days and used 60-90% CPU while idle. closes goauthentik#16747
✅ Deploy Preview for authentik-docs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
BeryJu
approved these changes
Nov 24, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #28067 +/- ##
==========================================
- Coverage 93.34% 93.30% -0.05%
==========================================
Files 1251 1251
Lines 89809 89819 +10
Branches 4967 4967
==========================================
- Hits 83833 83806 -27
- Misses 5911 5948 +37
Partials 65 65
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* main: (132 commits) Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) web: bump @styleframe/theme from 3.8.1 to 3.10.0 (#28058) web: bump launch-editor from 2.14.1 to 2.14.2 (#28070) web: bump launch-editor from 2.14.1 to 2.14.2 in /website (#28072) web: bump uuid from 14.0.1 to 14.0.3 in /website (#28073) web: bump fast-uri from 3.1.6 to 3.1.9 in /website (#28074) core: bump goauthentik/fips-python from `6d01ed9` to `35f881a` in /lifecycle/container (#28044) root: bump version to 2027.2.0-rc1 (#28065) web: bump the website-build group across 1 directory with 3 updates (#28054) core: bump cachetools from 8.0.0 to 8.0.2 (#28049) stages/authenticator_webauthn: Update FIDO MDS3 & Passkey aaguid blobs (#28041) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
…s-is-not-a-component' into web/bugs/form-errors-is-not-a-component * refs/remotes/origin/web/bugs/form-errors-is-not-a-component: (136 commits) web/maintenance: rename ak-field-errors to renderFormErrors Web/bugs/icon maintenance 4 (#28030) web/maintenance/icons: Debug, Permissions, Table, web/maintenance/icons: ApplicationWizard: replace the cogs with the spinner Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) web: bump @styleframe/theme from 3.8.1 to 3.10.0 (#28058) web: bump launch-editor from 2.14.1 to 2.14.2 (#28070) web: bump launch-editor from 2.14.1 to 2.14.2 in /website (#28072) web: bump uuid from 14.0.1 to 14.0.3 in /website (#28073) web: bump fast-uri from 3.1.6 to 3.1.9 in /website (#28074) core: bump goauthentik/fips-python from `6d01ed9` to `35f881a` in /lifecycle/container (#28044) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* main: (194 commits) Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) web: bump @styleframe/theme from 3.8.1 to 3.10.0 (#28058) web: bump launch-editor from 2.14.1 to 2.14.2 (#28070) web: bump launch-editor from 2.14.1 to 2.14.2 in /website (#28072) web: bump uuid from 14.0.1 to 14.0.3 in /website (#28073) web: bump fast-uri from 3.1.6 to 3.1.9 in /website (#28074) core: bump goauthentik/fips-python from `6d01ed9` to `35f881a` in /lifecycle/container (#28044) root: bump version to 2027.2.0-rc1 (#28065) web: bump the website-build group across 1 directory with 3 updates (#28054) core: bump cachetools from 8.0.0 to 8.0.2 (#28049) stages/authenticator_webauthn: Update FIDO MDS3 & Passkey aaguid blobs (#28041) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* main: (152 commits) Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) web: bump @styleframe/theme from 3.8.1 to 3.10.0 (#28058) web: bump launch-editor from 2.14.1 to 2.14.2 (#28070) web: bump launch-editor from 2.14.1 to 2.14.2 in /website (#28072) web: bump uuid from 14.0.1 to 14.0.3 in /website (#28073) web: bump fast-uri from 3.1.6 to 3.1.9 in /website (#28074) core: bump goauthentik/fips-python from `6d01ed9` to `35f881a` in /lifecycle/container (#28044) root: bump version to 2027.2.0-rc1 (#28065) web: bump the website-build group across 1 directory with 3 updates (#28054) core: bump cachetools from 8.0.0 to 8.0.2 (#28049) stages/authenticator_webauthn: Update FIDO MDS3 & Passkey aaguid blobs (#28041) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* main: (283 commits) Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) web: bump @styleframe/theme from 3.8.1 to 3.10.0 (#28058) web: bump launch-editor from 2.14.1 to 2.14.2 (#28070) web: bump launch-editor from 2.14.1 to 2.14.2 in /website (#28072) web: bump uuid from 14.0.1 to 14.0.3 in /website (#28073) web: bump fast-uri from 3.1.6 to 3.1.9 in /website (#28074) core: bump goauthentik/fips-python from `6d01ed9` to `35f881a` in /lifecycle/container (#28044) root: bump version to 2027.2.0-rc1 (#28065) web: bump the website-build group across 1 directory with 3 updates (#28054) core: bump cachetools from 8.0.0 to 8.0.2 (#28049) stages/authenticator_webauthn: Update FIDO MDS3 & Passkey aaguid blobs (#28041) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* web/maint/ak-label: (285 commits)
Editorial decision: Removed a brand ('optin-monster') from the collection of Icons we support. I'm not even sure who these people are or if we care: https://optinmonster.com/. The icon definition was blocking the merge because 'optin' is too close to 'option'.
Editorial decision: Removed a brand ('optin-monster') from the collection of Icons we support. I'm not even sure who these people are or if we care: https://optinmonster.com/
Web/bugs/icon maintenance 2 (#27889)
Web/spike/icon identification (#27888)
root: tidy the generated release changelog (#28079)
ci: leave rust build-warnings setting default (#28080)
outposts: close docker client connection on exit (#28067)
core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043)
ci: bump the codeql group across 1 directory with 3 updates (#28045)
core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047)
core: bump pyyaml from 6.0.3 to 6.0.4 (#28048)
web: bump styleframe from 3.9.1 to 3.9.2 (#28055)
web: bump @styleframe/theme from 3.8.1 to 3.10.0 (#28058)
web: bump launch-editor from 2.14.1 to 2.14.2 (#28070)
web: bump launch-editor from 2.14.1 to 2.14.2 in /website (#28072)
web: bump uuid from 14.0.1 to 14.0.3 in /website (#28073)
web: bump fast-uri from 3.1.6 to 3.1.9 in /website (#28074)
core: bump goauthentik/fips-python from `6d01ed9` to `35f881a` in /lifecycle/container (#28044)
root: bump version to 2027.2.0-rc1 (#28065)
web: bump the website-build group across 1 directory with 3 updates (#28054)
...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* main: (157 commits) web/maint: upgrade ak-label (#24265) web: bump jquery from 3.7.1 to 3.8.0 in /web (#28106) core: bump goauthentik/selenium from 155.0-ak-0.73.0 to 156.0-ak-0.73.1 in /tests/e2e (#28092) core: bump goauthentik/fips-python from `35f881a` to `bd582ea` in /lifecycle/container (#28096) core: bump goauthentik/fips-debian from `137514c` to `afdcf15` in /lifecycle/container (#28093) web/maintenance: remove Patternfly background-image CSS (#27760) Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) web: bump @styleframe/theme from 3.8.1 to 3.10.0 (#28058) web: bump launch-editor from 2.14.1 to 2.14.2 (#28070) web: bump launch-editor from 2.14.1 to 2.14.2 in /website (#28072) web: bump uuid from 14.0.1 to 14.0.3 in /website (#28073) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* main: (148 commits) website/docs: add release notes for 2026.5.9 (#28148) website/docs: add release notes for 2026.8.7 (#28150) web/components: clean up ak-event info (#27753) web/elements: ak-tooltip (#24418) web/maint: upgrade ak-label (#24265) web: bump jquery from 3.7.1 to 3.8.0 in /web (#28106) core: bump goauthentik/selenium from 155.0-ak-0.73.0 to 156.0-ak-0.73.1 in /tests/e2e (#28092) core: bump goauthentik/fips-python from `35f881a` to `bd582ea` in /lifecycle/container (#28096) core: bump goauthentik/fips-debian from `137514c` to `afdcf15` in /lifecycle/container (#28093) web/maintenance: remove Patternfly background-image CSS (#27760) Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) ...
kensternberg-authentik
added a commit
that referenced
this pull request
Nov 25, 2026
* main: (232 commits) website/docs: add release notes for 2026.5.9 (#28148) website/docs: add release notes for 2026.8.7 (#28150) web/components: clean up ak-event info (#27753) web/elements: ak-tooltip (#24418) web/maint: upgrade ak-label (#24265) web: bump jquery from 3.7.1 to 3.8.0 in /web (#28106) core: bump goauthentik/selenium from 155.0-ak-0.73.0 to 156.0-ak-0.73.1 in /tests/e2e (#28092) core: bump goauthentik/fips-python from `35f881a` to `bd582ea` in /lifecycle/container (#28096) core: bump goauthentik/fips-debian from `137514c` to `afdcf15` in /lifecycle/container (#28093) web/maintenance: remove Patternfly background-image CSS (#27760) Web/bugs/icon maintenance 2 (#27889) Web/spike/icon identification (#27888) root: tidy the generated release changelog (#28079) ci: leave rust build-warnings setting default (#28080) outposts: close docker client connection on exit (#28067) core: bump goauthentik/fips-debian from `7c0cb03` to `137514c` in /lifecycle/container (#28043) ci: bump the codeql group across 1 directory with 3 updates (#28045) core: bump coverage[toml] from 7.17.3 to 7.17.4 (#28047) core: bump pyyaml from 6.0.3 to 6.0.4 (#28048) web: bump styleframe from 3.9.1 to 3.9.2 (#28055) ...
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.
Details
What does this PR change?
DockerClient.__exit__now callsself.close()before it removes its temporary TLS and SSH files.Why is this change needed?
authentik.outposts.controllers.docker.DockerClientoverridesdocker.DockerClient.__exit__, which is where docker-py closes the connection. Forssh://service connections, every run ofoutpost_service_connection_monitor, and ofoutpost_controllerviaBaseController.__exit__, leaves a paramiko session and its transport thread open. On my 2026.8.5 instance the worker had 363 threads and 350 established SSH sessions to the outpost host after 3.5 days, and it used 60–90% CPU while it had almost nothing to do.How was this tested?
I added
test_client_exit_closes_connection. Against the 2026.8.5 image it fails without the change and passes with it. I haven't run the fullmake alllocally.I've also run the same change in production on 2026.8.6 since 2026-11-24 (patched at worker start). After nine monitor runs the worker had 14 threads, used about 1.4% CPU, and had one SSH session open per outpost host. Its local port changed between runs, so the earlier sessions had been closed.
Not in this PR:
DockerInlineSSH.cleanup()never removes a block at the top of~/.ssh/config, becausestart = 0doubles as "not found". On my instance the file had grown to 636 blocks. I can send a separate PR for that.Linked issues
closes #16747
AI usage
I used Claude Code to trace the leak on my server, write the change and the test, and draft this description. I reviewed the diff and checked the behaviour on my own instance.
Checklist
make all)make docs)