moby/api/types
Sebastiaan van Stijn 51c7992928
API: add "prune" events
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 <github@gone.nl>
2020-07-28 12:41:14 +02:00
..
backend Add stats options to not prime the stats 2020-02-28 09:54:37 -08:00
blkiodev Add canonical import comment 2018-02-05 16:51:57 -05:00
container Merge pull request #41254 from AkihiroSuda/deprecate-kernel-memory 2020-07-28 10:43:29 +02:00
events API: add "prune" events 2020-07-28 12:41:14 +02:00
filters bump gotest.tools v3.0.1 for compatibility with Go 1.14 2020-02-11 00:06:42 +01:00
image api/types: re-generate with new template 2019-11-05 11:32:41 -08:00
mount mount: add BindOptions.NonRecursive (API v1.40) 2018-11-06 17:51:58 +09:00
network api/types: remove errdefs dependency 2020-06-04 12:14:16 +02:00
plugins/logdriver Add partial log metadata to log driver proto 2018-08-10 20:44:30 -07:00
registry goimports: fix imports 2019-09-18 12:56:54 +02:00
strslice Format code with gofmt -s from go-1.11beta1 2018-09-06 15:24:16 -07:00
swarm Replace service "Capabilities" w/ add/drop API 2020-07-27 10:09:42 -07:00
time Improve GetTimestamp parsing 2018-05-20 13:07:17 +02:00
versions Add canonical import comment 2018-02-05 16:51:57 -05:00
volume swagger: reformat, and wrap to ~80-chars 2020-05-02 18:10:28 +02:00
auth.go Add canonical import comment 2018-02-05 16:51:57 -05:00
client.go Exec inspect field should be "ID" not "ExecID" 2020-02-10 14:08:54 -08:00
configs.go Accept platform spec on container create 2020-03-20 16:10:36 -07:00
error_response.go Update to inline comments. 2016-10-31 11:13:41 -04:00
error_response_ext.go Make ErrorResponse implement Error 2019-07-02 10:17:03 -07:00
graph_driver_data.go Generate GraphDriver from spec, and fix up image spec. 2017-01-03 11:47:47 -05:00
id_response.go Add an IDResponse type 2016-10-31 11:16:02 -04:00
image_delete_response_item.go Generate ImageDeleteResponse from swagger spec. 2017-01-03 11:47:47 -05:00
image_summary.go Generate api/types:Image from the swagger spec 2016-10-20 13:24:23 -07:00
plugin.go Move plugin client creation to the extension point 2018-05-25 15:18:53 -04:00
plugin_device.go Generate plugin types from the swagger spec. 2016-10-20 13:24:23 -07:00
plugin_env.go Generate plugin types from the swagger spec. 2016-10-20 13:24:23 -07:00
plugin_interface_type.go Generate plugin types from the swagger spec. 2016-10-20 13:24:23 -07:00
plugin_mount.go Generate plugin types from the swagger spec. 2016-10-20 13:24:23 -07:00
plugin_responses.go Add canonical import comment 2018-02-05 16:51:57 -05:00
port.go Describe IP field of Port definition 2018-05-15 12:09:42 +02:00
seccomp.go seccomp: allow ptrace for 4.8+ kernels 2018-11-04 13:06:43 -08:00
service_update_response.go Return warnings from service create and service update when digest pinning fails 2016-11-18 09:31:31 -08:00
stats.go Fix dont typo 2018-09-08 16:58:03 +08:00
types.go Deprecate KernelMemory 2020-07-24 20:44:29 +09:00
volume.go swagger: reformat, and wrap to ~80-chars 2020-05-02 18:10:28 +02:00