Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .evergreen-functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ functions:
params:
working_dir: src/github.com/mongodb/mongodb-kubernetes
binary: scripts/release/kubectl_mongodb/download_kubectl_plugin.sh
env:
PLATFORM: ${platform}

pipeline:
- command: subprocess.exec
Expand Down
3 changes: 3 additions & 0 deletions .evergreen-snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ variables:
- func: setup_mongosh
- func: download_kube_tools
- func: switch_context
- func: python_venv
- func: download_multi_cluster_binary
vars:
platform: linux/amd64
teardown_task:
- func: upload_e2e_logs
- func: upload_code_snippets_logs
Expand Down
8 changes: 8 additions & 0 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ tasks:
- func: clone
- func: setup_building_host
- func: download_multi_cluster_binary
vars:
platform: linux/amd64
- func: pipeline
vars:
image_name: meko-tests
Expand All @@ -367,6 +369,8 @@ tasks:
- func: clone
- func: setup_building_host
- func: download_multi_cluster_binary
vars:
platform: linux/arm64
- func: pipeline
vars:
image_name: meko-tests-arm64
Expand All @@ -379,6 +383,8 @@ tasks:
skip_minikube_setup: true
skip_install_python_requirements: false
- func: download_multi_cluster_binary
vars:
platform: linux/s390x
- func: pipeline
vars:
image_name: meko-tests-ibm-z
Expand All @@ -391,6 +397,8 @@ tasks:
skip_minikube_setup: true
skip_install_python_requirements: false
- func: download_multi_cluster_binary
vars:
platform: linux/ppc64le
- func: pipeline
vars:
image_name: meko-tests-ibm-power
Expand Down
38 changes: 23 additions & 15 deletions scripts/release/kubectl_mongodb/download_kubectl_plugin.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
import argparse
import os
import shutil

from botocore.exceptions import ClientError

from lib.base_logger import logger
from scripts.release.argparse_utils import get_platforms_from_arg, get_scenario_from_arg
from scripts.release.argparse_utils import get_scenario_from_arg
from scripts.release.build.build_info import (
KUBECTL_PLUGIN_BINARY,
load_build_info,
)
from scripts.release.build.build_scenario import SUPPORTED_SCENARIOS, BuildScenario
from scripts.release.build.image_build_configuration import SUPPORTED_PLATFORMS
from scripts.release.kubectl_mongodb.build_kubectl_plugin import (
kubectl_plugin_name,
parse_platform,
s3_path,
)
from scripts.release.kubectl_mongodb.utils import create_s3_client

KUBECTL_MONGODB_PLUGIN_BIN_PATH = "bin/kubectl-mongodb"


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


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

logger.info(f"Successfully downloaded artifact to {local_path}")
if copy_to_bin_path:
shutil.copyfile(local_path, KUBECTL_MONGODB_PLUGIN_BIN_PATH)

logger.info(
f"Successfully downloaded artifact to {local_path}{f" and {KUBECTL_MONGODB_PLUGIN_BIN_PATH}" if copy_to_bin_path else ""}"
)
except ClientError as e:
if e.response["Error"]["Code"] == "404":
raise Exception(f"Artifact not found at s3://{s3_bucket}/{s3_plugin_path}: {e}")
Expand Down Expand Up @@ -74,28 +85,25 @@ def main():
"--platform",
metavar="",
action="store",
required=True,
type=str,
help="Override the platforms instead of resolving from build scenario. Multi-arch builds are comma-separated. Example: linux/amd64,linux/arm64",
choices=SUPPORTED_PLATFORMS,
help=f"Specify kubectl-mongodb plugin platform to download. Options: {", ".join(SUPPORTED_PLATFORMS)}.",
)
args = parser.parse_args()

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

platforms = get_platforms_from_arg(args.platform) or build_info.platforms
platform = args.platform
version = args.version

for platform in platforms:
os_name, arch_name = parse_platform(platform)
if os_name != "linux":
logger.debug(f"Skipping non-linux platform {platform}, not used in e2e tests in Evergreen CI")
continue

filename = kubectl_plugin_name(os_name, arch_name)
s3_plugin_path = s3_path(filename, version)
local_path = local_tests_plugin_path(arch_name)
os_name, arch_name = parse_platform(platform)
filename = kubectl_plugin_name(os_name, arch_name)
s3_plugin_path = s3_path(filename, version)
local_path = local_tests_plugin_path(arch_name)

download_kubectl_plugin_from_s3(build_info.s3_store, s3_plugin_path, local_path)
download_kubectl_plugin_from_s3(build_info.s3_store, s3_plugin_path, local_path, copy_to_bin_path=True)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -Eeou pipefail

source scripts/dev/set_env_context.sh

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