1
1
#!/usr/bin/env python3
2
2
3
- """This pipeline script knows about the details of our Docker images
4
- and where to fetch and calculate parameters. It uses Sonar.py
5
- to produce the final images."""
3
+ """This atomic_pipeline script knows about the details of our Docker images
4
+ and where to fetch and calculate parameters."""
6
5
import json
7
6
import os
8
7
import shutil
22
21
verify_signature ,
23
22
)
24
23
from scripts .release .build .image_build_configuration import ImageBuildConfiguration
25
- from .build_images import process_image
24
+ from scripts .release .build .image_build_process import build_image
25
+
26
26
from .optimized_operator_build import build_operator_image_fast
27
27
28
28
TRACER = trace .get_tracer ("evergreen-agent" )
@@ -36,10 +36,6 @@ def get_tools_distro(tools_version: str) -> Dict[str, str]:
36
36
return default_distro
37
37
38
38
39
- def is_running_in_evg_pipeline ():
40
- return os .getenv ("RUNNING_IN_EVG" , "" ) == "true"
41
-
42
-
43
39
def load_release_file () -> Dict :
44
40
with open ("release.json" ) as release :
45
41
return json .load (release )
@@ -59,27 +55,37 @@ def pipeline_process_image(
59
55
if dockerfile_args :
60
56
span .set_attribute ("mck.build_args" , str (dockerfile_args ))
61
57
62
- logger .info (f"Dockerfile args: { dockerfile_args } , for image: { image_name } " )
63
-
64
58
if not dockerfile_args :
65
59
dockerfile_args = {}
66
- logger .debug (f"Build args: { dockerfile_args } " )
67
- process_image (
60
+ logger .info (f"Dockerfile args: { dockerfile_args } , for image: { image_name } " )
61
+
62
+ build_image (
68
63
image_tag = build_configuration .version ,
69
64
dockerfile_path = dockerfile_path ,
70
65
dockerfile_args = dockerfile_args ,
71
66
registry = build_configuration .registry ,
72
67
platforms = build_configuration .platforms ,
73
- sign = build_configuration .sign ,
74
68
build_path = build_path ,
75
69
)
76
70
71
+ if build_configuration .sign :
72
+ pipeline_sign_image (
73
+ registry = build_configuration .registry ,
74
+ version = build_configuration .version ,
75
+ )
76
+
77
+
78
+ @TRACER .start_as_current_span ("sign_image_in_repositories" )
79
+ def pipeline_sign_image (registry : str , version : str ):
80
+ logger .info ("Signing image" )
81
+ sign_image (registry , version )
82
+ verify_signature (registry , version )
83
+
77
84
78
85
def build_tests_image (build_configuration : ImageBuildConfiguration ):
79
86
"""
80
87
Builds image used to run tests.
81
88
"""
82
- image_name = "mongodb-kubernetes-tests"
83
89
84
90
# helm directory needs to be copied over to the tests docker context.
85
91
helm_src = "helm_chart"
@@ -170,20 +176,6 @@ def build_database_image(build_configuration: ImageBuildConfiguration):
170
176
)
171
177
172
178
173
- @TRACER .start_as_current_span ("sign_image_in_repositories" )
174
- def sign_image_in_repositories (args : Dict [str , str ], arch : str = None ):
175
- span = trace .get_current_span ()
176
- repository = args ["quay_registry" ] + args ["ubi_suffix" ]
177
- tag = args ["release_version" ]
178
- if arch :
179
- tag = f"{ tag } -{ arch } "
180
-
181
- span .set_attribute ("mck.tag" , tag )
182
-
183
- sign_image (repository , tag )
184
- verify_signature (repository , tag )
185
-
186
-
187
179
def find_om_in_releases (om_version : str , releases : Dict [str , str ]) -> Optional [str ]:
188
180
"""
189
181
There are a few alternatives out there that allow for json-path or xpath-type
@@ -257,43 +249,12 @@ def build_om_image(build_configuration: ImageBuildConfiguration):
257
249
)
258
250
259
251
260
- def build_image_generic (
261
- dockerfile_path : str ,
262
- build_configuration : ImageBuildConfiguration ,
263
- extra_args : dict | None = None ,
264
- ):
265
- """
266
- Build one or more platform-specific images, then (optionally)
267
- push a manifest and sign the result.
268
- """
269
-
270
- registry = build_configuration .registry
271
- image_name = build_configuration .image_name ()
272
- args_list = extra_args or {}
273
- version = args_list .get ("version" , "" )
274
-
275
- # merge in the registry without mutating caller’s dict
276
- build_args = {** args_list , "quay_registry" : registry }
277
- logger .debug (f"Build args: { build_args } " )
278
-
279
- logger .debug (f"Building { image_name } for platforms={ build_configuration .platforms } " )
280
- logger .debug (f"build image generic - registry={ registry } " )
281
- pipeline_process_image (
282
- dockerfile_path = dockerfile_path ,
283
- build_configuration = build_configuration ,
284
- dockerfile_args = build_args ,
285
- )
286
-
287
- if build_configuration .sign :
288
- sign_image (registry , version )
289
- verify_signature (registry , version )
290
-
291
-
292
252
def build_init_appdb (build_configuration : ImageBuildConfiguration ):
293
253
release = load_release_file ()
294
254
base_url = "https://fastdl.mongodb.org/tools/db/"
295
255
mongodb_tools_url_ubi = "{}{}" .format (base_url , release ["mongodbToolsBundle" ]["ubi" ])
296
256
args = {"version" : build_configuration .version , "mongodb_tools_url_ubi" : mongodb_tools_url_ubi }
257
+
297
258
pipeline_process_image (
298
259
dockerfile_path = "docker/mongodb-kubernetes-init-appdb/Dockerfile" ,
299
260
build_configuration = build_configuration ,
@@ -326,10 +287,10 @@ def build_readiness_probe_image(build_configuration: ImageBuildConfiguration):
326
287
"GOLANG_VERSION" : golang_version ,
327
288
}
328
289
329
- build_image_generic (
290
+ pipeline_process_image (
330
291
dockerfile_path = "docker/mongodb-kubernetes-readinessprobe/Dockerfile" ,
331
292
build_configuration = build_configuration ,
332
- extra_args = extra_args ,
293
+ dockerfile_args = extra_args ,
333
294
)
334
295
335
296
@@ -345,10 +306,10 @@ def build_upgrade_hook_image(build_configuration: ImageBuildConfiguration):
345
306
"GOLANG_VERSION" : golang_version ,
346
307
}
347
308
348
- build_image_generic (
309
+ pipeline_process_image (
349
310
dockerfile_path = "docker/mongodb-kubernetes-upgrade-hook/Dockerfile" ,
350
311
build_configuration = build_configuration ,
351
- extra_args = extra_args ,
312
+ dockerfile_args = extra_args ,
352
313
)
353
314
354
315
@@ -373,13 +334,13 @@ def build_agent_pipeline(
373
334
"init_database_image" : init_database_image ,
374
335
"mongodb_tools_url_ubi" : mongodb_tools_url_ubi ,
375
336
"mongodb_agent_url_ubi" : mongodb_agent_url_ubi ,
376
- "quay_registry" : build_configuration .registry ,
337
+ "quay_registry" : build_configuration_copy .registry ,
377
338
}
378
339
379
- build_image_generic (
340
+ pipeline_process_image (
380
341
dockerfile_path = "docker/mongodb-agent/Dockerfile" ,
381
342
build_configuration = build_configuration_copy ,
382
- extra_args = args ,
343
+ dockerfile_args = args ,
383
344
)
384
345
385
346
0 commit comments