Skip to content

Convert DanglingOnly to Filters for docker image prune#28535

Merged
vdemeester merged 1 commit intomoby:masterfrom
yongtang:28497-prune-until
Dec 6, 2016
Merged

Convert DanglingOnly to Filters for docker image prune#28535
vdemeester merged 1 commit intomoby:masterfrom
yongtang:28497-prune-until

Conversation

@yongtang
Copy link
Copy Markdown
Member

@yongtang yongtang commented Nov 17, 2016

- What I did

This fix is part of fix for #28497

This fix convert DanglingOnly in ImagesPruneConfig to Filters, so that it is possible to maintain API compatibility in the future.

A follow up to this PR will be done once this PR is merged.

- How I did it

- How to verify it

Several integration tests have been added to cover changes.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

cute-baby-animal-wallpapers-hd-images

This fix is related to #28497.

Signed-off-by: Yong Tang yong.tang.github@outlook.com

@AkihiroSuda
Copy link
Copy Markdown
Member

SGTM

It would be great if we can support --until="5min ago" as well.

Also it would be great if we can have support for network (another PR)

@thaJeztah
Copy link
Copy Markdown
Member

Should we use --filter for this? I think it's more consistent, and expandable (docker prune --filter label=foo at some point?)

@thaJeztah
Copy link
Copy Markdown
Member

/cc @mlaventure

@AkihiroSuda
Copy link
Copy Markdown
Member

IMO we should have both filter and until for CLI, but for API, we only need filter.

@vdemeester
Copy link
Copy Markdown
Member

vdemeester commented Nov 18, 2016

I do agree with @thaJeztah, it's the same as images where we had --until and --since and we unified it under --filter. Let's jump to --filter=until=… already and not add --until to deprecate it later 😛

@justincormack
Copy link
Copy Markdown
Contributor

SGTM, current prune has not been very useful for CI machines so far, really want prune by age for that use case.

@mlaventure
Copy link
Copy Markdown
Contributor

I'm with @vdemeester and @thaJeztah can we have a --filter instead?

@yongtang
Copy link
Copy Markdown
Member Author

Thanks all. Let me update the PR based on the comments.

@yongtang
Copy link
Copy Markdown
Member Author

I noticed that currently, images/prune has a DanglingOnly field:

// POST "/images/prune"
type ImagesPruneConfig struct {
    DanglingOnly bool   
  }

However, if we takes a filter, then this field could very well be replaced with dangling=true, which will be consistent with docker volume ls --filter dangling=true.

Should we convert DanglingOnly tofilter as well?

@mlaventure
Copy link
Copy Markdown
Contributor

@yongtang sure, why not.

@thaJeztah
Copy link
Copy Markdown
Member

Would dangling=false work though (for prune)?

@mlaventure
Copy link
Copy Markdown
Contributor

@thaJeztah both should work.

Currently danglingOnly default to true and -a switch it. It also only affects images atm.

@yongtang
Copy link
Copy Markdown
Member Author

The PR has been updated. Now the --filter flag takes both dangling=<true|false> and until=<timestamp>, replacing DanglingOnly bool. That could be an API change. Depending on if this PR is considered for 1.13 or later, additional update might be required to maintain API compatibility.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: how about Filters: pruneFilters

@AkihiroSuda AkihiroSuda removed this from the 1.14.0 milestone Nov 28, 2016
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i.e. -> e.g.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's dedup this "all vs dangling" logic

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i.e. -> e.g.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you support filter for volume and network as well?
(can be another PR)

Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda Nov 28, 2016

Choose a reason for hiding this comment

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

I think we don't need to deprecate the --all CLI option, because it is short and easy to use

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I also vote to keep --all

@AkihiroSuda
Copy link
Copy Markdown
Member

That could be an API change. Depending on if this PR is considered for 1.13 or later, additional update might be required to maintain API compatibility.

Since 1.13 has been already freezed, I do think the until=<timestamp> should not be in 1.13.
However, I also understand the issue about maintaining compatibility of the API.
So, how about the following plan?

1.13

  • API: Replace ImagePruneConfig.DanglingOnly with ImagePruneConfig.Filters right now. However, the filter API should only support dangling=true/false at the moment, and should not support until=<timestamp>.
  • CLI: Do not add --filter at the moment. However, the --all option should be internally converted to ImagePruneConfig.Filters.

1.14

  • API: Add until=<timestamp> (and so on, if we want)
  • CLI: Add --filter.

WDYT?

@mlaventure
Copy link
Copy Markdown
Contributor

I know we've frozen the branch yet, but I think i'd rather we make an exception and replace DanglingOnly with Filter to avoid having to maintain both in the future since this API wasn't in any stable release yet.

@thaJeztah
Copy link
Copy Markdown
Member

Agree with @AkihiroSuda and @mlaventure (discussed briefly with @AkihiroSuda earlier today). It's not released yet, so we can still modify. It's better done now, than having to officially deprecate / change after release

@yongtang
Copy link
Copy Markdown
Member Author

Thanks all for the review. I am also in favor of replacing DanglingOnly with Filter and get it in before 1.13 release (just to avoid future deprecate/compatibility issue).

I will update the PR based on the comments shortly.

@yongtang yongtang force-pushed the 28497-prune-until branch 2 times, most recently from 03c8104 to 5426403 Compare December 3, 2016 04:05
This fix convert DanglingOnly in ImagesPruneConfig to Filters,
so that it is possible to maintain API compatibility in the future.

Several integration tests have been added to cover changes.

This fix is related to 28497.

A follow up to this PR will be done once this PR is merged.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

ping @thaJeztah

Copy link
Copy Markdown
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐸

@vdemeester vdemeester merged commit 745795e into moby:master Dec 6, 2016
@yongtang yongtang deleted the 28497-prune-until branch December 6, 2016 15:34
yongtang added a commit to yongtang/docker that referenced this pull request Jan 4, 2017
This fix is a follow up for comment
moby#28535 (comment)

This fix provides `--filter until=<timestamp>` for `docker container/image prune`.

This fix adds `--filter until=<timestamp>` to `docker container/image prune`
so that it is possible to specify a timestamp and prune those containers/images
that are earlier than the timestamp.

Related docs has been updated

Several integration tests have been added to cover changes.

This fix fixes moby#28497.

This fix is related to moby#28535.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
Convert DanglingOnly to Filters for `docker image prune`
dnephin pushed a commit to dnephin/docker that referenced this pull request Apr 17, 2017
Convert DanglingOnly to Filters for `docker image prune`
andrewhsu pushed a commit to docker-archive/docker-ce that referenced this pull request May 19, 2017
This fix is a follow up for comment
moby/moby#28535 (comment)

This fix provides `--filter until=<timestamp>` for `docker container/image prune`.

This fix adds `--filter until=<timestamp>` to `docker container/image prune`
so that it is possible to specify a timestamp and prune those containers/images
that are earlier than the timestamp.

Related docs has been updated

Several integration tests have been added to cover changes.

This fix fixes #28497.

This fix is related to #28535.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: e2416af0136b72d369de53ff7928d7cc603d4f46
Component: cli
andrewhsu pushed a commit to docker-archive/docker-ce that referenced this pull request May 19, 2017
This fix is a follow up for comment
moby/moby#28535 (comment)

This fix provides `--filter until=<timestamp>` for `docker container/image prune`.

This fix adds `--filter until=<timestamp>` to `docker container/image prune`
so that it is possible to specify a timestamp and prune those containers/images
that are earlier than the timestamp.

Related docs has been updated

Several integration tests have been added to cover changes.

This fix fixes #28497.

This fix is related to #28535.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 337483496b355b61d3aa4fd4b4f4853e59be646a
Component: cli
andrewhsu pushed a commit to docker-archive/docker-ce that referenced this pull request Jun 5, 2017
This fix is a follow up for comment
moby/moby#28535 (comment)

This fix provides `--filter until=<timestamp>` for `docker container/image prune`.

This fix adds `--filter until=<timestamp>` to `docker container/image prune`
so that it is possible to specify a timestamp and prune those containers/images
that are earlier than the timestamp.

Related docs has been updated

Several integration tests have been added to cover changes.

This fix fixes #28497.

This fix is related to #28535.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: fdd6879b68d2587d1c88282a9b5e2da6566af25d
Component: cli
dnephin pushed a commit to dnephin/cli that referenced this pull request Jun 14, 2017
This fix is a follow up for comment
moby/moby#28535 (comment)

This fix provides `--filter until=<timestamp>` for `docker container/image prune`.

This fix adds `--filter until=<timestamp>` to `docker container/image prune`
so that it is possible to specify a timestamp and prune those containers/images
that are earlier than the timestamp.

Related docs has been updated

Several integration tests have been added to cover changes.

This fix fixes #28497.

This fix is related to #28535.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@nicosingh
Copy link
Copy Markdown

Hi,

I'm very very sorry in advance for this newbie question 😬, but I can't understand the definition of dangling parameter in /images/prune endpoint (ref):

dangling=<boolean>:
- When set to true (or 1), prune only unused and untagged images
- When set to false (or 0), all unused images are pruned

The usage of the words only and all brings my confusion. I'd expect to read something like this (if my understanding is correct):

dangling=<boolean>:
- When set to true (or 1), both unused and untagged images are pruned
- When set to false (or 0), only unused images are pruned

Or:

dangling=<boolean>:
- When set to true (or 1), only untagged images are pruned
- When set to false (or 0), only unused images are pruned

Or:

dangling=<boolean>:
- When set to true (or 1), only untagged images are pruned
- When set to false (or 0), both unused and untagged images are pruned

By the way, which is the default value for dangling field?. I'd expect to think it's false.

Thanks in advance for your help! My apologies if these questions are duplicated (I couldn't find them elsewhere).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants