Repository navigation
Cache image IDs to avoid querying Docker for every event - #427
Merged
Merged
Conversation
Each container event (including the several emitted by every healthcheck) spawned `docker image inspect` to resolve the image reference to an ID, which made Docuum's CPU usage scale with healthcheck activity even when no images were added or removed (#426). Container events now resolve image references through an in-memory cache. Image events, which can change what a reference points to, bypass and clear the cache, and entries also expire after five minutes in case a change goes unreported. The cache starts empty on each run, since events may have been missed while not listening.
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.
Docuum spawned
docker image inspectfor every container event to resolve the image reference to an ID. Each healthcheck emits several container events (exec_create,exec_start,exec_die), so Docuum's CPU usage scaled with healthcheck activity even when no images were added or removed.This PR resolves image references for container events through an in-memory cache:
pull,tag,untag,delete, etc.), which can change what a reference points to, bypass the cache and clear it.IMAGE_ID_CACHE_TTL) in case a change goes unreported. The TTL exceeds common healthcheck intervals so that healthchecks actually hit the cache.docker system eventsterminates).It also bumps the version to 0.27.2.
Testing: in addition to the new unit tests, I ran Docuum (with deletion effectively disabled) against a local Docker daemon with a container that has a 1s healthcheck. 44 of 45 container events were served from the cache, and after retagging the container's image reference to a different image, the
tagevent cleared the cache and subsequent events resolved to the new image ID.Status: Ready
Fixes: #426