Skip to content

add elapsed time since last used to the "Deleting image" log line #124

Description

@wu105

Description
Add elapsed time in seconds since last used to the "Deleting image" log line, e.g.,
the current log line
[2020-08-28 16:16:46 +00:00 INFO] Deleting image `sha256:a90bc6e1a28c671dd91b6f2fa7fa73d475c96e2091387649dbba2a0768a31611`…
would read like this
[2020-08-28 16:16:46 +00:00 INFO] Deleting image `sha256:a90bc6e1a28c671dd91b6f2fa7fa73d475c96e2091387649dbba2a0768a31611` last used 16600s ago
or simply like this;
[2020-08-28 16:16:46 +00:00 INFO] Deleting image `sha256:a90bc6e1a28c671dd91b6f2fa7fa73d475c96e2091387649dbba2a0768a31611` 16600

Since we are at modifying this log line, we may also want to add the image size information if it is readily available.

Alternatives considered
none

Additional context
On a machine used for building images, some actively used images are never used for running containers.
We are seen some images gets deleted then re-pulled soon after.
We may have a similar issue with images built locally or images with epoch 0 or other fake time as the build time.

Seeing the last used time of the deleted images can help us to understand the situation.

The follow up could be counting tagging or pulling as last use.
For locally built images, it would be desirable to use the build time as the last use time, and if possible, making all its parents as last used at the build time.

By the way, I have noticed that container destroy time was used for last used time and that has changed to use container start time -- we may want to use both if it is not the case. To prevent deleting images used by running containers (always fail) completely, we may need to update last use time periodically on running containers if it it is worthy.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions