From fa837b99f2e275abf2df8fb1f3f90f3312815ae9 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Fri, 23 May 2025 12:56:48 +0200 Subject: [PATCH 01/11] add multiarch mco --- inventory.yaml | 25 ++++++++++++++----------- pipeline.py | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/inventory.yaml b/inventory.yaml index d4beb4137..ac583f0a9 100644 --- a/inventory.yaml +++ b/inventory.yaml @@ -8,10 +8,11 @@ images: vars: context: . template_context: docker/mongodb-kubernetes-operator - platform: linux/amd64 + platform: linux/$(inputs.params.architecture) inputs: - version - log_automation_config_diff + - architecture stages: @@ -22,9 +23,10 @@ images: release_version: $(inputs.params.version) log_automation_config_diff: $(inputs.params.log_automation_config_diff) use_race: "false" + TARGETARCH: $(inputs.params.architecture) output: - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id) + tag: $(inputs.params.version_id)-$(inputs.params.architecture) - name: operator-race-context-dockerfile task_type: docker_build @@ -33,9 +35,10 @@ images: release_version: $(inputs.params.version) log_automation_config_diff: $(inputs.params.log_automation_config_diff) use_race: "true" + TARGETARCH: $(inputs.params.architecture) output: - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id)-race + tag: $(inputs.params.version_id)-race-$(inputs.params.architecture) - name: operator-template-ubi task_type: dockerfile_template @@ -50,39 +53,39 @@ images: task_type: docker_build dockerfile: $(stages['operator-template-ubi'].outputs[0].dockerfile) buildargs: - imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id) + imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id)-$(inputs.params.architecture) output: - registry: $(inputs.params.registry)/mongodb-kubernetes - tag: $(inputs.params.version_id) + tag: $(inputs.params.version_id)-$(inputs.params.architecture) - name: operator-ubi-race-build task_type: docker_build dockerfile: $(stages['operator-template-ubi'].outputs[0].dockerfile) buildargs: - imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id)-race + imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id)-race-$(inputs.params.architecture) output: - registry: $(inputs.params.registry)/mongodb-kubernetes - tag: $(inputs.params.version_id)-race + tag: $(inputs.params.version_id)-race-$(inputs.params.architecture) - name: master-latest task_type: tag_image tags: [ "master" ] source: registry: $(inputs.params.registry)/mongodb-kubernetes - tag: $(inputs.params.version_id) + tag: $(inputs.params.version_id)-$(inputs.params.architecture) destination: - registry: $(inputs.params.registry)/mongodb-kubernetes - tag: latest + tag: latest-$(inputs.params.architecture) - name: operator-context-release task_type: tag_image tags: ["release"] source: registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id) + tag: $(inputs.params.version_id)-$(inputs.params.architecture) destination: - registry: $(inputs.params.quay_registry) - tag: $(inputs.params.version)-context + tag: $(inputs.params.version)-context-$(inputs.params.architecture) - name: operator-template-ubi task_type: dockerfile_template diff --git a/pipeline.py b/pipeline.py index f33f85d1e..7d3900347 100755 --- a/pipeline.py +++ b/pipeline.py @@ -482,7 +482,7 @@ def build_mco_tests_image(build_configuration: BuildConfiguration): sonar_build_image(image_name, build_configuration, buildargs, "inventories/mco_test.yaml") - +TRACER.start_as_current_span("build_operator_image") def build_operator_image(build_configuration: BuildConfiguration): """Calculates arguments required to build the operator image, and starts the build process.""" # In evergreen, we can pass test_suffix env to publish the operator to a quay @@ -491,22 +491,41 @@ def build_operator_image(build_configuration: BuildConfiguration): log_automation_config_diff = os.environ.get("LOG_AUTOMATION_CONFIG_DIFF", "false") version, _ = get_git_release_tag() - args = { - "version": version, - "log_automation_config_diff": log_automation_config_diff, - "test_suffix": test_suffix, - "debug": build_configuration.debug, - } + # Use only amd64 if we should skip arm64 builds + if should_skip_arm64(): + architectures = ["amd64"] + logger.info("Skipping ARM64 builds for operator image as this is running in EVG pipeline as a patch") + else: + architectures = build_configuration.architecture or ["amd64", "arm64"] - logger.info(f"Building Operator args: {args}") + + multi_arch_args_list = [] + + for arch in architectures: + arch_args = { + "version": version, + "log_automation_config_diff": log_automation_config_diff, + "test_suffix": test_suffix, + "debug": build_configuration.debug, + "architecture": arch + } + multi_arch_args_list.append(arch_args) + + logger.info(f"Building Operator args: {multi_arch_args_list}") image_name = "mongodb-kubernetes" + + current_span = trace.get_current_span() + current_span.set_attribute("mck.image_name", image_name) + current_span.set_attribute("mck.architecture", architectures) + build_image_generic( config=build_configuration, image_name=image_name, inventory_file="inventory.yaml", - extra_args=args, registry_address=f"{QUAY_REGISTRY_URL}/{image_name}", + multi_arch_args_list=multi_arch_args_list, + is_multi_arch=True ) From 2e73c65a109f4c1550958333d928f8662d6e534e Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Tue, 17 Jun 2025 16:49:52 +0200 Subject: [PATCH 02/11] remove amend --- pipeline.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pipeline.py b/pipeline.py index 7d3900347..373933777 100755 --- a/pipeline.py +++ b/pipeline.py @@ -313,9 +313,6 @@ def create_and_push_manifest(image: str, tag: str, architectures: list[str]) -> final_manifest, ] - for arch in architectures: - args.extend(["--amend", f"{final_manifest}-{arch}"]) - args_str = " ".join(args) logger.debug(f"creating new manifest: {args_str}") cp = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) From 4fc60c1274d67c15de7c80bcc43d3a5723215c35 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 18 Jun 2025 10:57:43 +0200 Subject: [PATCH 03/11] add missing inventory --- docker/mongodb-kubernetes-operator/Dockerfile.builder | 6 ++++-- inventory.yaml | 2 ++ pipeline.py | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docker/mongodb-kubernetes-operator/Dockerfile.builder b/docker/mongodb-kubernetes-operator/Dockerfile.builder index 019ca7829..5663cf16e 100644 --- a/docker/mongodb-kubernetes-operator/Dockerfile.builder +++ b/docker/mongodb-kubernetes-operator/Dockerfile.builder @@ -9,6 +9,8 @@ FROM public.ecr.aws/docker/library/golang:1.24 as builder ARG release_version ARG log_automation_config_diff ARG use_race +ARG TARGETOS +ARG TARGETARCH COPY go.sum go.mod /go/src/github.com/mongodb/mongodb-kubernetes/ @@ -22,14 +24,14 @@ RUN git version RUN mkdir /build && \ if [ $use_race = "true" ]; then \ echo "Building with race detector" && \ - CGO_ENABLED=1 go build -o /build/mongodb-kubernetes-operator \ + CGO_ENABLED=1 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /build/mongodb-kubernetes-operator \ -buildvcs=false \ -race \ -ldflags=" -X github.com/mongodb/mongodb-kubernetes/pkg/util.OperatorVersion=${release_version} \ -X github.com/mongodb/mongodb-kubernetes/pkg/util.LogAutomationConfigDiff=${log_automation_config_diff}"; \ else \ echo "Building without race detector" && \ - CGO_ENABLED=0 go build -o /build/mongodb-kubernetes-operator \ + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /build/mongodb-kubernetes-operator \ -buildvcs=false \ -ldflags="-s -w -X github.com/mongodb/mongodb-kubernetes/pkg/util.OperatorVersion=${release_version} \ -X github.com/mongodb/mongodb-kubernetes/pkg/util.LogAutomationConfigDiff=${log_automation_config_diff}"; \ diff --git a/inventory.yaml b/inventory.yaml index ac583f0a9..c4384cc93 100644 --- a/inventory.yaml +++ b/inventory.yaml @@ -23,6 +23,7 @@ images: release_version: $(inputs.params.version) log_automation_config_diff: $(inputs.params.log_automation_config_diff) use_race: "false" + TARGETOS: linux TARGETARCH: $(inputs.params.architecture) output: - registry: $(inputs.params.registry)/operator-context @@ -35,6 +36,7 @@ images: release_version: $(inputs.params.version) log_automation_config_diff: $(inputs.params.log_automation_config_diff) use_race: "true" + TARGETOS: linux TARGETARCH: $(inputs.params.architecture) output: - registry: $(inputs.params.registry)/operator-context diff --git a/pipeline.py b/pipeline.py index 373933777..7d3900347 100755 --- a/pipeline.py +++ b/pipeline.py @@ -313,6 +313,9 @@ def create_and_push_manifest(image: str, tag: str, architectures: list[str]) -> final_manifest, ] + for arch in architectures: + args.extend(["--amend", f"{final_manifest}-{arch}"]) + args_str = " ".join(args) logger.debug(f"creating new manifest: {args_str}") cp = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) From b2d573b17c1256659eeaa73d8500ee5b758cd694 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 18 Jun 2025 11:54:38 +0200 Subject: [PATCH 04/11] add missing inventory --- pipeline.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pipeline.py b/pipeline.py index 7d3900347..73fa669d7 100755 --- a/pipeline.py +++ b/pipeline.py @@ -489,7 +489,7 @@ def build_operator_image(build_configuration: BuildConfiguration): # repository with a given suffix. test_suffix = os.environ.get("test_suffix", "") log_automation_config_diff = os.environ.get("LOG_AUTOMATION_CONFIG_DIFF", "false") - version, _ = get_git_release_tag() + version, is_release = get_git_release_tag() # Use only amd64 if we should skip arm64 builds if should_skip_arm64(): @@ -519,11 +519,14 @@ def build_operator_image(build_configuration: BuildConfiguration): current_span.set_attribute("mck.image_name", image_name) current_span.set_attribute("mck.architecture", architectures) + ecr_registry = os.environ.get("BASE_REPO_URL", "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev") + base_repo = QUAY_REGISTRY_URL if is_release else ecr_registry + build_image_generic( config=build_configuration, image_name=image_name, inventory_file="inventory.yaml", - registry_address=f"{QUAY_REGISTRY_URL}/{image_name}", + registry_address=f"{base_repo}/{image_name}", multi_arch_args_list=multi_arch_args_list, is_multi_arch=True ) From d97128defb509e304630714a194a8eeeda190654 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 18 Jun 2025 13:10:07 +0200 Subject: [PATCH 05/11] cleanup inventory --- inventory.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/inventory.yaml b/inventory.yaml index c4384cc93..a14ed3754 100644 --- a/inventory.yaml +++ b/inventory.yaml @@ -16,7 +16,7 @@ images: stages: - - name: operator-context-dockerfile + - name: mongodb-kubernetes-context task_type: docker_build dockerfile: docker/mongodb-kubernetes-operator/Dockerfile.builder buildargs: @@ -26,10 +26,10 @@ images: TARGETOS: linux TARGETARCH: $(inputs.params.architecture) output: - - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id)-$(inputs.params.architecture) + - registry: $(inputs.params.registry)/mongodb-kubernetes + tag: $(inputs.params.version_id)-context-$(inputs.params.architecture) - - name: operator-race-context-dockerfile + - name: operator-race-context task_type: docker_build dockerfile: docker/mongodb-kubernetes-operator/Dockerfile.builder buildargs: @@ -39,8 +39,8 @@ images: TARGETOS: linux TARGETARCH: $(inputs.params.architecture) output: - - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id)-race-$(inputs.params.architecture) + - registry: $(inputs.params.registry)/mongodb-kubernetes + tag: $(inputs.params.version_id)-context-race-$(inputs.params.architecture) - name: operator-template-ubi task_type: dockerfile_template @@ -55,7 +55,7 @@ images: task_type: docker_build dockerfile: $(stages['operator-template-ubi'].outputs[0].dockerfile) buildargs: - imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id)-$(inputs.params.architecture) + imagebase: $(inputs.params.registry)/mongodb-kubernetes:$(inputs.params.version_id)-context-$(inputs.params.architecture) output: - registry: $(inputs.params.registry)/mongodb-kubernetes tag: $(inputs.params.version_id)-$(inputs.params.architecture) @@ -64,7 +64,7 @@ images: task_type: docker_build dockerfile: $(stages['operator-template-ubi'].outputs[0].dockerfile) buildargs: - imagebase: $(inputs.params.registry)/operator-context:$(inputs.params.version_id)-race-$(inputs.params.architecture) + imagebase: $(inputs.params.registry)/mongodb-kubernetes:$(inputs.params.version_id)-context-race-$(inputs.params.architecture) output: - registry: $(inputs.params.registry)/mongodb-kubernetes tag: $(inputs.params.version_id)-race-$(inputs.params.architecture) @@ -79,12 +79,12 @@ images: - registry: $(inputs.params.registry)/mongodb-kubernetes tag: latest-$(inputs.params.architecture) - - name: operator-context-release + - name: mongodb-kubernetes-release task_type: tag_image tags: ["release"] source: - registry: $(inputs.params.registry)/operator-context - tag: $(inputs.params.version_id)-$(inputs.params.architecture) + registry: $(inputs.params.registry)/mongodb-kubernetes + tag: $(inputs.params.version_id)-context-$(inputs.params.architecture) destination: - registry: $(inputs.params.quay_registry) tag: $(inputs.params.version)-context-$(inputs.params.architecture) From 613ac07a3c024fb11ec86c7d5b047fbfeb007047 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 18 Jun 2025 13:58:42 +0200 Subject: [PATCH 06/11] precommit --- ...godb-kubernetes.clusterserviceversion.yaml | 33 ++++++++----------- ...multi_cluster_sharded_disaster_recovery.py | 5 +-- .../om_ops_manager_backup_sharded_cluster.py | 4 +-- .../opsmanager/om_ops_manager_upgrade.py | 4 +-- .../sharded_cluster_migration.py | 5 +-- helm_chart/Chart.yaml | 5 ++- pipeline.py | 8 +++-- 7 files changed, 25 insertions(+), 39 deletions(-) diff --git a/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml index fdde19397..810b0a97d 100644 --- a/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml +++ b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml @@ -8,9 +8,9 @@ metadata: certified: "true" containerImage: quay.io/mongodb/mongodb-kubernetes:1.1.0 createdAt: "" - description: The MongoDB Controllers for Kubernetes enable easy deploys of - MongoDB into Kubernetes clusters, using our management, monitoring and - backup platforms, Ops Manager and Cloud Manager. + description: The MongoDB Controllers for Kubernetes enable easy deploys of MongoDB + into Kubernetes clusters, using our management, monitoring and backup platforms, + Ops Manager and Cloud Manager. features.operators.openshift.io/disconnected: "true" features.operators.openshift.io/fips-compliant: "false" features.operators.openshift.io/proxy-aware: "false" @@ -51,8 +51,7 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: In a Replica Set deployment type, specifies the amount of - members. + - description: In a Replica Set deployment type, specifies the amount of members. displayName: Members of a Replica Set path: members x-descriptors: @@ -66,8 +65,7 @@ spec: - description: Project configuration for this deployment displayName: Ops Manager project configuration path: opsManager - - description: Name of the ConfigMap with the configuration for this - project + - description: Name of the ConfigMap with the configuration for this project displayName: Ops Manager Project Configuration path: opsManager.configMapRef.name x-descriptors: @@ -166,8 +164,7 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: In a Replica Set deployment type, specifies the amount of - members. + - description: In a Replica Set deployment type, specifies the amount of members. displayName: Members of a Replica Set path: members x-descriptors: @@ -181,8 +178,7 @@ spec: - description: Project configuration for this deployment displayName: Ops Manager project configuration path: opsManager - - description: Name of the ConfigMap with the configuration for this - project + - description: Name of the ConfigMap with the configuration for this project displayName: Ops Manager Project Configuration path: opsManager.configMapRef.name x-descriptors: @@ -194,8 +190,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: Optional. Specify whether to duplicate service objects - among different Kubernetes clusters. + - description: Optional. Specify whether to duplicate service objects among + different Kubernetes clusters. displayName: Duplicate Service Objects path: duplicateServiceObjects x-descriptors: @@ -256,8 +252,7 @@ spec: path: passwordSecretKeyRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret - - displayName: Name of the MongoDB resource to which this user is - associated. + - displayName: Name of the MongoDB resource to which this user is associated. path: mongodbResourceRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:mongodb @@ -313,8 +308,8 @@ spec: x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret - urn:alm:descriptor:com.tectonic.ui:fieldGroup:OpsManagerConfiguration - - displayName: Secret to enable TLS for Ops Manager allowing it to serve - traffic over HTTPS. + - displayName: Secret to enable TLS for Ops Manager allowing it to serve traffic + over HTTPS. path: security.tls.secretRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret @@ -324,8 +319,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ApplicationDatabase - - displayName: Secret containing the TLS certificate signed by known or - custom CA. + - displayName: Secret containing the TLS certificate signed by known or custom + CA. path: applicationDatabase.security.tls.secretRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret diff --git a/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py b/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py index 0e119fa57..98df55a6c 100644 --- a/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py +++ b/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py @@ -11,10 +11,7 @@ try_load, update_configmap, ) -from kubetester.kubetester import ( - KubernetesTester, - ensure_ent_version, -) +from kubetester.kubetester import KubernetesTester, ensure_ent_version from kubetester.kubetester import fixture as yaml_fixture from kubetester.kubetester import ( get_env_var_or_fail, diff --git a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py index 97888098d..a6b2d07d2 100644 --- a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py +++ b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py @@ -24,9 +24,7 @@ from tests.shardedcluster.conftest import ( enable_multi_cluster_deployment as enable_multi_cluster_deployment_mdb, ) -from tests.shardedcluster.conftest import ( - get_mongos_service_names, -) +from tests.shardedcluster.conftest import get_mongos_service_names HEAD_PATH = "/head/" S3_SECRET_NAME = "my-s3-secret" diff --git a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py index a40eabaac..7177da9c5 100644 --- a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py +++ b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py @@ -7,9 +7,7 @@ from kubernetes.client.rest import ApiException from kubetester import try_load from kubetester.awss3client import AwsS3Client -from kubetester.kubetester import ( - ensure_ent_version, -) +from kubetester.kubetester import ensure_ent_version from kubetester.kubetester import fixture as yaml_fixture from kubetester.kubetester import ( is_default_architecture_static, diff --git a/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py b/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py index 5a0f7e642..c538db028 100644 --- a/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py +++ b/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py @@ -2,10 +2,7 @@ import pytest from kubernetes import client from kubetester import try_load -from kubetester.kubetester import ( - assert_statefulset_architecture, - ensure_ent_version, -) +from kubetester.kubetester import assert_statefulset_architecture, ensure_ent_version from kubetester.kubetester import fixture as load_fixture from kubetester.kubetester import ( get_default_architecture, diff --git a/helm_chart/Chart.yaml b/helm_chart/Chart.yaml index aadb482da..140da18b8 100644 --- a/helm_chart/Chart.yaml +++ b/helm_chart/Chart.yaml @@ -1,8 +1,7 @@ apiVersion: v2 name: mongodb-kubernetes -description: MongoDB Controllers for Kubernetes translate the human knowledge of - creating a MongoDB instance into a scalable, repeatable, and standardized - method. +description: MongoDB Controllers for Kubernetes translate the human knowledge of creating + a MongoDB instance into a scalable, repeatable, and standardized method. version: 1.1.0 kubeVersion: '>=1.16-0' type: application diff --git a/pipeline.py b/pipeline.py index 73fa669d7..9c24919f7 100755 --- a/pipeline.py +++ b/pipeline.py @@ -482,7 +482,10 @@ def build_mco_tests_image(build_configuration: BuildConfiguration): sonar_build_image(image_name, build_configuration, buildargs, "inventories/mco_test.yaml") + TRACER.start_as_current_span("build_operator_image") + + def build_operator_image(build_configuration: BuildConfiguration): """Calculates arguments required to build the operator image, and starts the build process.""" # In evergreen, we can pass test_suffix env to publish the operator to a quay @@ -498,7 +501,6 @@ def build_operator_image(build_configuration: BuildConfiguration): else: architectures = build_configuration.architecture or ["amd64", "arm64"] - multi_arch_args_list = [] for arch in architectures: @@ -507,7 +509,7 @@ def build_operator_image(build_configuration: BuildConfiguration): "log_automation_config_diff": log_automation_config_diff, "test_suffix": test_suffix, "debug": build_configuration.debug, - "architecture": arch + "architecture": arch, } multi_arch_args_list.append(arch_args) @@ -528,7 +530,7 @@ def build_operator_image(build_configuration: BuildConfiguration): inventory_file="inventory.yaml", registry_address=f"{base_repo}/{image_name}", multi_arch_args_list=multi_arch_args_list, - is_multi_arch=True + is_multi_arch=True, ) From 614ddbb12ab74f6ba9acbcfe0322f4f8bb7abb28 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 18 Jun 2025 15:21:59 +0200 Subject: [PATCH 07/11] isort --- .../multi_cluster_sharded_disaster_recovery.py | 5 ++++- .../opsmanager/om_ops_manager_backup_sharded_cluster.py | 4 +++- .../tests/opsmanager/om_ops_manager_upgrade.py | 4 +++- .../tests/shardedcluster/sharded_cluster_migration.py | 5 ++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py b/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py index 98df55a6c..0e119fa57 100644 --- a/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py +++ b/docker/mongodb-kubernetes-tests/tests/multicluster_shardedcluster/multi_cluster_sharded_disaster_recovery.py @@ -11,7 +11,10 @@ try_load, update_configmap, ) -from kubetester.kubetester import KubernetesTester, ensure_ent_version +from kubetester.kubetester import ( + KubernetesTester, + ensure_ent_version, +) from kubetester.kubetester import fixture as yaml_fixture from kubetester.kubetester import ( get_env_var_or_fail, diff --git a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py index a6b2d07d2..97888098d 100644 --- a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py +++ b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py @@ -24,7 +24,9 @@ from tests.shardedcluster.conftest import ( enable_multi_cluster_deployment as enable_multi_cluster_deployment_mdb, ) -from tests.shardedcluster.conftest import get_mongos_service_names +from tests.shardedcluster.conftest import ( + get_mongos_service_names, +) HEAD_PATH = "/head/" S3_SECRET_NAME = "my-s3-secret" diff --git a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py index 7177da9c5..a40eabaac 100644 --- a/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py +++ b/docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_upgrade.py @@ -7,7 +7,9 @@ from kubernetes.client.rest import ApiException from kubetester import try_load from kubetester.awss3client import AwsS3Client -from kubetester.kubetester import ensure_ent_version +from kubetester.kubetester import ( + ensure_ent_version, +) from kubetester.kubetester import fixture as yaml_fixture from kubetester.kubetester import ( is_default_architecture_static, diff --git a/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py b/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py index c538db028..5a0f7e642 100644 --- a/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py +++ b/docker/mongodb-kubernetes-tests/tests/shardedcluster/sharded_cluster_migration.py @@ -2,7 +2,10 @@ import pytest from kubernetes import client from kubetester import try_load -from kubetester.kubetester import assert_statefulset_architecture, ensure_ent_version +from kubetester.kubetester import ( + assert_statefulset_architecture, + ensure_ent_version, +) from kubetester.kubetester import fixture as load_fixture from kubetester.kubetester import ( get_default_architecture, From f92069a8eb26027ee7b7d2c595c2bdafb0445ee7 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 23 Jun 2025 13:53:29 +0200 Subject: [PATCH 08/11] fix csv --- ...godb-kubernetes.clusterserviceversion.yaml | 33 +++++++++++-------- helm_chart/Chart.yaml | 5 +-- public/mongodb-kubernetes-multi-cluster.yaml | 6 ++-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml index 810b0a97d..fdde19397 100644 --- a/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml +++ b/config/manifests/bases/mongodb-kubernetes.clusterserviceversion.yaml @@ -8,9 +8,9 @@ metadata: certified: "true" containerImage: quay.io/mongodb/mongodb-kubernetes:1.1.0 createdAt: "" - description: The MongoDB Controllers for Kubernetes enable easy deploys of MongoDB - into Kubernetes clusters, using our management, monitoring and backup platforms, - Ops Manager and Cloud Manager. + description: The MongoDB Controllers for Kubernetes enable easy deploys of + MongoDB into Kubernetes clusters, using our management, monitoring and + backup platforms, Ops Manager and Cloud Manager. features.operators.openshift.io/disconnected: "true" features.operators.openshift.io/fips-compliant: "false" features.operators.openshift.io/proxy-aware: "false" @@ -51,7 +51,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: In a Replica Set deployment type, specifies the amount of members. + - description: In a Replica Set deployment type, specifies the amount of + members. displayName: Members of a Replica Set path: members x-descriptors: @@ -65,7 +66,8 @@ spec: - description: Project configuration for this deployment displayName: Ops Manager project configuration path: opsManager - - description: Name of the ConfigMap with the configuration for this project + - description: Name of the ConfigMap with the configuration for this + project displayName: Ops Manager Project Configuration path: opsManager.configMapRef.name x-descriptors: @@ -164,7 +166,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: In a Replica Set deployment type, specifies the amount of members. + - description: In a Replica Set deployment type, specifies the amount of + members. displayName: Members of a Replica Set path: members x-descriptors: @@ -178,7 +181,8 @@ spec: - description: Project configuration for this deployment displayName: Ops Manager project configuration path: opsManager - - description: Name of the ConfigMap with the configuration for this project + - description: Name of the ConfigMap with the configuration for this + project displayName: Ops Manager Project Configuration path: opsManager.configMapRef.name x-descriptors: @@ -190,8 +194,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ClusterConfiguration - - description: Optional. Specify whether to duplicate service objects among - different Kubernetes clusters. + - description: Optional. Specify whether to duplicate service objects + among different Kubernetes clusters. displayName: Duplicate Service Objects path: duplicateServiceObjects x-descriptors: @@ -252,7 +256,8 @@ spec: path: passwordSecretKeyRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret - - displayName: Name of the MongoDB resource to which this user is associated. + - displayName: Name of the MongoDB resource to which this user is + associated. path: mongodbResourceRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:mongodb @@ -308,8 +313,8 @@ spec: x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret - urn:alm:descriptor:com.tectonic.ui:fieldGroup:OpsManagerConfiguration - - displayName: Secret to enable TLS for Ops Manager allowing it to serve traffic - over HTTPS. + - displayName: Secret to enable TLS for Ops Manager allowing it to serve + traffic over HTTPS. path: security.tls.secretRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret @@ -319,8 +324,8 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:number - urn:alm:descriptor:com.tectonic.ui:fieldGroup:ApplicationDatabase - - displayName: Secret containing the TLS certificate signed by known or custom - CA. + - displayName: Secret containing the TLS certificate signed by known or + custom CA. path: applicationDatabase.security.tls.secretRef.name x-descriptors: - urn:alm:descriptor:io.kubernetes:Secret diff --git a/helm_chart/Chart.yaml b/helm_chart/Chart.yaml index 140da18b8..aadb482da 100644 --- a/helm_chart/Chart.yaml +++ b/helm_chart/Chart.yaml @@ -1,7 +1,8 @@ apiVersion: v2 name: mongodb-kubernetes -description: MongoDB Controllers for Kubernetes translate the human knowledge of creating - a MongoDB instance into a scalable, repeatable, and standardized method. +description: MongoDB Controllers for Kubernetes translate the human knowledge of + creating a MongoDB instance into a scalable, repeatable, and standardized + method. version: 1.1.0 kubeVersion: '>=1.16-0' type: application diff --git a/public/mongodb-kubernetes-multi-cluster.yaml b/public/mongodb-kubernetes-multi-cluster.yaml index 4873bd563..bb03b179f 100644 --- a/public/mongodb-kubernetes-multi-cluster.yaml +++ b/public/mongodb-kubernetes-multi-cluster.yaml @@ -71,7 +71,8 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-mongodb-role-binding + name: + mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-mongodb-role-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -100,7 +101,8 @@ subjects: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-telemetry-binding + name: + mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-telemetry-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole From 0bb1c76dc6b799c5ecdfdc48db54c4d6136c7d61 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Mon, 23 Jun 2025 14:11:34 +0200 Subject: [PATCH 09/11] remove trailing commas and set consistent yaml width --- public/mongodb-kubernetes-multi-cluster.yaml | 6 ++---- scripts/evergreen/release/helm_files_handler.py | 1 + scripts/evergreen/release/update_helm_values_files.py | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/public/mongodb-kubernetes-multi-cluster.yaml b/public/mongodb-kubernetes-multi-cluster.yaml index bb03b179f..4873bd563 100644 --- a/public/mongodb-kubernetes-multi-cluster.yaml +++ b/public/mongodb-kubernetes-multi-cluster.yaml @@ -71,8 +71,7 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: - mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-mongodb-role-binding + name: mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-mongodb-role-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -101,8 +100,7 @@ subjects: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: - mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-telemetry-binding + name: mongodb-kubernetes-operator-multi-cluster-mongodb-cluster-telemetry-binding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/scripts/evergreen/release/helm_files_handler.py b/scripts/evergreen/release/helm_files_handler.py index 69b8b9927..9c70306db 100644 --- a/scripts/evergreen/release/helm_files_handler.py +++ b/scripts/evergreen/release/helm_files_handler.py @@ -78,6 +78,7 @@ def update_standalone_installer(yaml_file_path: str, version: str): yaml.explicit_start = True # Ensure explicit `---` in the output yaml.indent(mapping=2, sequence=4, offset=2) # Align with tab width produced by Helm yaml.preserve_quotes = True # Preserve original quotes in the YAML file + yaml.width = 4096 # Set a very large line width to prevent inconsistent line wrapping with open(yaml_file_path, "r") as fd: data = list(yaml.load_all(fd)) # Convert the generator to a list diff --git a/scripts/evergreen/release/update_helm_values_files.py b/scripts/evergreen/release/update_helm_values_files.py index a1657856a..bf7f43b37 100755 --- a/scripts/evergreen/release/update_helm_values_files.py +++ b/scripts/evergreen/release/update_helm_values_files.py @@ -57,9 +57,9 @@ def main() -> int: def update_standalone(operator_version): - update_standalone_installer("public/mongodb-kubernetes.yaml", operator_version), - update_standalone_installer("public/mongodb-kubernetes-openshift.yaml", operator_version), - update_standalone_installer("public/mongodb-kubernetes-multi-cluster.yaml", operator_version), + update_standalone_installer("public/mongodb-kubernetes.yaml", operator_version) + update_standalone_installer("public/mongodb-kubernetes-openshift.yaml", operator_version) + update_standalone_installer("public/mongodb-kubernetes-multi-cluster.yaml", operator_version) def update_helm_charts(operator_version, release): From 751a850fd25c02374619f600a333797ffb666ed5 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 2 Jul 2025 13:33:56 +0200 Subject: [PATCH 10/11] fix pipeline for race --- inventory.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inventory.yaml b/inventory.yaml index a14ed3754..d263e13cd 100644 --- a/inventory.yaml +++ b/inventory.yaml @@ -60,6 +60,7 @@ images: - registry: $(inputs.params.registry)/mongodb-kubernetes tag: $(inputs.params.version_id)-$(inputs.params.architecture) + # we don't do multi-arch for race images; so we can just directly release it - name: operator-ubi-race-build task_type: docker_build dockerfile: $(stages['operator-template-ubi'].outputs[0].dockerfile) @@ -67,7 +68,7 @@ images: imagebase: $(inputs.params.registry)/mongodb-kubernetes:$(inputs.params.version_id)-context-race-$(inputs.params.architecture) output: - registry: $(inputs.params.registry)/mongodb-kubernetes - tag: $(inputs.params.version_id)-race-$(inputs.params.architecture) + tag: $(inputs.params.version_id)-race - name: master-latest task_type: tag_image From 71bbd32811f3aaa2e4d852c35c6955928ade8886 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Wed, 2 Jul 2025 13:46:33 +0200 Subject: [PATCH 11/11] fix pipeline for race --- pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipeline.py b/pipeline.py index c841e9937..4777b5eb4 100755 --- a/pipeline.py +++ b/pipeline.py @@ -495,7 +495,7 @@ def build_operator_image(build_configuration: BuildConfiguration): version, is_release = get_git_release_tag() # Use only amd64 if we should skip arm64 builds - if should_skip_arm64(): + if should_skip_arm64(build_configuration): architectures = ["amd64"] logger.info("Skipping ARM64 builds for operator image as this is running in EVG pipeline as a patch") else: