Skip to content

WIP: Rename --include to --image and remove build_all_images func #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: simon/remove-unused-params
Choose a base branch
from
Draft
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: 1 addition & 1 deletion .evergreen-functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ functions:
shell: bash
<<: *e2e_include_expansions_in_env
working_dir: src/github.com/mongodb/mongodb-kubernetes
binary: scripts/evergreen/run_python.sh pipeline.py --include ${image_name} --parallel --sign
binary: scripts/evergreen/run_python.sh pipeline.py --image ${image_name} --parallel --sign

teardown_cloud_qa_all:
- *switch_context
Expand Down
28 changes: 14 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ operator: configure-operator build-and-push-operator-image

# build-push, (todo) restart database
database: aws_login
@ scripts/evergreen/run_python.sh pipeline.py --include database
@ scripts/evergreen/run_python.sh pipeline.py --image database

readiness_probe: aws_login
@ scripts/evergreen/run_python.sh pipeline.py --include readiness-probe
@ scripts/evergreen/run_python.sh pipeline.py --image readiness-probe

upgrade_hook: aws_login
@ scripts/evergreen/run_python.sh pipeline.py --include upgrade-hook
@ scripts/evergreen/run_python.sh pipeline.py --image upgrade-hook

# ensures cluster is up, cleans Kubernetes + OM, build-push-deploy operator,
# push-deploy database, create secrets, config map, resources etc
Expand All @@ -84,7 +84,7 @@ full: build-and-push-images

# build-push appdb image
appdb: aws_login
@ scripts/evergreen/run_python.sh pipeline.py --include appdb
@ scripts/evergreen/run_python.sh pipeline.py --image appdb

# runs the e2e test: make e2e test=e2e_sharded_cluster_pv. The Operator is redeployed before the test, the namespace is cleaned.
# The e2e test image is built and pushed together with all main ones (operator, database, init containers)
Expand Down Expand Up @@ -148,19 +148,19 @@ aws_cleanup:
@ scripts/evergreen/prepare_aws.sh

build-and-push-operator-image: aws_login
@ scripts/evergreen/run_python.sh pipeline.py --include operator-quick
@ scripts/evergreen/run_python.sh pipeline.py --image operator-quick

build-and-push-database-image: aws_login
@ scripts/dev/build_push_database_image

build-and-push-test-image: aws_login build-multi-cluster-binary
@ if [[ -z "$(local)" ]]; then \
scripts/evergreen/run_python.sh pipeline.py --include test; \
scripts/evergreen/run_python.sh pipeline.py --image test; \
fi

build-and-push-mco-test-image: aws_login
@ if [[ -z "$(local)" ]]; then \
scripts/evergreen/run_python.sh pipeline.py --include mco-test; \
scripts/evergreen/run_python.sh pipeline.py --image mco-test; \
fi

build-multi-cluster-binary:
Expand All @@ -175,27 +175,27 @@ build-and-push-images: build-and-push-operator-image appdb-init-image om-init-im
build-and-push-init-images: appdb-init-image om-init-image database-init-image

database-init-image:
@ scripts/evergreen/run_python.sh pipeline.py --include init-database
@ scripts/evergreen/run_python.sh pipeline.py --image init-database

appdb-init-image:
@ scripts/evergreen/run_python.sh pipeline.py --include init-appdb
@ scripts/evergreen/run_python.sh pipeline.py --image init-appdb

# Not setting a parallel-factor will default to 0 which will lead to using all CPUs, that can cause docker to die.
# Here we are defaulting to 6, a higher value might work for you.
agent-image:
@ scripts/evergreen/run_python.sh pipeline.py --include agent --all-agents --parallel --parallel-factor 6
@ scripts/evergreen/run_python.sh pipeline.py --image agent --all-agents --parallel --parallel-factor 6

agent-image-slow:
@ scripts/evergreen/run_python.sh pipeline.py --include agent --parallel-factor 1
@ scripts/evergreen/run_python.sh pipeline.py --image agent --parallel-factor 1

operator-image:
@ scripts/evergreen/run_python.sh pipeline.py --include operator
@ scripts/evergreen/run_python.sh pipeline.py --image operator

om-init-image:
@ scripts/evergreen/run_python.sh pipeline.py --include init-ops-manager
@ scripts/evergreen/run_python.sh pipeline.py --image init-ops-manager

om-image:
@ scripts/evergreen/run_python.sh pipeline.py --include ops-manager
@ scripts/evergreen/run_python.sh pipeline.py --image ops-manager

configure-operator:
@ scripts/dev/configure_operator.sh
Expand Down
39 changes: 9 additions & 30 deletions pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,31 +1498,11 @@ def build_image(image_name: str, build_configuration: BuildConfiguration):
get_builder_function_for_image_name()[image_name](build_configuration)


def build_all_images(
images: Iterable[str],
builder: str,
debug: bool = False,
parallel: bool = False,
architecture: Optional[List[str]] = None,
sign: bool = False,
all_agents: bool = False,
parallel_factor: int = 0,
):
"""Builds all the images in the `images` list."""
build_configuration = operator_build_configuration(
builder, parallel, debug, architecture, sign, all_agents, parallel_factor
)
if sign:
mongodb_artifactory_login()
for image in images:
build_image(image, build_configuration)


def main():
_setup_tracing()

parser = argparse.ArgumentParser()
parser.add_argument("--include", required=True)
parser.add_argument("--image", required=True)
parser.add_argument("--builder", default="docker", type=str)
parser.add_argument("--list-images", action="store_true")
parser.add_argument("--parallel", action="store_true", default=False)
Expand Down Expand Up @@ -1560,18 +1540,15 @@ def main():
if not args.sign:
logger.warning("--sign flag not provided, images won't be signed")

if args.include is None:
print("No images to build, --include is required.")
if args.image not in get_builder_function_for_image_name():
print("Image {} not found".format(args.image))
sys.exit(1)

image_to_build = args.include
if args.include not in get_builder_function_for_image_name():
print("Image {} not found".format(args.include))
sys.exit(1)
if args.sign:
mongodb_artifactory_login()

build_all_images(
image_to_build,
args.builder,
build_configuration = operator_build_configuration(
builder=args.builder,
debug=args.debug,
parallel=args.parallel,
architecture=args.arch,
Expand All @@ -1580,6 +1557,8 @@ def main():
parallel_factor=args.parallel_factor,
)

build_image(args.image, build_configuration)


if __name__ == "__main__":
main()