Skip to content

Commit da6c026

Browse files
authored
CLOUDP-338084 - removing and refactoring agent matrix from pipeline.py and atomic_pipeline.py (#346)
# Summary ## Why we do this - since we don't do an agent matrix release anymore, there is no need to release all the agents we see on `release.json`. Instead we should only release the agent if PCT adds a new agent. That happens during OM and CM bumps, the new detection script should handle this and release the images ## What changes - adding a detection script that detects agent changes between `local` vs `origin/master` for `release.json` and uses that as a base to do the release - streamline evergreen.yml and remove matrix builds/releases - streamline agent builds on pipeline.py **Evergreen configuration cleanup and simplification:** * Removed obsolete tasks and buildvariants related to agent image releases, such as `release_agent_operator_release`, `release_agents_on_ecr_conditional`, and `init_release_agents_on_ecr`, to streamline the release process. **Pipeline logic refactoring:** * Refactored the `build_agent_default_case` function in `pipeline.py` to use the new `detect_ops_manager_changes` function for determining which agent versions to build, and eliminated the separate `build_agent_on_agent_bump` logic. * Simplified agent in `pipeline.py` to match `atomic_pipeline.py` * Updated the image builder function mapping so that both `"agent"` and `"agent-pct"` use the unified `build_agent_default_case` function. ## Proof of Work - no agent needed to be released - patch: [Link](https://spruce.mongodb.com/task/mongodb_kubernetes_init_test_run_build_agent_images_ubi_patch_0786a90d4034657a11c9289e917c62691bc2500f_689da41126d25300077a269a_25_08_14_08_53_40/logs?execution=0) ``` [2025/08/14 10:56:13.642] === Detecting OM Mapping Changes (Local vs Base) === [2025/08/14 10:56:13.643] INFO 2025-08-14 08:56:13,642 [atomic_pipeline] No changes detected, skipping agent build [2025/08/14 10:56:13.725] Finished command 'subprocess.exec' in function 'pipeline' (step 3.5 of 3) in 4.209554597s. ``` - manual changing release.json ([the changeset, its a manual rsynced patch](https://evergreen.mongodb.com/filediff/689e037a1e4cc8000785a0fd/?file_name=release.json&patch_number=0&commit_number=4)), leading to an agent release/build. Note; the task is not passing because I am releasing a non existant image -[Link](https://spruce.mongodb.com/task/mongodb_kubernetes_init_test_run_build_agent_images_ubi_patch_f0df6f42547f5602c5c4ab120d1d7e3d0db05797_689e037a1e4cc8000785a0fd_25_08_14_15_40_44/logs?execution=0) ``` [2025/08/14 17:42:50.558] INFO 2025-08-14 15:42:50,558 [atomic_pipeline] ======= Agent versions to build [('13.30.0.9590-1', '100.12.2')] ======= [2025/08/14 17:42:50.558] INFO 2025-08-14 15:42:50,558 [atomic_pipeline] ======= Building Agent ('13.30.0.9590- ``` - cm bump worked with this changeset [link](#311) + [the related patch](https://spruce.mongodb.com/task/mongodb_kubernetes_init_test_run_build_agent_images_ubi_patch_f0df6f42547f5602c5c4ab120d1d7e3d0db05797_689dcf5b0e81480007929ddc_25_08_14_11_58_22/logs?execution=0) - this caused in init_test_run agent build to release the agent to ecr as release.json has changed ``` [2025/08/14 13:59:35.068] === Detecting OM Mapping Changes (Local vs Base) === [2025/08/14 13:59:35.068] INFO 2025-08-14 11:59:35,067 [atomic_pipeline] Building Agent versions: [('13.38.0.9654-1', '100.12.2')] [2025/08/14 13:59:35.068] INFO 2025-08-14 11:59:35,068 [atomic_pipeline] Running with factor of None [2025/08/14 13:59:35.068] INFO 2025-08-14 11:59:35,068 [atomic_pipeline] ======= Agent versions to build [('13.38.0.9654-1', '100.12.2')] ======= [2025/08/14 13:59:35.068] INFO 2025-08-14 11:59:35,068 [atomic_pipeline] ======= Building Agent ('13.38.0.9654-1', '100.12.2') (0/1) ``` - we have a dedicated variant that can also release all agents: [link](https://parsley.mongodb.com/evergreen/mongodb_kubernetes_manual_ecr_release_agent_release_all_agents_on_ecr_patch_0786a90d4034657a11c9289e917c62691bc2500f_689dea314fcada00075dd3c4_25_08_14_13_52_51/0/task?bookmarks=0,6038) ### Example Cases **A new OM/CM bump workflow** - publish_om/cm and release_agent variants are getting triggered - detection script detects a change in release.json - release the new agent ## Checklist - [x] Have you linked a jira ticket and/or is the ticket in the title? - [x] Have you checked whether your jira ticket required DOCSP changes? - [x] Have you added changelog file? - use `skip-changelog` label if not needed - refer to [Changelog files and Release Notes](https://github.com/mongodb/mongodb-kubernetes/blob/master/CONTRIBUTING.md#changelog-files-and-release-notes) section in CONTRIBUTING.md for more details
1 parent 60b9bb0 commit da6c026

11 files changed

+516
-355
lines changed

.evergreen-functions.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -517,30 +517,14 @@ functions:
517517
# docker buildx needs the moby/buildkit image when setting up a builder so we pull it from our mirror
518518
docker buildx create --driver=docker-container --driver-opt=image=268558157000.dkr.ecr.eu-west-1.amazonaws.com/docker-hub-mirrors/moby/buildkit:buildx-stable-1 --use
519519
docker buildx inspect --bootstrap
520-
- command: ec2.assume_role
521-
display_name: Assume IAM role with permissions to pull Kondukto API token
522-
params:
523-
role_arn: ${kondukto_role_arn}
524-
- command: shell.exec
525-
display_name: Pull Kondukto API token from AWS Secrets Manager and write it to file
526-
params:
527-
silent: true
528-
shell: bash
529-
include_expansions_in_env: [AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN]
530-
script: |
531-
set -e
532-
# use AWS CLI to get the Kondukto API token from AWS Secrets Manager
533-
kondukto_token=$(aws secretsmanager get-secret-value --secret-id "kondukto-token" --region "us-east-1" --query 'SecretString' --output text)
534-
# write the KONDUKTO_TOKEN environment variable to Silkbomb environment file
535-
echo "KONDUKTO_TOKEN=$kondukto_token" > ${workdir}/silkbomb.env
536520
- command: subprocess.exec
537521
retry_on_failure: true
538522
type: setup
539523
params:
540524
shell: bash
541525
<<: *e2e_include_expansions_in_env
542526
working_dir: src/github.com/mongodb/mongodb-kubernetes
543-
binary: scripts/dev/run_python.sh scripts/release/pipeline_main.py --parallel ${image_name}
527+
binary: scripts/dev/run_python.sh scripts/release/pipeline_main.py --parallel ${image_name} ${all_agents}
544528

545529
# TODO: CLOUDP-335471 ; once all image builds are made with the new atomic pipeline, remove the following function
546530
legacy_pipeline:

.evergreen.yml

Lines changed: 17 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ variables:
6161
variant: init_test_run
6262
- name: build_test_image
6363
variant: init_test_run
64-
- name: build_agent_images_ubi
65-
variant: init_test_run
6664
- name: build_readiness_probe_image
6765
variant: init_test_run
6866
- name: build_upgrade_hook_image
6967
variant: init_test_run
7068
- name: build_mco_test_image
7169
variant: init_test_run
70+
- name: build_agent_images_ubi
71+
variant: init_test_run
7272

7373
- &setup_group
7474
setup_group_can_fail_task: true
@@ -347,19 +347,6 @@ tasks:
347347
image_name: init-ops-manager
348348
include_tags: release
349349

350-
- name: release_agent_operator_release
351-
tags: [ "image_release" ]
352-
allowed_requesters: [ "patch", "github_tag" ]
353-
commands:
354-
- func: clone
355-
- func: setup_building_host
356-
- func: quay_login
357-
- func: setup_docker_sbom
358-
- func: legacy_pipeline
359-
vars:
360-
image_name: agent
361-
include_tags: release
362-
363350
# pct only triggers this variant once a new agent image is out
364351
- name: release_agent
365352
# this enables us to run this variant either manually (patch) which pct does or during an OM bump (github_pr)
@@ -371,8 +358,7 @@ tasks:
371358
- func: setup_docker_sbom
372359
- func: legacy_pipeline
373360
vars:
374-
image_name: agent-pct
375-
include_tags: release
361+
image_name: agent
376362

377363
- name: run_precommit_and_push
378364
tags: ["patch-run"]
@@ -392,48 +378,17 @@ tasks:
392378
working_dir: src/github.com/mongodb/mongodb-kubernetes
393379
binary: scripts/evergreen/precommit_bump.sh
394380

395-
# Pct only triggers this variant once a new agent image is out
396-
# these releases the agent with the operator suffix (not patch id) on ecr to allow for digest pinning to pass.
397-
# For this to work, we rely on skip_tags which is used to determine whether
398-
# we want to release on quay or not, in this case - ecr instead.
399-
# We rely on the init_database from ecr for the agent x operator images.
400-
# This runs on agent releases that are not concurrent with operator releases.
401-
- name: release_agents_on_ecr_conditional
402-
commands:
403-
- func: clone
404-
- func: run_task_conditionally
405-
vars:
406-
condition_script: scripts/evergreen/should_release_agents_on_ecr.sh
407-
variant: init_release_agents_on_ecr
408-
task: release_agents_on_ecr
409-
410-
- name: release_agents_on_ecr
411-
# this enables us to run this variant either manually (patch) which pct does or during an OM bump (github_pr)
412-
allowed_requesters: [ "patch", "github_pr" ]
413-
priority: 70
414-
commands:
415-
- func: clone
416-
- func: setup_building_host
417-
- func: legacy_pipeline
418-
vars:
419-
image_name: agent-pct
420-
skip_tags: release
421-
422381
- name: release_all_agents_on_ecr
423-
# this enables us to run this manually (patch) and release all agent versions to ECR
424-
# it's needed during operator new version release process - e2e tests (especially olm tests)
425-
# will look for agent with new operator version suffix, but during PR checks we only build
426-
# agent versions for most recent major OM versions and the tests will fail. Before running the PR
427-
# we have to manually release all agents to ECR by triggering this patch
382+
# this enables us to run this manually (patch) and release all agent versions to ECR to verify
383+
# Dockerfile, script changes etc.
428384
allowed_requesters: [ "patch" ]
429385
commands:
430386
- func: clone
431387
- func: setup_building_host
432-
- func: legacy_pipeline
388+
- func: pipeline
433389
vars:
434-
image_name: agent-pct
435-
skip_tags: release
436-
all_agents: true
390+
image_name: agent
391+
all_agents: "--all-agents"
437392

438393
- name: build_test_image
439394
commands:
@@ -1334,8 +1289,7 @@ buildvariants:
13341289
variant: init_test_run
13351290
- name: build_init_database_image_ubi
13361291
variant: init_test_run
1337-
- name: build_agent_images_ubi
1338-
variant: init_test_run
1292+
13391293
tasks:
13401294
- name: e2e_custom_domain_task_group
13411295

@@ -1369,8 +1323,7 @@ buildvariants:
13691323
variant: init_test_run
13701324
- name: build_init_database_image_ubi
13711325
variant: init_test_run
1372-
- name: build_agent_images_ubi
1373-
variant: init_test_run
1326+
13741327
run_on:
13751328
- ubuntu2204-small
13761329
tasks:
@@ -1594,6 +1547,8 @@ buildvariants:
15941547
variant: init_test_run
15951548
- name: prepare_and_upload_openshift_bundles_for_e2e
15961549
variant: init_tests_with_olm
1550+
- name: build_agent_images_ubi
1551+
variant: init_test_run
15971552
tasks:
15981553
- name: e2e_kind_olm_group
15991554

@@ -1619,6 +1574,7 @@ buildvariants:
16191574
variant: init_test_run
16201575
- name: build_agent_images_ubi
16211576
variant: init_test_run
1577+
16221578
tasks:
16231579
- name: e2e_kind_olm_group
16241580

@@ -1683,18 +1639,6 @@ buildvariants:
16831639
- name: build_upgrade_hook_image
16841640
- name: prepare_aws
16851641

1686-
- name: init_release_agents_on_ecr
1687-
display_name: init_release_agents_on_ecr
1688-
# this enables us to run this variant either manually (patch) which pct does or during an OM bump (github_pr)
1689-
allowed_requesters: [ "patch", "github_pr" ]
1690-
tags: [ "release_agents_on_ecr" ]
1691-
# We want that to run first and finish asap. Digest pinning depends on this to succeed.
1692-
priority: 70
1693-
run_on:
1694-
- ubuntu2204-large
1695-
tasks:
1696-
- name: release_agents_on_ecr_conditional
1697-
16981642
- name: run_pre_commit
16991643
priority: 70
17001644
display_name: run_pre_commit
@@ -1722,8 +1666,7 @@ buildvariants:
17221666
variant: init_test_run
17231667
- name: build_init_om_images_ubi
17241668
variant: init_test_run
1725-
- name: build_agent_images_ubi
1726-
variant: init_test_run
1669+
17271670
run_on:
17281671
- ubuntu2204-small
17291672
tasks:
@@ -1809,13 +1752,6 @@ buildvariants:
18091752
- name: release_init_database
18101753
- name: release_init_ops_manager
18111754
- name: release_database
1812-
# Once we release the operator, we will also release the init databases, we require them to be out first
1813-
# such that we can reference them and retrieve those binaries.
1814-
# Since we immediately run daily rebuild after creating the image, we can ensure that the init_database is out
1815-
# such that the agent image build can use it.
1816-
- name: release_agent_operator_release
1817-
depends_on:
1818-
- name: release_init_database
18191755

18201756
- name: preflight_release_images
18211757
display_name: preflight_release_images
@@ -1847,13 +1783,13 @@ buildvariants:
18471783

18481784
# It will be called by pct while bumping the agent cloud manager image
18491785
- name: release_agent
1850-
display_name: (Static Containers) Release Agent matrix
1786+
display_name: release_agent
18511787
tags: [ "release_agent" ]
18521788
run_on:
18531789
- release-ubuntu2204-large # This is required for CISA attestation https://jira.mongodb.org/browse/DEVPROD-17780
18541790
depends_on:
1855-
- variant: init_release_agents_on_ecr
1856-
name: '*'
1791+
- variant: init_test_run
1792+
name: build_agent_images_ubi # this ensures the agent gets released to ECR as well
18571793
- variant: e2e_multi_cluster_kind
18581794
name: '*'
18591795
- variant: e2e_static_multi_cluster_2_clusters

inventories/agent.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ vars:
33
s3_bucket: s3://enterprise-operator-dockerfiles/dockerfiles/mongodb-agent
44

55
images:
6-
- name: mongodb-agent-ubi
6+
- name: mongodb-agent
77
vars:
88
context: .
99
template_context: docker/mongodb-agent

lib/sonar/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def render(path: str, template_name: str, parameters: Dict[str, str]) -> str:
1313
"""
1414
env = jinja2.Environment(loader=jinja2.FileSystemLoader(path), undefined=jinja2.StrictUndefined)
1515

16-
template = "Dockerfile"
16+
template = "Dockerfile.old"
1717
if template_name is not None:
1818
template = "Dockerfile.{}".format(template_name)
1919

0 commit comments

Comments
 (0)