Skip to content

Commit c021609

Browse files
authored
CLOUDP-295785 - Publish agent images to staging repo automatically (#530)
# Summary Publish agent images to staging repo automatically. Whenever new version of `agent` appears in the `release.json`, `build_agent_images_ubi` will build and push it to appropriate registry. For PRs it will appear in the `dev` registry, but when the commit is merged to master, same `build_agent_images_ubi` will publish agent image to `staging` registry. This is possible, because now agent images utilise `skip-if-exists` flag that makes sure we only build and publish `agent` image that is not yet published for particular registry, others are skipped. Renamed `manual_release` scenario to existing `release`. `manual_release` was only used by `agent` and `ops_manager` release process and was unnecessary distinction from release scenario. This also helps to run `agent` and `ops_manager` release tasks from EVG, because `evg_private_context` was not aware of `manual_release` scenario: https://github.com/mongodb/mongodb-kubernetes/blob/7f864b2d76b5930596bb0ba08bb30bbe5ab6c087/scripts/dev/contexts/evg-private-context#L121-L153 ## Proof of Work [publish_om80_images](https://spruce.mongodb.com/version/68ee0f864be8200008a07a82/tasks?page=0&sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC&variant=%5Epublish_om80_images%24) was triggered manually. No images were published, because all of them exist already in quay.io/mongodb registry. The build scenario however was properly inferred as `release` >[2025/10/14 10:58:08.340] INFO 2025-10-14 08:58:08,340 [pipeline] Building image: ops-manager [2025/10/14 10:58:08.340] INFO 2025-10-14 08:58:08,340 [pipeline] Build configuration: ImageBuildConfiguration(scenario=<BuildScenario.RELEASE: 'release'>, version='8.0.14', latest_tag=False, olm_tag=True, registries=['quay.io/mongodb/mongodb-enterprise-ops-manager-ubi'], dockerfile_path='docker/mongodb-enterprise-ops-manager/Dockerfile', platforms=['linux/amd64'], sign=False, skip_if_exists=True, parallel=False, parallel_factor=0, all_agents=False, currently_used_agents=False) [2025/10/14 10:58:08.340] INFO 2025-10-14 08:58:08,340 [image_build_process] Ensuring buildx builder 'multiarch' exists... [2025/10/14 10:58:16.775] INFO 2025-10-14 08:58:16,774 [image_build_process] Created new buildx builder: multiarch [2025/10/14 10:58:17.358] INFO 2025-10-14 08:58:17,358 [atomic_pipeline] Image with tag quay.io/mongodb/mongodb-enterprise-ops-manager-ubi:8.0.14 already exists. Skipping it. [2025/10/14 10:58:17.358] INFO 2025-10-14 08:58:17,358 [atomic_pipeline] All specified image tags already exist. Skipping build. >[2025/10/14 10:59:14.284] INFO 2025-10-14 08:59:14,284 [pipeline] Building image: agent [2025/10/14 10:59:14.284] INFO 2025-10-14 08:59:14,284 [pipeline] Build configuration: ImageBuildConfiguration(scenario=<BuildScenario.RELEASE: 'release'>, version=None, latest_tag=False, olm_tag=True, registries=['quay.io/mongodb/mongodb-agent-ubi', 'quay.io/mongodb/mongodb-agent'], dockerfile_path='docker/mongodb-agent/Dockerfile', platforms=['linux/arm64', 'linux/amd64', 'linux/s390x', 'linux/ppc64le'], sign=False, skip_if_exists=True, parallel=True, parallel_factor=0, all_agents=False, currently_used_agents=False) [2025/10/14 10:59:14.284] INFO 2025-10-14 08:59:14,284 [image_build_process] Ensuring buildx builder 'multiarch' exists... [2025/10/14 10:59:18.493] INFO 2025-10-14 08:59:18,493 [image_build_process] Created new buildx builder: multiarch [2025/10/14 10:59:18.493] 2025-10-14 08:59:18,493 - scripts.release.agent.detect_ops_manager_changes - INFO - === Detecting OM Mapping Changes (Local vs Base) === [2025/10/14 10:59:18.496] INFO 2025-10-14 08:59:18,496 [atomic_pipeline] building agents for changed OM versions [2025/10/14 10:59:18.496] INFO 2025-10-14 08:59:18,496 [atomic_pipeline] No changes detected, skipping agent build ## Checklist - [ ] Have you linked a jira ticket and/or is the ticket in the title? - [ ] Have you checked whether your jira ticket required DOCSP changes? - [ ] 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 8ce17d4 commit c021609

File tree

4 files changed

+56
-52
lines changed

4 files changed

+56
-52
lines changed

.evergreen.yml

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ patch_aliases:
208208
- alias: "release_all_agents_manually"
209209
variant_tags: [ "release_all_agents_manually" ]
210210
task: ".*"
211+
- alias: "release_current_agents_manually"
212+
variant_tags: [ "release_current_agents_manually" ]
213+
task: ".*"
211214
- alias: "smoke_test_release"
212215
variant_tags: [ "e2e_smoke_release_test_suite" ]
213216
task_tags: [ "patch-run" ]
@@ -282,19 +285,19 @@ tasks:
282285
- func: setup_docker_sbom
283286
- func: pipeline_agent
284287
vars:
285-
BUILD_SCENARIO: manual_release
288+
BUILD_SCENARIO: release
286289

287290
- name: migrate_all_agents
288-
# this enables us to run this variant manually to build all the agents for the new registry
291+
# this enables us to run this variant manually to build all the agents for the new agent registry
289292
allowed_requesters: [ "patch" ]
290293
commands:
291294
- func: clone
292295
- func: setup_building_host
293296
- func: quay_login
294297
- func: pipeline_agent
295298
vars:
296-
BUILD_SCENARIO: manual_release
297-
FLAGS: "--all-agents -r quay.io/mongodb/mongodb-agent"
299+
BUILD_SCENARIO: release
300+
FLAGS: "--all-agents -r quay.io/mongodb/mongodb-agent --skip-if-exists=false"
298301

299302
- name: run_precommit_and_push
300303
tags: [ "patch-run" ]
@@ -315,27 +318,29 @@ tasks:
315318
working_dir: src/github.com/mongodb/mongodb-kubernetes
316319
binary: scripts/evergreen/precommit_bump.sh
317320

318-
- name: release_all_agents_on_ecr
319-
# this enables us to run this manually (patch) and release all agent versions to ECR to verify
321+
- name: rebuild_all_agents
322+
# this enables us to run this manually (patch) and rebuild all agent versions to verify
320323
# Dockerfile, script changes etc.
321324
allowed_requesters: [ "patch" ]
322325
commands:
323326
- func: clone
324327
- func: setup_building_host
328+
- func: quay_login
325329
- func: pipeline_agent
326330
vars:
327-
FLAGS: "--all-agents"
331+
FLAGS: "--all-agents --skip-if-exists=false"
328332

329-
- name: release_all_currently_used_agents_on_ecr
330-
# this enables us to run this manually (patch) and release all agent versions to ECR to verify
333+
- name: rebuild_currently_used_agents
334+
# this enables us to run this manually (patch) and rebuild current agent versions to verify
331335
# Dockerfile, script changes etc.
332336
allowed_requesters: [ "patch" ]
333337
commands:
334338
- func: clone
335339
- func: setup_building_host
340+
- func: quay_login
336341
- func: pipeline_agent
337342
vars:
338-
FLAGS: "--current-agents"
343+
FLAGS: "--current-agents --skip-if-exists=false"
339344

340345
- name: build_test_image
341346
commands:
@@ -405,7 +410,10 @@ tasks:
405410
commands:
406411
- func: clone
407412
- func: setup_building_host
413+
- func: quay_login
408414
- func: pipeline_agent
415+
vars:
416+
FLAGS: "--current-agents"
409417

410418
- name: build_init_database_image_ubi
411419
commands:
@@ -491,7 +499,7 @@ tasks:
491499
- func: setup_docker_sbom
492500
- func: pipeline_ops_manager
493501
vars:
494-
BUILD_SCENARIO: manual_release
502+
BUILD_SCENARIO: release
495503

496504
- name: prepare_and_upload_openshift_bundles_for_e2e
497505
commands:
@@ -1810,25 +1818,25 @@ buildvariants:
18101818
tasks:
18111819
- name: release_agent
18121820

1813-
# Only called manually, It's used for testing the task release_agents_on_ecr in case the release.json
1814-
# has not changed, and you still want to push the images to ecr.
1815-
- name: manual_ecr_release_agent
1821+
# Only called manually, It's used for testing the task release_agents in case the release.json
1822+
# has not changed, and you still want to push the images to registry.
1823+
- name: manual_release_all_agents
18161824
display_name: Manual Agent Release for all versions
18171825
tags: [ "manual_patch", "release_all_agents_manually" ]
18181826
run_on:
18191827
- ubuntu2404-large
18201828
tasks:
1821-
- name: release_all_agents_on_ecr
1829+
- name: rebuild_all_agents
18221830

1823-
# Only called manually, It's used for testing the task release_agents_on_ecr in case the release.json
1824-
# has not changed, and you still want to push the images to ecr.
1825-
- name: manual_ecr_release_agent_currently_used
1826-
display_name: manual_ecr_release_agent_currently_used
1827-
tags: [ "manual_patch", "release_all_agents_manually" ]
1831+
# Only called manually, It's used for testing the task release_agents in case the release.json
1832+
# has not changed, and you still want to push the images to registry.
1833+
- name: manual_release_agent_currently_used
1834+
display_name: manual_release_agent_currently_used
1835+
tags: [ "manual_patch", "release_current_agents_manually" ]
18281836
run_on:
18291837
- ubuntu2404-large
18301838
tasks:
1831-
- name: release_all_currently_used_agents_on_ecr
1839+
- name: rebuild_currently_used_agents
18321840

18331841
### Build variants for manual patch only
18341842

build_info.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,15 @@
268268
"agent": {
269269
"dockerfile-path": "docker/mongodb-agent/Dockerfile",
270270
"patch": {
271+
"skip-if-exists": true,
271272
"repositories": ["268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-agent"],
272273
"platforms": [
273274
"linux/amd64"
274275
]
275276
},
276277
"staging": {
277278
"sign": true,
279+
"skip-if-exists": true,
278280
"repositories": ["268558157000.dkr.ecr.us-east-1.amazonaws.com/staging/mongodb-agent"],
279281
"platforms": [
280282
"linux/arm64",
@@ -283,7 +285,7 @@
283285
"linux/ppc64le"
284286
]
285287
},
286-
"manual_release": {
288+
"release": {
287289
"sign": true,
288290
"olm-tag": true,
289291
"skip-if-exists": true,
@@ -299,19 +301,21 @@
299301
"ops-manager": {
300302
"dockerfile-path": "docker/mongodb-enterprise-ops-manager/Dockerfile",
301303
"patch": {
304+
"skip-if-exists": true,
302305
"repositories": ["268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-enterprise-ops-manager-ubi"],
303306
"platforms": [
304307
"linux/amd64"
305308
]
306309
},
307310
"staging": {
308311
"sign": true,
312+
"skip-if-exists": true,
309313
"repositories": ["268558157000.dkr.ecr.us-east-1.amazonaws.com/staging/mongodb-enterprise-ops-manager-ubi"],
310314
"platforms": [
311315
"linux/amd64"
312316
]
313317
},
314-
"manual_release": {
318+
"release": {
315319
"sign": true,
316320
"olm-tag": true,
317321
"skip-if-exists": true,

scripts/release/build/build_scenario.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33

44
class BuildScenario(StrEnum):
5-
RELEASE = "release" # Official release triggered by a git tag
6-
MANUAL_RELEASE = "manual_release" # Manual release, not part of operator release cycle
5+
RELEASE = "release" # Official release triggered by a git tag or OM version bump
76
PATCH = "patch" # CI build for a patch/pull request
87
STAGING = "staging" # CI build from a merge to the master
98
DEVELOPMENT = "development" # Local build on a developer machine

scripts/release/tests/build_info_test.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ def test_load_build_info_development():
6868
repositories=["268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-agent"],
6969
platforms=["linux/amd64"],
7070
dockerfile_path="docker/mongodb-agent/Dockerfile",
71+
skip_if_exists=True,
7172
),
7273
"ops-manager": ImageInfo(
7374
repositories=["268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-enterprise-ops-manager-ubi"],
7475
platforms=["linux/amd64"],
7576
dockerfile_path="docker/mongodb-enterprise-ops-manager/Dockerfile",
77+
skip_if_exists=True,
7678
),
7779
},
7880
binaries={
@@ -152,11 +154,13 @@ def test_load_build_info_patch():
152154
repositories=["268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-agent"],
153155
platforms=["linux/amd64"],
154156
dockerfile_path="docker/mongodb-agent/Dockerfile",
157+
skip_if_exists=True,
155158
),
156159
"ops-manager": ImageInfo(
157160
repositories=["268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-enterprise-ops-manager-ubi"],
158161
platforms=["linux/amd64"],
159162
dockerfile_path="docker/mongodb-enterprise-ops-manager/Dockerfile",
163+
skip_if_exists=True,
160164
),
161165
},
162166
binaries={
@@ -253,6 +257,7 @@ def test_load_build_info_staging():
253257
platforms=["linux/arm64", "linux/amd64", "linux/s390x", "linux/ppc64le"],
254258
dockerfile_path="docker/mongodb-agent/Dockerfile",
255259
sign=True,
260+
skip_if_exists=True,
256261
),
257262
"ops-manager": ImageInfo(
258263
repositories=[
@@ -261,6 +266,7 @@ def test_load_build_info_staging():
261266
platforms=["linux/amd64"],
262267
dockerfile_path="docker/mongodb-enterprise-ops-manager/Dockerfile",
263268
sign=True,
269+
skip_if_exists=True,
264270
),
265271
},
266272
binaries={
@@ -348,30 +354,6 @@ def test_load_build_info_release():
348354
olm_tag=True,
349355
sign=True,
350356
),
351-
},
352-
binaries={
353-
"kubectl-mongodb": BinaryInfo(
354-
s3_store="s3://kubectl-mongodb/prod",
355-
platforms=["darwin/amd64", "darwin/arm64", "linux/amd64", "linux/arm64"],
356-
sign=True,
357-
)
358-
},
359-
helm_charts={
360-
"mongodb-kubernetes": HelmChartInfo(
361-
repositories=["quay.io/mongodb/helm-charts"],
362-
sign=True,
363-
)
364-
},
365-
)
366-
367-
build_info = load_build_info(BuildScenario.RELEASE)
368-
369-
assert build_info == expected_build_info
370-
371-
372-
def test_load_build_info_manual_release():
373-
expected_build_info = BuildInfo(
374-
images={
375357
"agent": ImageInfo(
376358
repositories=["quay.io/mongodb/mongodb-agent-ubi", "quay.io/mongodb/mongodb-agent"],
377359
platforms=["linux/arm64", "linux/amd64", "linux/s390x", "linux/ppc64le"],
@@ -389,10 +371,21 @@ def test_load_build_info_manual_release():
389371
sign=True,
390372
),
391373
},
392-
binaries={},
393-
helm_charts={},
374+
binaries={
375+
"kubectl-mongodb": BinaryInfo(
376+
s3_store="s3://kubectl-mongodb/prod",
377+
platforms=["darwin/amd64", "darwin/arm64", "linux/amd64", "linux/arm64"],
378+
sign=True,
379+
)
380+
},
381+
helm_charts={
382+
"mongodb-kubernetes": HelmChartInfo(
383+
repositories=["quay.io/mongodb/helm-charts"],
384+
sign=True,
385+
)
386+
},
394387
)
395388

396-
build_info = load_build_info(BuildScenario.MANUAL_RELEASE)
389+
build_info = load_build_info(BuildScenario.RELEASE)
397390

398391
assert build_info == expected_build_info

0 commit comments

Comments
 (0)