Skip to content

Allow Image.pull to recognise when a remote check is not needed

Currently every time Image.pull() (from behave_utils.docker) is called there is an HTTP request made to a registry, even when there was an equivalent request moments before. Image.pull should be taught to recognise when a check for newer images is unnecessary.

Fix

There are two scenarios to fix:

Image without a hash

In this scenario, maintain an in-memory cache of image tags to hashes that have been checked during the current run, and refer to it before a remote check.

The cache should include the following features:

  • Include the Image class in the key
  • Be bound in size (an LRU cache)

This may all be possible by decorating Image.pull with functools.lru_cache

Image with ...@sha256:...

In this scenario, if the manifest with the given SHA256 hash already exists locally, and the image for the best architecture in it exists locally, then skip a remote check.

The cache of image tags could be used in this scenario too, as long as the full image tag with hash is used as the key. This can avoid one or two requests to the Docker server as well.

Tasks

  • Add a cache of image tags to SHA256 hashes: !8 (merged)
  • Add a Docker check for specific manifests and platform images: !9
Edited by Dom Sekotill
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information