docuum icon indicating copy to clipboard operation
docuum copied to clipboard

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

Open wu105 opened this issue 4 years ago • 1 comments

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.

wu105 avatar Oct 14 '20 18:10 wu105

I agree this would be nice to have. Thanks for submitting this request!

(As usual, I can't make any promises that I will have time to implement it, but contributions are always welcome.)

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.

Hm, that sounds like a bug. Docuum logs every time it thinks an image has just been used. Perhaps the logs already have enough information to diagnose? But Docuum only logs the image ID (not the tags), so you'd need to have that handy.

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.

Both start and end time are now used. Docuum also understands when an image is currently in use by a running container, so in a sense the entire interval is taken into consideration and not just the two endpoints.

stepchowfun avatar Oct 15 '20 00:10 stepchowfun