Repository navigation
fix(run): keep a recreated dependency's anonymous volumes - #14358
Merged
Merged
Conversation
Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ndeloof
approved these changes
Oct 20, 2026
ndeloof
left a comment
Contributor
There was a problem hiding this comment.
LGTM. The root cause is right (run left Inherit unset while up and watch set it), the change is scoped to the dependencies run starts, and the e2e scenario fails on main for the right reason (cat: can't open '/data/marker') and passes with the fix.
Two non-blocking nits:
- The
RunOptions.CreateOptionscomment inpkg/api/api.gostill saysInheritis ignored for the dependencies; it is now always true. - The fixture could say why
init: true(sosleep infinitystops quickly) andCOMPOSE_IGNORE_ORPHANS=True(second step) are there.
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 this PR does
When
docker compose runrecreates a dependency whose configuration changed, the new container now keeps the anonymous volumes of the old one, asdocker compose upalready does. Before this change the dependency got fresh, empty volumes, so a database dependency looked wiped.Related issue
Fixes #14357
Changes made
pkg/compose/run.go:startDependenciesnow passesInherit: truetocreate(). It was left unset (false), whileupsets it unless--renew-anon-volumesis given and the watch rebuild always sets it.runhas no--renew-anon-volumesflag, so there is nothing to opt out from.pkg/e2e/compose_run_test.goandpkg/e2e/testdata/TestComposeRunInheritsAnonymousVolumes/compose.yaml: a new Scenario test. Data is written into the dependency's anonymous volume, then a config change makesrunrecreate the dependency, and the test checks the data is still there. The data is written by the test, not by the container, so a fresh volume cannot pass the check.Testing done
make testmake e2e-composeormake e2e-compose-standalonemake lintmake fmtAI tool used (if applicable)
AI Tool:
Additional context
Related: #13769. #14144 added
run --no-recreateto avoid recreating a dependency. This PR fixes the data loss when the recreation does happen.(not mandatory) A picture of a cute animal, if possible in relation to what you did