Skip to content

Commit 355e63d

Browse files
authored
Agent and OM releases with new pipeline (#355)
# Summary Add a new `manual_release` scenario to properly handle image releases that are decoupled from operator releases. ## Proof of Work Tested `release_agent` task on Evergreen, manually edited json file to point to my repo, and added `--all-agents` ton actually trigger a release. Task: https://spruce.mongodb.com/task/mongodb_kubernetes_release_agent_release_agent_patch_cda9f730105c7b461ebb9a5fcf6adfea66006d35_68a5c140eba83800072c1894_25_08_20_12_36_23/logs?execution=0 Agents were pushed to my private repository. ## Checklist - [ ] 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 6a9d142 commit 355e63d

File tree

7 files changed

+49
-22
lines changed

7 files changed

+49
-22
lines changed

.evergreen-functions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ functions:
524524
shell: bash
525525
<<: *e2e_include_expansions_in_env
526526
working_dir: src/github.com/mongodb/mongodb-kubernetes
527-
binary: scripts/dev/run_python.sh scripts/release/pipeline_main.py --parallel ${image_name} ${all_agents}
527+
binary: scripts/dev/run_python.sh scripts/release/pipeline_main.py --parallel ${image_name} ${all_agents} ${build_scenario}
528528

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

.evergreen.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,10 @@ tasks:
344344
- func: setup_building_host
345345
- func: quay_login
346346
- func: setup_docker_sbom
347-
- func: legacy_pipeline
347+
- func: pipeline
348348
vars:
349349
image_name: agent
350+
build_scenario: --build-scenario manual_release
350351

351352
- name: run_precommit_and_push
352353
tags: ["patch-run"]
@@ -531,10 +532,10 @@ tasks:
531532
- func: setup_building_host
532533
- func: quay_login
533534
- func: setup_docker_sbom
534-
- func: legacy_pipeline
535+
- func: pipeline
535536
vars:
536537
image_name: ops-manager
537-
include_tags: release
538+
build_scenario: --build-scenario manual_release
538539

539540
- name: prepare_and_upload_openshift_bundles_for_e2e
540541
commands:

build_info.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
"linux/amd64"
241241
]
242242
},
243-
"release": {
243+
"manual_release": {
244244
"sign": true,
245245
"repository": "quay.io/mongodb/mongodb-agent-ubi",
246246
"platforms": [
@@ -266,8 +266,7 @@
266266
"linux/amd64"
267267
]
268268
},
269-
"release": {
270-
"version": "om-version-from-release.json",
269+
"manual_release": {
271270
"sign": true,
272271
"repository": "quay.io/mongodb/mongodb-enterprise-ops-manager",
273272
"platforms": [

scripts/release/build/build_info.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def load_build_info(
8080
initial_version = get_initial_version()
8181

8282
version = scenario.get_version(repository_path, changelog_sub_path, initial_commit_sha, initial_version)
83+
# For manual_release, version can be None and will be set by image-specific logic
8384

8485
with open("build_info.json", "r") as f:
8586
build_info = json.load(f)
@@ -98,7 +99,7 @@ def load_build_info(
9899

99100
# Only update the image_version if it is not already set in the build_info.json file
100101
image_version = scenario_data.get("version")
101-
if not image_version:
102+
if not image_version and version is not None:
102103
image_version = version
103104

104105
images[name] = ImageInfo(

scripts/release/build/build_scenario.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
class BuildScenario(StrEnum):
1313
RELEASE = "release" # Official release triggered by a git tag
14+
MANUAL_RELEASE = "manual_release" # Manual release, not part of operator release cycle
1415
PATCH = "patch" # CI build for a patch/pull request
1516
STAGING = "staging" # CI build from a merge to the master
1617
DEVELOPMENT = "development" # Local build on a developer machine
@@ -58,5 +59,9 @@ def get_version(self, repository_path: str, changelog_sub_path: str, initial_com
5859
return repo.head.object.hexsha[:COMMIT_SHA_LENGTH]
5960
case BuildScenario.RELEASE:
6061
return calculate_next_version(repo, changelog_sub_path, initial_commit_sha, initial_version)
62+
case BuildScenario.MANUAL_RELEASE:
63+
# For manual releases, version must be provided externally (e.g., for ops-manager via om_version env var,
64+
# for agent via release.json). Return None to indicate version will be set by image-specific logic.
65+
return None
6166

6267
raise ValueError(f"Unknown build scenario: {self}")

scripts/release/pipeline_main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ def image_build_config_from_args(args) -> ImageBuildConfiguration:
114114
sign = args.sign or image_build_info.sign
115115
dockerfile_path = image_build_info.dockerfile_path
116116

117+
# Validate version - only ops-manager and agent can have None version as the versions are managed by the agent
118+
# and om methods themselves, which are externally retrieved - om_version env var and release.json respectively
119+
if version is None and image not in ["ops-manager", "agent"]:
120+
raise ValueError(f"Version cannot be empty for {image}.")
121+
117122
return ImageBuildConfiguration(
118123
scenario=build_scenario,
119124
version=version,

scripts/release/tests/build_info_test.py

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -408,20 +408,6 @@ def test_load_build_info_release(
408408
dockerfile_path="docker/mongodb-kubernetes-upgrade-hook/Dockerfile.atomic",
409409
sign=True,
410410
),
411-
"agent": ImageInfo(
412-
repository="quay.io/mongodb/mongodb-agent-ubi",
413-
platforms=["linux/arm64", "linux/amd64"],
414-
version=version,
415-
dockerfile_path="docker/mongodb-agent/Dockerfile.atomic",
416-
sign=True,
417-
),
418-
"ops-manager": ImageInfo(
419-
repository="quay.io/mongodb/mongodb-enterprise-ops-manager",
420-
platforms=["linux/amd64"],
421-
version="om-version-from-release.json",
422-
dockerfile_path="docker/mongodb-enterprise-ops-manager/Dockerfile.atomic",
423-
sign=True,
424-
),
425411
},
426412
binaries={
427413
"kubectl-mongodb": BinaryInfo(
@@ -443,3 +429,33 @@ def test_load_build_info_release(
443429
build_info = load_build_info(BuildScenario.RELEASE, git_repo.working_dir)
444430

445431
assert build_info == expected_build_info
432+
433+
434+
def test_load_build_info_manual_release(git_repo: Repo):
435+
version = "1.2.0"
436+
git_repo.git.checkout(version)
437+
438+
expected_build_info = BuildInfo(
439+
images={
440+
"agent": ImageInfo(
441+
repository="quay.io/mongodb/mongodb-agent-ubi",
442+
platforms=["linux/arm64", "linux/amd64"],
443+
version=None, # Version is None for manual_release scenario
444+
dockerfile_path="docker/mongodb-agent/Dockerfile.atomic",
445+
sign=True,
446+
),
447+
"ops-manager": ImageInfo(
448+
repository="quay.io/mongodb/mongodb-enterprise-ops-manager",
449+
platforms=["linux/amd64"],
450+
version=None, # Version is None for manual_release scenario
451+
dockerfile_path="docker/mongodb-enterprise-ops-manager/Dockerfile.atomic",
452+
sign=True,
453+
),
454+
},
455+
binaries={},
456+
helm_charts={},
457+
)
458+
459+
build_info = load_build_info(BuildScenario.MANUAL_RELEASE, git_repo.working_dir)
460+
461+
assert build_info == expected_build_info

0 commit comments

Comments
 (0)