Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

[17.06] Error if "until" filter is combined with "--volumes" on system prune #154

Merged

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Aug 1, 2017

cherry picked from commit docker/cli@3c095dc (docker/cli#311)

conflicted with f7a9f9f (#109)

The "until" filter is supported by all object types, except for
volumes.

Before this patch, the "until" filter would attempted to be used for the volume
prune endpoint, resulting in an error being returned by the daemon, and
further prune endpoints (networks, images) to be skipped.

$ docker system prune --filter until=24h --filter label=label.foo=bar

WARNING! This will remove:
        - all stopped containers
        - all volumes not used by at least one container
        - all networks not used by at least one container
        - all dangling images
Are you sure you want to continue? [y/N] y
Error response from daemon: Invalid filter 'until'

Calling POST /v1.30/containers/prune?filters=%7B%22label%22%3A%7B%22label.foo%3D%3Dbar%22%3Atrue%7D%2C%22until%22%3A%7B%2224h%22%3Atrue%7D%7D
Calling POST /v1.30/volumes/prune?filters=%7B%22label%22%3A%7B%22label.foo%3D%3Dbar%22%3Atrue%7D%2C%22until%22%3A%7B%2224h%22%3Atrue%7D%7D
Handler for POST /v1.30/volumes/prune returned error: Invalid filter 'until'
Error response from daemon: Invalid filter 'until'

With this patch, an error is produced instead, preventing "partial" prune.

$ docker system prune --filter until=24h --filter label=foo==bar --volumes
ERROR: The "until" filter is not supported with "--volumes"

Note that docker volume prune does not have this problem, and produces an
error if the until filter is used;

$ docker volume prune --filter until=24h

WARNING! This will remove all volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Error response from daemon: Invalid filter 'until'

The "until" filter is supported by all object types, except for
volumes.

Before this patch, the "until" filter would attempted to be used for the volume
prune endpoint, resulting in an error being returned by the daemon, and
further prune endpoints (networks, images) to be skipped.

    $ docker system prune --filter until=24h --filter label=label.foo=bar

    WARNING! This will remove:
            - all stopped containers
            - all volumes not used by at least one container
            - all networks not used by at least one container
            - all dangling images
    Are you sure you want to continue? [y/N] y
    Error response from daemon: Invalid filter 'until'

    Calling POST /v1.30/containers/prune?filters=%7B%22label%22%3A%7B%22label.foo%3D%3Dbar%22%3Atrue%7D%2C%22until%22%3A%7B%2224h%22%3Atrue%7D%7D
    Calling POST /v1.30/volumes/prune?filters=%7B%22label%22%3A%7B%22label.foo%3D%3Dbar%22%3Atrue%7D%2C%22until%22%3A%7B%2224h%22%3Atrue%7D%7D
    Handler for POST /v1.30/volumes/prune returned error: Invalid filter 'until'
    Error response from daemon: Invalid filter 'until'

With this patch, an error is produced instead, preventing "partial" prune.

    $ docker system prune --filter until=24h --filter label=foo==bar --volumes
    ERROR: The "until" filter is not supported with "--volumes"

Note that `docker volume prune` does not have this problem, and produces an
error if the `until` filter is used;

    $ docker volume prune --filter until=24h

    WARNING! This will remove all volumes not used by at least one container.
    Are you sure you want to continue? [y/N] y
    Error response from daemon: Invalid filter 'until'

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3c095dc546e9c90afcfb1ca1695b408d813b4306)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

ping @dnephin @vieux @andrewhsu PTAL

Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@andrewhsu andrewhsu left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewhsu andrewhsu added this to the 17.06.1 milestone Aug 1, 2017
@andrewhsu andrewhsu merged commit 2e36049 into docker-archive:17.06 Aug 2, 2017
@thaJeztah thaJeztah deleted the 17.06-backport-prune-until-filter branch August 2, 2017 06:48
tophj-ibm pushed a commit to tophj-ibm/docker-ce that referenced this pull request Aug 29, 2017
…ipts

Add scripts and targets for manpages and yamldocs
Upstream-commit: ed5b66308222511bd9e2e4e7e2c278d9887d0142
Component: cli
docker-jenkins pushed a commit that referenced this pull request Aug 23, 2018
Fix up Dockerfile.engine to compile docker-proxy statically
Upstream-commit: 8f1a3c9
Component: packaging
docker-jenkins pushed a commit that referenced this pull request Feb 23, 2019
…iner_on_start

[18.09 backport] Delete stale containerd object on start failure
Upstream-commit: ba8664cc2219c3ed75d3f4306569edf8b7b97a98
Component: engine
akrasnov-drv pushed a commit to drivenets/docker-ce that referenced this pull request Apr 23, 2023
Fix up Dockerfile.engine to compile docker-proxy statically
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants