diff --git a/.evergreen-functions.yml b/.evergreen-functions.yml index a300a7735..b56dd947a 100644 --- a/.evergreen-functions.yml +++ b/.evergreen-functions.yml @@ -396,29 +396,6 @@ functions: - bin binary: scripts/evergreen/e2e/dump_diagnostic_information_from_all_namespaces.sh - ### Publish and release image ### - - # Tags and pushes an image into an external Docker registry. The source image - # needs to exist before it can be pushed to a remote registry. - # It is expected that IMAGE_SOURCE is accessible with no authentication (like a - # local image), and the IMAGE_TARGET will be authenticated with DOCKER_* series of - # environment variables. - release_docker_image_to_registry: - - command: subprocess.exec - type: system - params: - working_dir: src/github.com/mongodb/mongodb-kubernetes - add_to_path: - - ${workdir}/bin - include_expansions_in_env: - - tag_source - - tag_dest - - image_source - - image_target - - docker_username - - docker_password - binary: scripts/evergreen/tag_push_docker_image.sh - # # Performs some AWS cleanup # @@ -431,33 +408,6 @@ functions: - ${workdir}/bin command: scripts/evergreen/prepare_aws.sh - build-dockerfiles: - - command: subprocess.exec - type: setup - params: - add_to_path: - - ${workdir}/bin - working_dir: src/github.com/mongodb/mongodb-kubernetes - binary: scripts/dev/run_python.sh scripts/update_supported_dockerfiles.py - - command: subprocess.exec - type: setup - params: - working_dir: src/github.com/mongodb/mongodb-kubernetes - include_expansions_in_env: - - triggered_by_git_tag - # if you ever change the target folder structure, the same needs to be reflected in PCT - command: "tar -czvf ./public/dockerfiles-${triggered_by_git_tag}.tgz ./public/dockerfiles" - - enable_QEMU: - - command: shell.exec - type: setup - params: - shell: bash - working_dir: src/github.com/mongodb/mongodb-kubernetes - script: | - echo "Enabling QEMU building for Docker" - docker run --rm --privileged 268558157000.dkr.ecr.eu-west-1.amazonaws.com/docker-hub-mirrors/multiarch/qemu-user-static --reset -p yes - # upload_e2e_logs has the responsibility of dumping as much information as # possible into the S3 bucket that corresponds to this ${version}. The # Kubernetes cluster where the test finished running, should still be diff --git a/Makefile b/Makefile index 42e37d7dc..40204ecf8 100644 --- a/Makefile +++ b/Makefile @@ -403,11 +403,6 @@ bundle: manifests kustomize bundle-build: docker build $(EXPIRES) --platform linux/amd64 -f ./bundle/$(VERSION)/bundle.Dockerfile -t $(BUNDLE_IMG) . -.PHONY: dockerfiles -dockerfiles: - python scripts/update_supported_dockerfiles.py - tar -czvf ./public/dockerfiles-$(VERSION).tgz ./public/dockerfiles - prepare-local-e2e: reset-mco # prepares the local environment to run a local operator scripts/dev/prepare_local_e2e_run.sh diff --git a/scripts/evergreen/tag_push_docker_image.sh b/scripts/evergreen/tag_push_docker_image.sh deleted file mode 100755 index 553c347cf..000000000 --- a/scripts/evergreen/tag_push_docker_image.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -set -Eeou pipefail - -source scripts/dev/set_env_context.sh - -# Evaluates a string passed as argument. -function evaluate { - val="${1}" - if [ ${#val} -gt 3 ] && [ "${val:0:1}" = "\$" ]; then - # Removes the first '$(' (dollar + open paren) and the - # last ')' (closing paren). - eval "${val:2:-1}" - return - fi - - echo "${val}" -} - -# We login into the destination registry for Redhat Connect or quay. -# The source registry is expected to be configured with a login manager (like ECR) or -# to be of local images. -docker_registry="$(echo "${image_target:?}"| cut -d / -f1)" -docker login "${docker_registry}" -u "${docker_username:?}" -p "${docker_password:?}" - -final_tag_source=$(evaluate "${tag_source:?}") -final_tag_dest=$(evaluate "${tag_dest:?}") - -echo "final_tag_source: |${final_tag_source}|" -echo "final_tag_dest: |${final_tag_dest}|" - -from="${image_source:?}:${final_tag_source}" -to="${image_target:?}:${final_tag_dest}" - -docker pull "${from}" -docker tag "${from}" "${to}" -docker push "${to}" - -docker image rmi "${from}" diff --git a/scripts/update_supported_dockerfiles.py b/scripts/update_supported_dockerfiles.py deleted file mode 100755 index 4effd8f50..000000000 --- a/scripts/update_supported_dockerfiles.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python3 -# - -import json -import os -import subprocess -import sys -from typing import Dict, List - -import requests -from git import Repo -from requests import Response - -from scripts.evergreen.release.agent_matrix import ( - get_supported_version_for_image, -) - - -def get_repo_root(): - output = subprocess.check_output("git rev-parse --show-toplevel".split()) - - return output.decode("utf-8").strip() - - -SUPPORTED_IMAGES = ( - "mongodb-agent", - "mongodb-enterprise-ops-manager", -) - -URL_LOCATION_BASE = "https://enterprise-operator-dockerfiles.s3.amazonaws.com/dockerfiles" - -LOCAL_DOCKERFILE_LOCATION = "public/dockerfiles" -DOCKERFILE_NAME = "Dockerfile" - - -def get_release() -> Dict[str, str]: - return json.load(open("release.json")) - - -def get_supported_variants_for_image(image: str) -> List[str]: - image = get_image_name(image) - - return get_release()["supportedImages"][image]["variants"] - - -def get_supported_version_for_image_mck(image: str) -> List[str]: - image = get_image_name(image) - - return get_supported_version_for_image(image) - - -def get_image_name(image): - if image == "mongodb-enterprise-ops-manager": - splitted_image_name = image.split("mongodb-enterprise-", 1) - else: - splitted_image_name = image.split("mongodb-kubernetes-", 1) - if len(splitted_image_name) == 2: - image = splitted_image_name[1] - return image - - -def download_dockerfile_from_s3(image: str, version: str, distro: str) -> Response: - url = f"{URL_LOCATION_BASE}/{image}/{version}/{distro}/Dockerfile" - return requests.get(url) - - -def git_add_dockerfiles(base_directory: str): - """Looks for all of the `Dockerfile`s in the public/dockerfiles - directory and stages them in git.""" - repo = Repo() - public_dir = os.path.join(get_repo_root(), LOCAL_DOCKERFILE_LOCATION) - - for root, _, files in os.walk(public_dir): - for fname in files: - if fname != DOCKERFILE_NAME: - continue - - repo.index.add(os.path.join(root, fname)) - - -def save_supported_dockerfiles(): - """ - Finds every supported release in the release.json and downloads the corresponding - Dockerfile. - """ - for image in SUPPORTED_IMAGES: - print("Image:", image) - versions = get_supported_version_for_image_mck(image) - for version in versions: - for variant in get_supported_variants_for_image(image): - response = download_dockerfile_from_s3(image, version, variant) - if response.ok: - dockerfile = response.text - docker_dir = f"{LOCAL_DOCKERFILE_LOCATION}/{image}/{version}/{variant}" - os.makedirs(docker_dir, exist_ok=True) - docker_path = os.path.join(docker_dir, DOCKERFILE_NAME) - with open(docker_path, "w") as fd: - fd.write(dockerfile) - print("* {} - {}: {}".format(version, variant, docker_path)) - else: - print("* {} - {}: does not exist".format(version, variant)) - - -def main() -> int: - save_supported_dockerfiles() - git_add_dockerfiles(LOCAL_DOCKERFILE_LOCATION) - - return 0 - - -if __name__ == "__main__": - sys.exit(main())