Skip to content

[fix] Fixed docker images unecessary prefetching from hub #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "redis-benchmarks-specification"
version = "0.1.10"
version = "0.1.11"
description = "The Redis benchmarks specification describes the cross-language/tools requirements and expectations to foster performance and observability standards around redis related technologies. Members from both industry and academia, including organizations and individuals are encouraged to contribute."
authors = ["filipecosta90 <[email protected]>"]
readme = "Readme.md"
Expand Down
10 changes: 8 additions & 2 deletions redis_benchmarks_specification/__builder__/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
def build_spec_image_prefetch(builders_folder, different_build_specs):
logging.info("checking build spec requirements")
already_checked_images = []
hub_pulled_images = 0
client = docker.from_env()
for build_spec in different_build_specs:
build_config, id = get_build_config(builders_folder + "/" + build_spec)
Expand All @@ -331,13 +332,18 @@ def build_spec_image_prefetch(builders_folder, different_build_specs):
id, build_image
)
)
if build_image not in client.images.list():
local_images = [
x.tags[0]
for x in client.images.list(filters={"reference": build_image})
]
if build_image not in local_images:
logging.info(
"Build {} requirement: build image {} is not available locally. Fetching it from hub".format(
id, build_image
)
)
client.images.pull(build_image)
hub_pulled_images = hub_pulled_images + 1
else:
logging.info(
"Build {} requirement: build image {} is available locally.".format(
Expand All @@ -351,4 +357,4 @@ def build_spec_image_prefetch(builders_folder, different_build_specs):
id, build_image
)
)
return already_checked_images
return already_checked_images, hub_pulled_images
8 changes: 7 additions & 1 deletion utils/tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@
def test_build_spec_image_prefetch():
builders_folder = "./redis_benchmarks_specification/setups/builders"
different_build_specs = ["gcc:8.5.0-amd64-debian-buster-default.yml"]
prefetched_images = build_spec_image_prefetch(
prefetched_images, total_fetched = build_spec_image_prefetch(
builders_folder, different_build_specs
)
assert total_fetched == 0 or total_fetched == 1
assert "gcc:8.5.0-buster" in prefetched_images
for x in range(0, 100):
prefetched_images, total_fetched = build_spec_image_prefetch(
builders_folder, different_build_specs
)
assert total_fetched == 0


def test_commit_schema_to_stream_then_build():
Expand Down