Skip to content

Commit 0d414fb

Browse files
committed
CLOUDP-295785 - copy kubectl-mongodb plugin to ./bin/kubectl-mongodb for code snippets tests
1 parent 97333b2 commit 0d414fb

File tree

5 files changed

+37
-16
lines changed

5 files changed

+37
-16
lines changed

.evergreen-functions.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ functions:
525525
params:
526526
working_dir: src/github.com/mongodb/mongodb-kubernetes
527527
binary: scripts/release/kubectl_mongodb/download_kubectl_plugin.sh
528+
env:
529+
PLATFORM: ${platform}
528530

529531
pipeline:
530532
- command: subprocess.exec

.evergreen-snippets.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ variables:
77
- func: setup_mongosh
88
- func: download_kube_tools
99
- func: switch_context
10+
- func: python_venv
1011
- func: download_multi_cluster_binary
12+
vars:
13+
platform: linux/amd64
1114
teardown_task:
1215
- func: upload_e2e_logs
1316
- func: upload_code_snippets_logs

.evergreen.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ tasks:
358358
- func: clone
359359
- func: setup_building_host
360360
- func: download_multi_cluster_binary
361+
vars:
362+
platform: linux/amd64
361363
- func: pipeline
362364
vars:
363365
image_name: meko-tests
@@ -367,6 +369,8 @@ tasks:
367369
- func: clone
368370
- func: setup_building_host
369371
- func: download_multi_cluster_binary
372+
vars:
373+
platform: linux/arm64
370374
- func: pipeline
371375
vars:
372376
image_name: meko-tests-arm64
@@ -379,6 +383,8 @@ tasks:
379383
skip_minikube_setup: true
380384
skip_install_python_requirements: false
381385
- func: download_multi_cluster_binary
386+
vars:
387+
platform: linux/s390x
382388
- func: pipeline
383389
vars:
384390
image_name: meko-tests-ibm-z
@@ -391,6 +397,8 @@ tasks:
391397
skip_minikube_setup: true
392398
skip_install_python_requirements: false
393399
- func: download_multi_cluster_binary
400+
vars:
401+
platform: linux/ppc64le
394402
- func: pipeline
395403
vars:
396404
image_name: meko-tests-ibm-power

scripts/release/kubectl_mongodb/download_kubectl_plugin.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
import argparse
22
import os
3+
import shutil
34

45
from botocore.exceptions import ClientError
56

67
from lib.base_logger import logger
7-
from scripts.release.argparse_utils import get_platforms_from_arg, get_scenario_from_arg
8+
from scripts.release.argparse_utils import get_scenario_from_arg
89
from scripts.release.build.build_info import (
910
KUBECTL_PLUGIN_BINARY,
1011
load_build_info,
1112
)
1213
from scripts.release.build.build_scenario import SUPPORTED_SCENARIOS, BuildScenario
14+
from scripts.release.build.image_build_configuration import SUPPORTED_PLATFORMS
1315
from scripts.release.kubectl_mongodb.build_kubectl_plugin import (
1416
kubectl_plugin_name,
1517
parse_platform,
1618
s3_path,
1719
)
1820
from scripts.release.kubectl_mongodb.utils import create_s3_client
1921

22+
KUBECTL_MONGODB_PLUGIN_BIN_PATH = "bin/kubectl-mongodb"
23+
2024

2125
def local_tests_plugin_path(arch_name: str) -> str:
2226
return f"docker/mongodb-kubernetes-tests/multi-cluster-kube-config-creator_{arch_name}"
2327

2428

25-
def download_kubectl_plugin_from_s3(s3_bucket: str, s3_plugin_path: str, local_path: str):
29+
def download_kubectl_plugin_from_s3(
30+
s3_bucket: str, s3_plugin_path: str, local_path: str, copy_to_bin_path: bool = False
31+
) -> None:
2632
"""
2733
Downloads the plugin for provided platform and puts it in the path expected by the tests image
2834
"""
@@ -35,7 +41,12 @@ def download_kubectl_plugin_from_s3(s3_bucket: str, s3_plugin_path: str, local_p
3541
# change the file's permissions to make file executable
3642
os.chmod(local_path, 0o755)
3743

38-
logger.info(f"Successfully downloaded artifact to {local_path}")
44+
if copy_to_bin_path:
45+
shutil.copyfile(local_path, KUBECTL_MONGODB_PLUGIN_BIN_PATH)
46+
47+
logger.info(
48+
f"Successfully downloaded artifact to {local_path}{f" and {KUBECTL_MONGODB_PLUGIN_BIN_PATH}" if copy_to_bin_path else ""}"
49+
)
3950
except ClientError as e:
4051
if e.response["Error"]["Code"] == "404":
4152
raise Exception(f"Artifact not found at s3://{s3_bucket}/{s3_plugin_path}: {e}")
@@ -74,28 +85,25 @@ def main():
7485
"--platform",
7586
metavar="",
7687
action="store",
88+
required=True,
7789
type=str,
78-
help="Override the platforms instead of resolving from build scenario. Multi-arch builds are comma-separated. Example: linux/amd64,linux/arm64",
90+
choices=SUPPORTED_PLATFORMS,
91+
help=f"Specify kubectl-mongodb plugin platform to download. Options: {", ".join(SUPPORTED_PLATFORMS)}.",
7992
)
8093
args = parser.parse_args()
8194

8295
build_scenario = get_scenario_from_arg(args.build_scenario)
8396
build_info = load_build_info(build_scenario).binaries[KUBECTL_PLUGIN_BINARY]
8497

85-
platforms = get_platforms_from_arg(args.platform) or build_info.platforms
98+
platform = args.platform
8699
version = args.version
87100

88-
for platform in platforms:
89-
os_name, arch_name = parse_platform(platform)
90-
if os_name != "linux":
91-
logger.debug(f"Skipping non-linux platform {platform}, not used in e2e tests in Evergreen CI")
92-
continue
93-
94-
filename = kubectl_plugin_name(os_name, arch_name)
95-
s3_plugin_path = s3_path(filename, version)
96-
local_path = local_tests_plugin_path(arch_name)
101+
os_name, arch_name = parse_platform(platform)
102+
filename = kubectl_plugin_name(os_name, arch_name)
103+
s3_plugin_path = s3_path(filename, version)
104+
local_path = local_tests_plugin_path(arch_name)
97105

98-
download_kubectl_plugin_from_s3(build_info.s3_store, s3_plugin_path, local_path)
106+
download_kubectl_plugin_from_s3(build_info.s3_store, s3_plugin_path, local_path, copy_to_bin_path=True)
99107

100108

101109
if __name__ == "__main__":

scripts/release/kubectl_mongodb/download_kubectl_plugin.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -Eeou pipefail
44

55
source scripts/dev/set_env_context.sh
66

7-
scripts/dev/run_python.sh scripts/release/kubectl_mongodb/download_kubectl_plugin.py --build-scenario "${BUILD_SCENARIO}" --version "${OPERATOR_VERSION}"
7+
scripts/dev/run_python.sh scripts/release/kubectl_mongodb/download_kubectl_plugin.py --build-scenario "${BUILD_SCENARIO}" --version "${OPERATOR_VERSION}" --platform "${PLATFORM}"

0 commit comments

Comments
 (0)