@@ -305,19 +305,19 @@ def copy_into_container(client, src, dst):
305
305
# Sonar as an interface to docker. We decided to keep this asymmetry for now, as Sonar will be removed soon.
306
306
307
307
308
- def create_and_push_manifest (image : str , tag : str ) -> None :
308
+ def create_and_push_manifest (image : str , tag : str , architectures : list [ str ] ) -> None :
309
309
final_manifest = image + ":" + tag
310
310
311
311
args = [
312
312
"docker" ,
313
313
"manifest" ,
314
314
"create" ,
315
315
final_manifest ,
316
- "--amend" ,
317
- final_manifest + "-amd64" ,
318
- "--amend" ,
319
- final_manifest + "-arm64" ,
320
316
]
317
+
318
+ for arch in architectures :
319
+ args .extend (["--amend" , f"{ final_manifest } -{ arch } " ])
320
+
321
321
args_str = " " .join (args )
322
322
logger .debug (f"creating new manifest: { args_str } " )
323
323
cp = subprocess .run (args , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
@@ -752,6 +752,14 @@ def submit(self, fn, *args, **kwargs):
752
752
"""
753
753
754
754
755
+ def should_skip_arm64 ():
756
+ """
757
+ Determines if arm64 builds should be skipped based on environment.
758
+ Returns True if running in Evergreen pipeline as a patch.
759
+ """
760
+ return is_running_in_evg_pipeline () and is_running_in_patch ()
761
+
762
+
755
763
def build_image_daily (
756
764
image_name : str , # corresponds to the image_name in the release.json
757
765
min_version : str = None ,
@@ -766,6 +774,10 @@ def get_architectures_set(build_configuration, args):
766
774
if arch_set == {"arm64" }:
767
775
raise ValueError ("Building for ARM64 only is not supported yet" )
768
776
777
+ if should_skip_arm64 ():
778
+ logger .info ("Skipping ARM64 builds as this is running in EVG pipeline as a patch" )
779
+ return {"amd64" }
780
+
769
781
# Automatic architecture detection is the default behavior if 'arch' argument isn't specified
770
782
if arch_set == set ():
771
783
if check_multi_arch (
@@ -779,13 +791,13 @@ def get_architectures_set(build_configuration, args):
779
791
780
792
return arch_set
781
793
782
- def create_and_push_manifests (args : dict ):
794
+ def create_and_push_manifests (args : dict , architectures : list [ str ] ):
783
795
"""Create and push manifests for all registries."""
784
796
registries = [args ["ecr_registry_ubi" ], args ["quay_registry" ]]
785
797
tags = [args ["release_version" ], args ["release_version" ] + "-b" + args ["build_id" ]]
786
798
for registry in registries :
787
799
for tag in tags :
788
- create_and_push_manifest (registry + args ["ubi_suffix" ], tag )
800
+ create_and_push_manifest (registry + args ["ubi_suffix" ], tag , architectures = architectures )
789
801
790
802
def sign_image_concurrently (executor , args , futures , arch = None ):
791
803
v = args ["release_version" ]
@@ -838,7 +850,7 @@ def inner(build_configuration: BuildConfiguration):
838
850
)
839
851
if build_configuration .sign :
840
852
sign_image_concurrently (executor , copy .deepcopy (args ), futures , arch )
841
- create_and_push_manifests (args )
853
+ create_and_push_manifests (args , list ( arch_set ) )
842
854
for arch in arch_set :
843
855
args ["architecture_suffix" ] = f"-{ arch } "
844
856
args ["platform" ] = arch
@@ -985,12 +997,13 @@ def build_image_generic(
985
997
if is_multi_arch :
986
998
# we only push the manifests of the context images here,
987
999
# since daily rebuilds will push the manifests for the proper images later
988
- create_and_push_manifest (registry_address , f"{ version } -context" )
1000
+ architectures = [v ["architecture" ] for v in multi_arch_args_list ]
1001
+ create_and_push_manifest (registry_address , f"{ version } -context" , architectures = architectures )
989
1002
if not config .is_release_step_executed ():
990
1003
# Normally daily rebuild would create and push the manifests for the non-context images.
991
1004
# But since we don't run daily rebuilds on ecr image builds, we can do that step instead here.
992
1005
# We only need to push manifests for multi-arch images.
993
- create_and_push_manifest (registry_address , version )
1006
+ create_and_push_manifest (registry_address , version , architectures = architectures )
994
1007
if config .sign and config .is_release_step_executed ():
995
1008
sign_and_verify_context_image (registry , version )
996
1009
if config .is_release_step_executed () and version and QUAY_REGISTRY_URL in registry :
@@ -1044,7 +1057,14 @@ def build_community_image(build_configuration: BuildConfiguration, image_type: s
1044
1057
1045
1058
version , is_release = get_git_release_tag ()
1046
1059
golang_version = os .getenv ("GOLANG_VERSION" , "1.24" )
1047
- architectures = build_configuration .architecture or ["amd64" , "arm64" ]
1060
+
1061
+ # Use only amd64 if we should skip arm64 builds
1062
+ if should_skip_arm64 ():
1063
+ architectures = ["amd64" ]
1064
+ logger .info ("Skipping ARM64 builds for community image as this is running in EVG pipeline as a patch" )
1065
+ else :
1066
+ architectures = build_configuration .architecture or ["amd64" , "arm64" ]
1067
+
1048
1068
multi_arch_args_list = []
1049
1069
1050
1070
for arch in architectures :
@@ -1064,7 +1084,7 @@ def build_community_image(build_configuration: BuildConfiguration, image_type: s
1064
1084
multi_arch_args_list = multi_arch_args_list ,
1065
1085
inventory_file = inventory_file ,
1066
1086
registry_address = f"{ base_repo } /{ image_name } " ,
1067
- is_multi_arch = True ,
1087
+ is_multi_arch = True , # We for pushing manifest anyway, even if arm64 is skipped in patches
1068
1088
)
1069
1089
1070
1090
@@ -1151,16 +1171,19 @@ def build_multi_arch_agent_in_sonar(
1151
1171
ecr_registry = os .environ .get ("REGISTRY" , "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev" )
1152
1172
ecr_agent_registry = ecr_registry + f"/mongodb-agent-ubi"
1153
1173
quay_agent_registry = QUAY_REGISTRY_URL + f"/mongodb-agent-ubi"
1154
- joined_args = list ()
1155
- for arch in [arch_arm , arch_amd ]:
1156
- joined_args .append (args | arch )
1174
+ joined_args = [arch_amd ]
1175
+
1176
+ # Only include arm64 if we shouldn't skip it
1177
+ if not should_skip_arm64 ():
1178
+ joined_args .append (arch_arm )
1179
+
1157
1180
build_image_generic (
1158
1181
config = build_configuration ,
1159
1182
image_name = "mongodb-agent" ,
1160
1183
inventory_file = "inventories/agent_non_matrix.yaml" ,
1161
1184
multi_arch_args_list = joined_args ,
1162
1185
registry_address = quay_agent_registry if is_release else ecr_agent_registry ,
1163
- is_multi_arch = True ,
1186
+ is_multi_arch = True , # We for pushing manifest anyway, even if arm64 is skipped in patches
1164
1187
is_run_in_parallel = True ,
1165
1188
)
1166
1189
0 commit comments