Volume prune: only prune anonymous volumes by default#44216
Volume prune: only prune anonymous volumes by default#44216thaJeztah merged 1 commit intomoby:masterfrom
Conversation
tianon
left a comment
There was a problem hiding this comment.
This finally makes volume pruning consistent with all our other prune experiences! LGTM 😍
3a6e782 to
2312731
Compare
1ddbd45 to
7fdf167
Compare
7fdf167 to
5ed9600
Compare
|
Updated this as discussed to make sure older API versions keep the old behavior. |
|
Looks like we need to skip one of the docker-py tests and/or fix in upstream. Haven't checked yet what the test does, and if it's incorrect. That said; if it's using API v1.41, it probably should've passed 🤔 Test is https://github.com/docker/docker-py/blob/5.0.3/tests/integration/api_volume_test.py#L58-L64
edit: LOL, and of course I already had a PR in draft; #43998 |
|
The test looks quite straightforward in the current main, but I'm not sure what version is in use here. If this is actually what is failing here, I think the bug is in this PR; however I haven't dug in any further. |
|
I see brian is already testing a change in that code. Perhaps the docker-py tests don't specify an API version, in which case they could be using "latest" (not a fixed version). I also dusted off #43998, which shows how tests can be skipped temporarily (we probably can do so if we know why it's failing) |
|
It seems like it should be using 1.41 (it's what's in the docker-py makefile). |
|
The daemon logs from the docker-py run shows it is using API v1.43 https://github.com/moby/moby/actions/runs/3154324955/jobs/5131882252#step:8:17308 |
|
Ah, that's because we are running |
|
I see it's calling |
|
As isn't merged yet, and it looks like needs some work, perhaps you can update Line 19 in 3c06ebd # TODO re-enable test_attach_no_stream after https://github.com/docker/docker-py/issues/2513 is resolved
# TODO re-enable test_create_with_device_cgroup_rules after https://github.com/docker/docker-py/issues/2939 is resolved
# TODO re-enable test_prune_volumes after https://github.com/docker/docker-py/pull/3051 is resolved
: "${PY_TEST_OPTIONS:=--junitxml=${DEST}/junit-report.xml --deselect=tests/integration/api_container_test.py::AttachContainerTest::test_attach_no_stream --deselect=tests/integration/api_container_test.py::CreateContainerTest::test_create_with_device_cgroup_rules --deselect=tests/integration/api_volume_test.py::TestVolumes::test_prune_volumes}" |
thaJeztah
left a comment
There was a problem hiding this comment.
Left two comments; I have the changes locally, so let me open a quick PR against your branch
|
|
||
| Available filters: | ||
| - `label` (`label=<key>`, `label=<key>=<value>`, `label!=<key>`, or `label!=<key>=<value>`) Prune volumes with (or without, in case `label!=...` is used) the specified labels. | ||
| - `all` (`all=true`) - Consider all (local) volumes for pruning and not just anonymous volumes. |
There was a problem hiding this comment.
Looks like this PR was implemented to be included in API v1.42 (22.06); could you apply this change to the docs/api/v1.42.yaml file as well?
|
opened cpuguy83#5 <-- PTAL @cpuguy83 |
97c4744 to
07f46f6
Compare
This adds a new filter argument to the volume prune endpoint "all". When this is not set, or it is a false-y value, then only anonymous volumes are considered for pruning. When `all` is set to a truth-y value, you get the old behavior. This is an API change, but I think one that is what most people would want. Signed-off-by: Brian Goff <cpuguy83@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
07f46f6 to
618f26c
Compare
|
All green |
|
|
||
| // AnonymousLabel is the label used to indicate that a volume is anonymous | ||
| // This is set automatically on a volume when a volume is created without a name specified, and as such an id is generated for it. | ||
| const AnonymousLabel = "com.docker.volume.anonymous" |
There was a problem hiding this comment.
One thing I wonder; will this have an effect on volumes that "started as anonymous", but later on became "named"?
Thinking of situations like
docker run -d --name container1 some-image-with-volumes
docker run --volumes-from=container2 some-image
Yes, the volume is still "anonymous", but no longer really "ephemeral"
There was a problem hiding this comment.
The volume is still anonymous, but if a container is holding a reference to it, it won't be pruned anyway.
This is related to moby/moby#44216 Prunes will, by default, no longer prune named volumes, only anonymous ones. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This is related to moby/moby#44216 Prunes will, by default, no longer prune named volumes, only anonymous ones. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This adds a new filter argument to the volume prune endpoint "all". When this is not set, or it is a false-y value, then only anonymous volumes are considered for pruning.
When
allis set to a truth-y value, you get the old behavior.This is an API change, but I think one that is what most people would want.