-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
attach: close streams when done #12112
Merged
Merged
Conversation
This file contains 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
When Compose is watching a project/reattaching streams on container start, it will make new API `ContainerAttach()` calls every time a container it's watching is started. However, it only closes the stream when the context used to start the attach is canceled. This means that if a user has a project with multiple containers where containers keep restarting, Compose will attach to the new containers but never close the previous streams, causing fds to pile up and goroutines on the engine to get stuck. Signed-off-by: Laura Brehm <laurabrehm@hey.com>
laurazard
requested review from
a team,
ndeloof,
glours and
jhrotko
and removed request for
a team
September 10, 2024 12:46
glours
approved these changes
Sep 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ndeloof
approved these changes
Sep 10, 2024
tmeijn
pushed a commit
to tmeijn/dotfiles
that referenced
this pull request
Sep 21, 2024
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [docker/compose](https://github.com/docker/compose) | patch | `v2.29.2` -> `v2.29.6` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>docker/compose (docker/compose)</summary> ### [`v2.29.6`](https://github.com/docker/compose/releases/tag/v2.29.6) [Compare Source](docker/compose@v2.29.5...v2.29.6) #### What's Changed ##### 🐛 Fixes - Don't set propagation if target engine isn't linux by [@​ndeloof](https://github.com/ndeloof) [(12138)](docker/compose#12138) ##### ⚙️ Dependencies - build(deps): bump docker, docker/cli to v27.3.0-rc.2 by [@​thaJeztah](https://github.com/thaJeztah) [(12136)](docker/compose#12136) **Full Changelog**: docker/compose@v2.29.5...v2.29.6 ### [`v2.29.5`](https://github.com/docker/compose/releases/tag/v2.29.5) [Compare Source](docker/compose@v2.29.4...v2.29.5) #### What's Changed This release fix an issue with bind mounts on WSL2 when using Docker Desktop ##### 🐛 Fixes - Set propagation default by [@​ndeloof](https://github.com/ndeloof) [(12133)](docker/compose#12133) ##### 🔧 Internal - Remove custom codeql workflow in favor of default setup by [@​temenuzhka-thede](https://github.com/temenuzhka-thede) [(12131)](docker/compose#12131) **Full Changelog**: docker/compose@v2.29.4...v2.29.5 ### [`v2.29.4`](https://github.com/docker/compose/releases/tag/v2.29.4) [Compare Source](docker/compose@v2.29.3...v2.29.4) #### What's Changed ##### 🐛 Fixes - Fixed possible `nil` pointer dereference by [@​disc](https://github.com/disc) [(12127)](docker/compose#12127) - Stop dependent containers before recreating diverged service by [@​ndeloof](https://github.com/ndeloof) [(12122)](docker/compose#12122) ##### 🔧 Internal - GHA: test against docker engine v27.3.0 by [@​thaJeztah](https://github.com/thaJeztah) [(12126)](docker/compose#12126) - Chore(watch): Add debug log when skipping service without build context by [@​idsulik](https://github.com/idsulik) [(12067)](docker/compose#12067) ##### ⚙️ Dependencies - Build(deps): bump docker, docker/cli to v27.3.0-rc.1, buildx v0.17.1 by [@​thaJeztah](https://github.com/thaJeztah) [(12125)](docker/compose#12125) #### New Contributors - [@​disc](https://github.com/disc) made their first contribution in docker/compose#12127 **Full Changelog**: docker/compose@v2.29.3...v2.29.4 ### [`v2.29.3`](https://github.com/docker/compose/releases/tag/v2.29.3) [Compare Source](docker/compose@v2.29.2...v2.29.3) #### What's Changed ##### ✨ Improvements - Allow combination of bind mounts and 'rebuild' watches by [@​remcokranenburg](https://github.com/remcokranenburg) [(12089)](docker/compose#12089) ##### 🐛 Fixes - Fix(wait): Wait only until first container exit by [@​idsulik](https://github.com/idsulik) [(12064)](docker/compose#12064) - Prefer mount API over bind by [@​ndeloof](https://github.com/ndeloof) [(12078)](docker/compose#12078) - Service hash must exclude depends_on by [@​ndeloof](https://github.com/ndeloof) [(12072)](docker/compose#12072) - Attach: close streams when done by [@​laurazard](https://github.com/laurazard) [(12112)](docker/compose#12112) - Restore compose v1 behavior to recreate containers when ran with `-V` by [@​ndeloof](https://github.com/ndeloof) [(12116)](docker/compose#12116) ##### 🔧 Internal - Allow to add empty line in the logs when nav menu activated by [@​glours](https://github.com/glours) [(12062)](docker/compose#12062) - Docs: duplicate documentation for root cmd by [@​dvdksn](https://github.com/dvdksn) [(12076)](docker/compose#12076) - Fix typo in pull.go by [@​jonathan-dev](https://github.com/jonathan-dev) [(12108)](docker/compose#12108) - Use logrus instead of direct output to stderr by [@​felixfontein](https://github.com/felixfontein) [(11996)](docker/compose#11996) - Fix minor typos by [@​NathanBaulch](https://github.com/NathanBaulch) [(12104)](docker/compose#12104) - Chore(watch): Add changed file paths/count to log by [@​idsulik](https://github.com/idsulik) [(12118)](docker/compose#12118) ##### ⚙️ Dependencies - Build(deps): bump golang.org/x/sys from 0.22.0 to 0.25.0 by [@​dependabot](https://github.com/dependabot) [(12101)](docker/compose#12101) - Bump engine cli v27.2.1 by [@​glours](https://github.com/glours) [(12115)](docker/compose#12115) - Bump compose-go to version `v2.2.0` by [@​glours](https://github.com/glours) [(12117)](docker/compose#12117) - Build(deps): bump golang.org/x/sync from `0.7.0` to `0.8.0` by [@​dependabot](https://github.com/dependabot) [(12043)](docker/compose#12043) #### New Contributors - [@​remcokranenburg](https://github.com/remcokranenburg) made their first contribution in [(12089)](docker/compose#12089) - [@​jonathan-dev](https://github.com/jonathan-dev) made their first contribution in [(12108)](docker/compose#12108) - [@​NathanBaulch](https://github.com/NathanBaulch) made their first contribution in [(12104)](docker/compose#12104) **Full Changelog**: docker/compose@v2.29.2...v2.29.3 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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 I did
When Compose is watching a project/reattaching streams on container start, it will make new API
ContainerAttach()
calls every time a container it's watching is started. However, it only closes the stream when the context used to start the attach is canceled.This means that if a user has a project with multiple containers where containers keep restarting, Compose will attach to the new containers but never close the previous streams, causing fds to pile up and goroutines on the engine to get stuck.
You can verify this by using a Dockerfile such as:
And the following Compose file:
Run
docker compose up --scale occupied=8 --scale surplus=2`.
In another terminal, run
watch -n1 "lsof -p `pgrep docker-compose` | grep unix"
And gradually watch the connections pile up.
(There might also be some bug engine-side here, I haven't looked into it yet.)
Related issue
fixes #12023
(not mandatory) A picture of a cute animal, if possible in relation to what you did