Skip to content

Commit 4e25e9c

Browse files
Added --docker-air-gap to builder and scc (#116)
1 parent f85dab1 commit 4e25e9c

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redis-benchmarks-specification"
3-
version = "0.1.40"
3+
version = "0.1.41"
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]>","Redis Performance Group <[email protected]>"]
66
readme = "Readme.md"

redis_benchmarks_specification/__builder__/builder.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ def main():
7171
type=str,
7272
default=">",
7373
)
74+
parser.add_argument(
75+
"--docker-air-gap",
76+
default=False,
77+
action="store_true",
78+
help="Store the docker images in redis keys.",
79+
)
7480
args = parser.parse_args()
7581
if args.logname is not None:
7682
print("Writting log to {}".format(args.logname))
@@ -130,7 +136,11 @@ def main():
130136
previous_id = args.consumer_start_id
131137
while True:
132138
previous_id, new_builds_count = builder_process_stream(
133-
builders_folder, conn, different_build_specs, previous_id
139+
builders_folder,
140+
conn,
141+
different_build_specs,
142+
previous_id,
143+
args.docker_air_gap,
134144
)
135145

136146

@@ -155,7 +165,9 @@ def builder_consumer_group_create(conn, id="$"):
155165
)
156166

157167

158-
def builder_process_stream(builders_folder, conn, different_build_specs, previous_id):
168+
def builder_process_stream(
169+
builders_folder, conn, different_build_specs, previous_id, docker_air_gap=False
170+
):
159171
new_builds_count = 0
160172
logging.info("Entering blocking read waiting for work.")
161173
consumer_name = "{}-proc#{}".format(STREAM_GH_EVENTS_COMMIT_BUILDERS_CG, "1")
@@ -212,6 +224,30 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
212224
run_image = build_image
213225
if "run_image" in build_config:
214226
run_image = build_config["run_image"]
227+
if docker_air_gap:
228+
airgap_key = "docker:air-gap:{}".format(run_image)
229+
logging.info(
230+
"DOCKER AIR GAP: storing run image named: {} in redis key {}".format(
231+
run_image, airgap_key
232+
)
233+
)
234+
run_image_binary_stream = io.BytesIO()
235+
run_image_docker = docker_client.images.get(run_image)
236+
for chunk in run_image_docker.save():
237+
run_image_binary_stream.write(chunk)
238+
# 7 days expire
239+
binary_exp_secs = 24 * 60 * 60 * 7
240+
res_airgap = conn.set(
241+
airgap_key,
242+
run_image_binary_stream.getbuffer(),
243+
ex=binary_exp_secs,
244+
)
245+
logging.info(
246+
"DOCKER AIR GAP: result of set bin data to {}: {}".format(
247+
airgap_key, res_airgap
248+
)
249+
)
250+
215251
compiler = build_config["compiler"]
216252
cpp_compiler = build_config["cpp_compiler"]
217253
build_os = build_config["os"]

redis_benchmarks_specification/__self_contained_coordinator__/args.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,10 @@ def create_self_contained_coordinator_args(project_name):
110110
type=str,
111111
default="https://benchmarksredisio.grafana.net/d/uRPZar57k/ci-profiler-viewer",
112112
)
113+
parser.add_argument(
114+
"--docker-air-gap",
115+
default=False,
116+
action="store_true",
117+
help="Read the docker images from redis keys.",
118+
)
113119
return parser

redis_benchmarks_specification/__self_contained_coordinator__/self_contained_coordinator.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ def main():
186186
consumer_pos = args.consumer_pos
187187
logging.info("Consumer pos {}".format(consumer_pos))
188188

189+
# Docker air gap usage
190+
docker_air_gap = args.docker_air_gap
191+
if docker_air_gap:
192+
logging.info(
193+
"Using docker in an air-gapped way. Restoring running images from redis keys."
194+
)
195+
189196
profilers_list = []
190197
profilers_enabled = args.enable_profilers
191198
if profilers_enabled:
@@ -219,6 +226,7 @@ def main():
219226
cpuset_start_pos,
220227
redis_proc_start_port,
221228
consumer_pos,
229+
docker_air_gap,
222230
)
223231

224232

@@ -266,6 +274,7 @@ def self_contained_coordinator_blocking_read(
266274
cpuset_start_pos=0,
267275
redis_proc_start_port=6379,
268276
consumer_pos=1,
277+
docker_air_gap=False,
269278
):
270279
num_process_streams = 0
271280
num_process_test_suites = 0
@@ -307,6 +316,7 @@ def self_contained_coordinator_blocking_read(
307316
grafana_profile_dashboard,
308317
cpuset_start_pos,
309318
redis_proc_start_port,
319+
docker_air_gap,
310320
)
311321
num_process_streams = num_process_streams + 1
312322
num_process_test_suites = num_process_test_suites + total_test_suite_runs
@@ -374,6 +384,7 @@ def process_self_contained_coordinator_stream(
374384
grafana_profile_dashboard="",
375385
cpuset_start_pos=0,
376386
redis_proc_start_port=6379,
387+
docker_air_gap=False,
377388
):
378389
stream_id = "n/a"
379390
overall_result = False
@@ -398,6 +409,14 @@ def process_self_contained_coordinator_stream(
398409

399410
overall_result = True
400411
profiler_dashboard_links = []
412+
if docker_air_gap:
413+
airgap_key = "docker:air-gap:{}".format(run_image)
414+
logging.info(
415+
"Restoring docker image: {} from {}".format(run_image, airgap_key)
416+
)
417+
airgap_docker_image_bin = conn.get(airgap_key)
418+
images_loaded = docker_client.images.load(airgap_docker_image_bin)
419+
logging.info("Successfully loaded images {}".format(images_loaded))
401420

402421
for test_file in testsuite_spec_files:
403422
redis_containers = []

0 commit comments

Comments
 (0)