Skip to content

Commit 11f11a8

Browse files
[fix] Fixed docker images unecessary prefetching from hub (#44)
* [fix] Fixed docker images unecessary prefetching from hub * [ver] Bumping version from 0.1.10 to 0.1.11
1 parent e2d3bdf commit 11f11a8

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redis-benchmarks-specification"
3-
version = "0.1.10"
3+
version = "0.1.11"
44
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."
55
authors = ["filipecosta90 <[email protected]>"]
66
readme = "Readme.md"

redis_benchmarks_specification/__builder__/builder.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
320320
def build_spec_image_prefetch(builders_folder, different_build_specs):
321321
logging.info("checking build spec requirements")
322322
already_checked_images = []
323+
hub_pulled_images = 0
323324
client = docker.from_env()
324325
for build_spec in different_build_specs:
325326
build_config, id = get_build_config(builders_folder + "/" + build_spec)
@@ -331,13 +332,18 @@ def build_spec_image_prefetch(builders_folder, different_build_specs):
331332
id, build_image
332333
)
333334
)
334-
if build_image not in client.images.list():
335+
local_images = [
336+
x.tags[0]
337+
for x in client.images.list(filters={"reference": build_image})
338+
]
339+
if build_image not in local_images:
335340
logging.info(
336341
"Build {} requirement: build image {} is not available locally. Fetching it from hub".format(
337342
id, build_image
338343
)
339344
)
340345
client.images.pull(build_image)
346+
hub_pulled_images = hub_pulled_images + 1
341347
else:
342348
logging.info(
343349
"Build {} requirement: build image {} is available locally.".format(
@@ -351,4 +357,4 @@ def build_spec_image_prefetch(builders_folder, different_build_specs):
351357
id, build_image
352358
)
353359
)
354-
return already_checked_images
360+
return already_checked_images, hub_pulled_images

utils/tests/test_builder.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@
2424
def test_build_spec_image_prefetch():
2525
builders_folder = "./redis_benchmarks_specification/setups/builders"
2626
different_build_specs = ["gcc:8.5.0-amd64-debian-buster-default.yml"]
27-
prefetched_images = build_spec_image_prefetch(
27+
prefetched_images, total_fetched = build_spec_image_prefetch(
2828
builders_folder, different_build_specs
2929
)
30+
assert total_fetched == 0 or total_fetched == 1
3031
assert "gcc:8.5.0-buster" in prefetched_images
32+
for x in range(0, 100):
33+
prefetched_images, total_fetched = build_spec_image_prefetch(
34+
builders_folder, different_build_specs
35+
)
36+
assert total_fetched == 0
3137

3238

3339
def test_commit_schema_to_stream_then_build():

0 commit comments

Comments
 (0)