Skip to content

Commit 0786a90

Browse files
CLOUDP-337727: Add operator with race checker image in init variant (#341)
# Summary This patch adds a separate task in the `init_test_run` variant for building the operator image with the race-checker enabled. This patch also moved the tests under `scripts/release` according to [standard pytest best practices](https://doc.pytest.org/en/latest/explanation/goodpractices.html#tests-as-part-of-application-code) as currently our python test targets were not capturing all the tests. ## Proof of Work [EVG Job](https://spruce.mongodb.com/version/689b8a097e5e41000778b82e) ## 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 6075072 commit 0786a90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+131
-71
lines changed

.evergreen.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ variables:
156156
- name: build_agent_images_ubi
157157
variant: init_test_run
158158

159+
- &base_om7_dependency_with_race
160+
depends_on:
161+
- name: build_om_images
162+
variant: build_om70_images
163+
- name: build_operator_race_ubi
164+
variant: init_test_run
165+
- name: build_init_database_image_ubi
166+
variant: init_test_run
167+
- name: build_database_image_ubi
168+
variant: init_test_run
169+
- name: build_test_image
170+
variant: init_test_run
171+
- name: build_init_appdb_images_ubi
172+
variant: init_test_run
173+
- name: build_init_om_images_ubi
174+
variant: init_test_run
175+
- name: build_agent_images_ubi
176+
variant: init_test_run
177+
159178
- &base_om8_dependency
160179
depends_on:
161180
- name: build_om_images
@@ -439,18 +458,23 @@ tasks:
439458
- func: setup_building_host
440459
- func: pipeline
441460
vars:
442-
skip_tags: ubuntu,release
443-
distro: ubi
444461
image_name: operator
445462

463+
- name: build_operator_race_ubi
464+
commands:
465+
- func: clone
466+
- func: setup_building_host
467+
- func: pipeline
468+
vars:
469+
image_name: operator-race
470+
446471
- name: build_init_om_images_ubi
447472
commands:
448473
- func: clone
449474
- func: setup_building_host
450475
- func: pipeline
451476
vars:
452477
image_name: init-ops-manager
453-
skip_tags: ubuntu,release
454478

455479
- name: build_init_appdb_images_ubi
456480
commands:
@@ -459,7 +483,6 @@ tasks:
459483
- func: pipeline
460484
vars:
461485
image_name: init-appdb
462-
skip_tags: ubuntu,release
463486

464487
- name: build_agent_images_ubi
465488
commands:
@@ -468,7 +491,6 @@ tasks:
468491
- func: pipeline
469492
vars:
470493
image_name: agent
471-
skip_tags: ubuntu,release
472494

473495
- name: build_init_database_image_ubi
474496
commands:
@@ -477,7 +499,6 @@ tasks:
477499
- func: pipeline
478500
vars:
479501
image_name: init-database
480-
skip_tags: ubuntu,release
481502

482503
- name: build_database_image_ubi
483504
commands:
@@ -486,7 +507,6 @@ tasks:
486507
- func: pipeline
487508
vars:
488509
image_name: database
489-
skip_tags: ubuntu,release
490510

491511
- name: build_readiness_probe_image
492512
commands:
@@ -495,7 +515,6 @@ tasks:
495515
- func: pipeline
496516
vars:
497517
image_name: readiness-probe
498-
skip_tags: ubuntu,release
499518

500519
- name: build_upgrade_hook_image
501520
commands:
@@ -504,7 +523,6 @@ tasks:
504523
- func: pipeline
505524
vars:
506525
image_name: upgrade-hook
507-
skip_tags: ubuntu,release
508526

509527
- name: prepare_aws
510528
priority: 59
@@ -1434,7 +1452,7 @@ buildvariants:
14341452
tags: [ "e2e_test_suite" ]
14351453
run_on:
14361454
- ubuntu1804-xlarge
1437-
<<: *base_om7_dependency
1455+
<<: *base_om7_dependency_with_race
14381456
tasks:
14391457
- name: e2e_operator_race_with_telemetry_task_group
14401458

@@ -1653,6 +1671,7 @@ buildvariants:
16531671
- ubuntu2204-small
16541672
tasks:
16551673
- name: build_operator_ubi
1674+
- name: build_operator_race_ubi
16561675
- name: build_test_image
16571676
- name: build_mco_test_image
16581677
- name: build_init_appdb_images_ubi

build_info.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525
]
2626
}
2727
},
28+
"operator-race": {
29+
"dockerfile-path": "docker/mongodb-kubernetes-operator/Dockerfile.atomic",
30+
"patch": {
31+
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/dev/mongodb-kubernetes",
32+
"platforms": [
33+
"linux/amd64"
34+
]
35+
},
36+
"staging": {
37+
"sign": true,
38+
"repository": "268558157000.dkr.ecr.us-east-1.amazonaws.com/staging/mongodb-kubernetes",
39+
"platforms": [
40+
"linux/arm64",
41+
"linux/amd64"
42+
]
43+
}
44+
},
2845
"init-database": {
2946
"dockerfile-path": "docker/mongodb-kubernetes-init-database/Dockerfile.atomic",
3047
"patch": {

scripts/release/atomic_pipeline.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,20 @@ def build_mco_tests_image(build_configuration: ImageBuildConfiguration):
117117
)
118118

119119

120-
def build_operator_image(build_configuration: ImageBuildConfiguration):
120+
def build_operator_image(build_configuration: ImageBuildConfiguration, with_race_detection: bool = False):
121121
"""Calculates arguments required to build the operator image, and starts the build process."""
122122
# In evergreen, we can pass test_suffix env to publish the operator to a quay
123123
# repository with a given suffix.
124124
test_suffix = os.getenv("test_suffix", "")
125125
log_automation_config_diff = os.getenv("LOG_AUTOMATION_CONFIG_DIFF", "false")
126126

127+
build_configuration.version = f"{build_configuration.version}{'-race' if with_race_detection else ''}"
128+
127129
args = {
128130
"version": build_configuration.version,
129131
"log_automation_config_diff": log_automation_config_diff,
130132
"test_suffix": test_suffix,
133+
"use_race": "true" if with_race_detection else "false",
131134
}
132135

133136
logger.info(f"Building Operator args: {args}")

scripts/release/build/build_info.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
from typing import Dict
44

55
from scripts.release.build.build_scenario import BuildScenario
6-
from scripts.release.constants import DEFAULT_REPOSITORY_PATH, DEFAULT_CHANGELOG_PATH, RELEASE_INITIAL_VERSION_ENV_VAR, \
7-
get_initial_version, get_initial_commit_sha
6+
from scripts.release.constants import (
7+
DEFAULT_REPOSITORY_PATH,
8+
DEFAULT_CHANGELOG_PATH,
9+
RELEASE_INITIAL_VERSION_ENV_VAR,
10+
get_initial_version,
11+
get_initial_commit_sha,
12+
)
813

914
MEKO_TESTS_IMAGE = "meko-tests"
1015
OPERATOR_IMAGE = "operator"
16+
OPERATOR_RACE_IMAGE = "operator-race"
1117
MCO_TESTS_IMAGE = "mco-tests"
1218
READINESS_PROBE_IMAGE = "readiness-probe"
1319
UPGRADE_HOOK_IMAGE = "upgrade-hook"
@@ -50,11 +56,13 @@ class BuildInfo:
5056
helm_charts: Dict[str, HelmChartInfo]
5157

5258

53-
def load_build_info(scenario: BuildScenario,
54-
repository_path: str = DEFAULT_REPOSITORY_PATH,
55-
changelog_sub_path: str = DEFAULT_CHANGELOG_PATH,
56-
initial_commit_sha: str = None,
57-
initial_version: str = None) -> BuildInfo:
59+
def load_build_info(
60+
scenario: BuildScenario,
61+
repository_path: str = DEFAULT_REPOSITORY_PATH,
62+
changelog_sub_path: str = DEFAULT_CHANGELOG_PATH,
63+
initial_commit_sha: str = None,
64+
initial_version: str = None,
65+
) -> BuildInfo:
5866
f"""
5967
Load build information based on the specified scenario.
6068

scripts/release/build/conftest.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

scripts/release/build/image_build_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def is_release_scenario(self) -> bool:
2222
return self.scenario == BuildScenario.RELEASE
2323

2424
def base_registry(self) -> str:
25-
return self.registry.rpartition('/')[0]
25+
return self.registry.rpartition("/")[0]
2626

2727
def image_name(self) -> str:
28-
return self.registry.rpartition('/')[2]
28+
return self.registry.rpartition("/")[2]

scripts/release/pipeline_main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import argparse
22
import os
3+
from functools import partial
34
from typing import Callable, Dict
45

56
from opentelemetry import context, trace
@@ -37,6 +38,7 @@
3738
MCO_TESTS_IMAGE,
3839
MEKO_TESTS_IMAGE,
3940
OPERATOR_IMAGE,
41+
OPERATOR_RACE_IMAGE,
4042
OPS_MANAGER_IMAGE,
4143
READINESS_PROBE_IMAGE,
4244
UPGRADE_HOOK_IMAGE,
@@ -67,6 +69,7 @@ def get_builder_function_for_image_name() -> Dict[str, Callable]:
6769
image_builders = {
6870
MEKO_TESTS_IMAGE: build_meko_tests_image,
6971
OPERATOR_IMAGE: build_operator_image,
72+
OPERATOR_RACE_IMAGE: partial(build_operator_image, with_race_detection=True),
7073
MCO_TESTS_IMAGE: build_mco_tests_image,
7174
READINESS_PROBE_IMAGE: build_readiness_probe_image,
7275
UPGRADE_HOOK_IMAGE: build_upgrade_hook_image,
@@ -96,7 +99,6 @@ def image_build_config_from_args(args) -> ImageBuildConfiguration:
9699
image = args.image
97100

98101
build_scenario = get_scenario_from_arg(args.build_scenario) or BuildScenario.infer_scenario_from_environment()
99-
100102
build_info = load_build_info(build_scenario)
101103
logger.info(f"image is {image}")
102104
logger.info(f"images are {build_info.images}")

scripts/release/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)