API: add "prune" events#41259
Merged
tiborvass merged 1 commit intomoby:masterfrom Jul 29, 2020
Merged
Conversation
Member
Author
|
ping @djs55 @tiborvass @AkihiroSuda PTAL |
djs55
approved these changes
Jul 25, 2020
Contributor
djs55
left a comment
There was a problem hiding this comment.
Very nice -- trim-after-delete could easily consume this.
3195a90 to
9ae9539
Compare
Member
Author
|
Rebased to trigger CI (failing on a flaky test) |
Member
Author
|
This test is flaky (again); |
This patch adds a new "prune" event type to indicate that pruning of a resource type completed. This event-type can be used on systems that want to perform actions after resources have been cleaned up. For example, Docker Desktop performs an fstrim after resources are deleted (https://github.com/linuxkit/linuxkit/tree/v0.7/pkg/trim-after-delete). While the current (remove, destroy) events can provide information on _most_ resources, there is currently no event triggered after the BuildKit build-cache is cleaned. Prune events have a `reclaimed` attribute, indicating the amount of space that was reclaimed (in bytes). The attribute can be used, for example, to use as a threshold for performing fstrim actions. Reclaimed space for `network` events will always be 0, but the field is added to be consistent with prune events for other resources. To test this patch: Create some resources: for i in foo bar baz; do \ docker network create network_$i \ && docker volume create volume_$i \ && docker run -d --name container_$i -v volume_$i:/volume busybox sh -c 'truncate -s 5M somefile; truncate -s 5M /volume/file' \ && docker tag busybox:latest image_$i; \ done; docker pull alpine docker pull nginx:alpine echo -e "FROM busybox\nRUN truncate -s 50M bigfile" | DOCKER_BUILDKIT=1 docker build - Start listening for "prune" events in another shell: docker events --filter event=prune Prune containers, networks, volumes, and build-cache: docker system prune -af --volumes See the events that are returned: docker events --filter event=prune 2020-07-25T12:12:09.268491000Z container prune (reclaimed=15728640) 2020-07-25T12:12:09.447890400Z network prune (reclaimed=0) 2020-07-25T12:12:09.452323000Z volume prune (reclaimed=15728640) 2020-07-25T12:12:09.517236200Z image prune (reclaimed=21568540) 2020-07-25T12:12:09.566662600Z builder prune (reclaimed=52428841) Signed-off-by: Sebastiaan van Stijn <[email protected]>
9ae9539 to
51c7992
Compare
Member
Author
|
All green now; PTAL |
tonistiigi
approved these changes
Jul 28, 2020
Member
tonistiigi
left a comment
There was a problem hiding this comment.
This wouldn't catch the buildkit gc releases. Otherwise LGTM
Member
Author
|
Good point; do you think there's a way to trickle those up as an event somehow (as a follow up)?
… On 28 Jul 2020, at 22:52, Tõnis Tiigi ***@***.***> wrote:
@tonistiigi approved this pull request.
This wouldn't catch the buildkit gc releases. Otherwise LGTM
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
tiborvass
approved these changes
Jul 29, 2020
Contributor
tiborvass
left a comment
There was a problem hiding this comment.
Let's do GC in a followup
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.
Relates to linuxkit/linuxkit#3539
This patch adds a new "prune" event type to indicate that pruning of a resource
type completed.
This event-type can be used on systems that want to perform actions after
resources have been cleaned up. For example, Docker Desktop performs an fstrim
after resources are deleted (https://github.com/linuxkit/linuxkit/tree/v0.7/pkg/trim-after-delete).
While the current (remove, destroy) events can provide information on most
resources, there is currently no event triggered after the BuildKit build-cache
is cleaned.
Prune events have a
reclaimedattribute, indicating the amount of space thatwas reclaimed (in bytes). The attribute can be used, for example, to use as a
threshold for performing fstrim actions. Reclaimed space for
networkeventswill always be 0, but the field is added to be consistent with prune events for
other resources.
To test this patch:
Create some resources:
Start listening for "prune" events in another shell:
Prune containers, networks, volumes, and build-cache:
See the events that are returned:
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)