Skip to content

Commit 084b8f2

Browse files
committed
Add version_prefix to build_info.json + other fixes
1 parent ca7881c commit 084b8f2

File tree

9 files changed

+34
-28
lines changed

9 files changed

+34
-28
lines changed

build_info.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,14 @@
383383
"helm-charts": {
384384
"mongodb-kubernetes": {
385385
"patch": {
386+
"version-prefix": "0.0.0+",
386387
"registry": "268558157000.dkr.ecr.us-east-1.amazonaws.com",
387388
"region": "us-east-1",
388389
"repository": "dev/mongodb/helm-charts"
389390
},
390391
"staging": {
391392
"sign": true,
393+
"version-prefix": "0.0.0+",
392394
"registry": "268558157000.dkr.ecr.us-east-1.amazonaws.com",
393395
"region": "us-east-1",
394396
"repository": "staging/mongodb/helm-charts"

docker/mongodb-kubernetes-tests/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ RUN apt-get -qq update \
1616

1717
COPY requirements.txt requirements.txt
1818

19+
# install aws, required to run helm registry login while running the tests
1920
RUN python3 -m venv /venv \
2021
&& . /venv/bin/activate \
2122
&& pip install --upgrade pip \
2223
&& GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 pip install -r requirements.txt \
23-
&& pip install awscli # install aws, required to run helm registry login while running the tests
24+
&& pip install awscli
2425

2526
FROM scratch AS tools_downloader
2627

@@ -48,6 +49,8 @@ RUN apt-get -qq update \
4849
curl \
4950
libldap2-dev \
5051
libsasl2-dev \
52+
git \
53+
openssl
5154

5255
RUN mkdir -p /tmp/mongodb-tools && \
5356
tar xfz /tmp/mongodb-tools.tgz -C /tmp/mongodb-tools && \

docker/mongodb-kubernetes-tests/kubetester/consts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
OPERATOR_VERSION_ENV_VAR_NAME = "OPERATOR_VERSION"
2-
1+
OCI_HELM_VERSION = "OCI_HELM_VERSION"
32
OCI_HELM_REGISTRY_ENV_VAR_NAME = "OCI_HELM_REGISTRY"
43
OCI_HELM_REPOSITORY_ENV_VAR_NAME = "OCI_HELM_REPOSITORY"
54
OCI_HELM_REGION_ENV_VAR_NAME = "OCI_HELM_REGION"

docker/mongodb-kubernetes-tests/kubetester/helm.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
# LOCAL_CRDs_DIR is the dir where local helm chart's CRDs are copied in tests image
1515
LOCAL_CRDs_DIR = "helm_chart/crds"
16+
OCI_HELM_REGISTRY_ECR = "268558157000.dkr.ecr.us-east-1.amazonaws.com"
1617

1718

1819
def helm_template(
@@ -314,23 +315,20 @@ def helm_chart_path_and_version(helm_chart_path: str, operator_version: str) ->
314315
return LOCAL_HELM_CHART_DIR, ""
315316

316317
# if operator_version is not specified, and we are not installing the MCK or MEKO chart
317-
# it would mean we want to install OCI published helm chart. Figure out respective version,
318-
# it is set in env var `OPERATOR_VERSION` based on build_scenario.
318+
# it would mean we want to install OCI published helm chart.
319319
if not operator_version and helm_chart_path not in (
320320
MCK_HELM_CHART,
321321
LEGACY_OPERATOR_CHART,
322322
):
323-
non_semver_operator_version = os.environ.get(OPERATOR_VERSION_ENV_VAR_NAME)
324-
# when we publish the helm chart we append `0.0.0+` in the chart version, details are
325-
# here https://docs.google.com/document/d/1eJ8iKsI0libbpcJakGjxcPfbrTn8lmcZDbQH1UqMR_g/edit?tab=t.gg5ble8qlesq
323+
non_semver_operator_version = os.environ.get(OCI_HELM_VERSION)
326324
operator_version = f"0.0.0+{non_semver_operator_version}"
327325

328326
# helm_chart_path not being passed would mean we are on evg env and would like to
329327
# install helm chart from OCI registry.
330328
if not helm_chart_path:
331329
registry, repository, region = oci_chart_info()
332330
# If ECR we need to login first to the OCI container registry
333-
if registry == "268558157000.dkr.ecr.us-east-1.amazonaws.com":
331+
if registry == OCI_HELM_REGISTRY_ECR:
334332
try:
335333
helm_registry_login_to_ecr(registry, region)
336334
except Exception as e:

scripts/evergreen/deployments/test-app/values.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ omDebugHttp:
4848
# to run a test.
4949
helm:
5050
oci:
51+
version: ""
5152
registry: ""
5253
repository: ""
5354
region: ""
54-
55-
operator:
56-
version: ""

scripts/evergreen/e2e/single_e2e.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ deploy_test_app() {
5555
helm_oci_registry=$(echo "${chart_info}" | jq -r '.registry' )
5656
helm_oci_repository=$(echo "${chart_info}" | jq -r '.repository' )
5757
helm_oci_registry_region=$(echo "${chart_info}" | jq -r '.region' )
58+
helm_oci_version_prefix=$(echo "${chart_info}" | jq -r '.version_prefix // empty' )
59+
helm_oci_version="${helm_oci_version_prefix:-}${OPERATOR_VERSION}"
5860

5961
# note, that the 4 last parameters are used only for Mongodb resource testing - not for Ops Manager
6062
helm_params=(
6163
"--set" "taskId=${task_id:-'not-specified'}"
62-
"--set" "operator.version=${OPERATOR_VERSION}"
6364
"--set" "namespace=${NAMESPACE}"
6465
"--set" "taskName=${task_name}"
6566
"--set" "mekoTestsRegistry=${MEKO_TESTS_REGISTRY}"
@@ -85,6 +86,7 @@ deploy_test_app() {
8586
"--set" "cognito_user_password=${cognito_user_password}"
8687
"--set" "cognito_workload_url=${cognito_workload_url}"
8788
"--set" "cognito_workload_user_id=${cognito_workload_user_id}"
89+
"--set" "helm.oci.version=${helm_oci_version}"
8890
"--set" "helm.oci.registry=${helm_oci_registry}"
8991
"--set" "helm.oci.repository=${helm_oci_repository}"
9092
"--set" "helm.oci.region=${helm_oci_registry_region}"

scripts/release/build/build_info.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class BinaryInfo:
4444
class HelmChartInfo:
4545
repository: str
4646
registry: str
47-
region: str
47+
region: str = None
48+
version_prefix: str = None
4849
sign: bool = False
4950

5051

@@ -112,6 +113,7 @@ def load_build_info(scenario: BuildScenario) -> BuildInfo:
112113
helm_charts[name] = HelmChartInfo(
113114
repository=scenario_data.get("repository"),
114115
sign=scenario_data.get("sign", False),
116+
version_prefix=scenario_data.get("version-prefix"),
115117
registry=scenario_data.get("registry"),
116118
region=scenario_data.get("region")
117119
)

scripts/release/publish_helm_chart.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
import os
33
import subprocess
4-
import sys
54

65
import yaml
76

@@ -28,7 +27,7 @@ def run_command(command: list[str]):
2827

2928
# update_chart_and_get_metadata updates the helm chart's Chart.yaml and sets the version
3029
# to either evg patch id or commit which is set in OPERATOR_VERSION.
31-
def update_chart_and_get_metadata(chart_dir: str, build_scenario) -> tuple[str, str]:
30+
def update_chart_and_get_metadata(chart_dir: str, version_prefix: str = None) -> tuple[str, str]:
3231
chart_path = os.path.join(chart_dir, "Chart.yaml")
3332
version = os.environ.get("OPERATOR_VERSION")
3433
if not version:
@@ -50,13 +49,15 @@ def update_chart_and_get_metadata(chart_dir: str, build_scenario) -> tuple[str,
5049
if not chart_name:
5150
raise ValueError("Chart.yaml is missing required 'name' field.")
5251
except Exception as e:
53-
raise Exception(f"Unable to load Chart.yaml from dir {chart_path}")
52+
raise Exception(f"Unable to load Chart.yaml from dir {chart_path}: {e}")
5453

55-
# if build_scenario is release, the chart.yaml would already have correct chart version
56-
if build_scenario == BuildScenario.RELEASE:
54+
# If version_prefix is not specified, the chart.yaml would already have correct chart version
55+
if version_prefix is None:
5756
return chart_name, version
5857

59-
new_version = f"0.0.0+{version}"
58+
# When we publish the helm chart to dev and staging we append `0.0.0+` in the chart version, details are
59+
# here https://docs.google.com/document/d/1eJ8iKsI0libbpcJakGjxcPfbrTn8lmcZDbQH1UqMR_g/edit?tab=t.gg5ble8qlesq
60+
new_version = f"{version_prefix}{version}"
6061
logger.info(f"New helm chart version will be: {new_version}")
6162

6263
try:
@@ -79,7 +80,7 @@ def get_oci_registry(chart_info: HelmChartInfo) -> str:
7980
raise ValueError("Error: registry doesn't seem to be set in HelmChartInfo.")
8081

8182
if not repo:
82-
raise ValueError("Error: reposiotry doesn't seem to be set in HelmChartInfo.")
83+
raise ValueError("Error: repository doesn't seem to be set in HelmChartInfo.")
8384

8485
oci_registry = f"oci://{registry}/{repo}"
8586
logger.info(f"Determined OCI Registry: {oci_registry}")
@@ -89,7 +90,7 @@ def get_oci_registry(chart_info: HelmChartInfo) -> str:
8990
def publish_helm_chart(chart_info: HelmChartInfo, build_scenario):
9091
try:
9192
oci_registry = get_oci_registry(chart_info)
92-
chart_name, chart_version = update_chart_and_get_metadata(CHART_DIR, build_scenario)
93+
chart_name, chart_version = update_chart_and_get_metadata(CHART_DIR, chart_info.version_prefix)
9394
tgz_filename = f"{chart_name}-{chart_version}.tgz"
9495

9596
logger.info(f"Packaging chart: {chart_name} with Version: {chart_version}")
@@ -121,6 +122,5 @@ def main():
121122
if __name__ == "__main__":
122123
try:
123124
main()
124-
except Exception as e:
125-
logger.error(f"Failure in the helm publishing process {e}")
126-
sys.exit(1)
125+
except Exception as main_err:
126+
raise Exception(f"Failure in the helm publishing process {main_err}")

scripts/release/tests/build_info_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def test_load_build_info_development():
9191
},
9292
helm_charts={
9393
"mongodb-kubernetes": HelmChartInfo(
94+
version_prefix="0.0.0+",
9495
registry="268558157000.dkr.ecr.us-east-1.amazonaws.com",
9596
repository="dev/mongodb/helm-charts",
9697
region="us-east-1",
@@ -185,6 +186,7 @@ def test_load_build_info_patch():
185186
},
186187
helm_charts={
187188
"mongodb-kubernetes": HelmChartInfo(
189+
version_prefix="0.0.0+",
188190
region="us-east-1",
189191
repository="dev/mongodb/helm-charts",
190192
registry="268558157000.dkr.ecr.us-east-1.amazonaws.com",
@@ -308,10 +310,11 @@ def test_load_build_info_staging():
308310
},
309311
helm_charts={
310312
"mongodb-kubernetes": HelmChartInfo(
313+
sign=True,
314+
version_prefix="0.0.0+",
311315
registry="268558157000.dkr.ecr.us-east-1.amazonaws.com",
312316
repository="staging/mongodb/helm-charts",
313317
region="us-east-1",
314-
sign=True,
315318
)
316319
},
317320
)
@@ -419,10 +422,9 @@ def test_load_build_info_release():
419422
},
420423
helm_charts={
421424
"mongodb-kubernetes": HelmChartInfo(
425+
sign=True,
422426
registry="quay.io",
423427
repository="mongodb/helm-charts",
424-
region=None,
425-
sign=True,
426428
)
427429
},
428430
)

0 commit comments

Comments
 (0)