From 90678edb622ab1c445c107536bbc0d4cc03adfa7 Mon Sep 17 00:00:00 2001 From: Chi Chang Date: Tue, 30 May 2023 11:40:55 +0100 Subject: [PATCH] Fix docker image not pulled with --image option (#3614) --- paasta_tools/cli/cmds/spark_run.py | 38 ++++++++++++++++++------------ 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/paasta_tools/cli/cmds/spark_run.py b/paasta_tools/cli/cmds/spark_run.py index 72442c5e09..9c3d39d9a0 100644 --- a/paasta_tools/cli/cmds/spark_run.py +++ b/paasta_tools/cli/cmds/spark_run.py @@ -513,25 +513,33 @@ def get_docker_run_cmd( def get_docker_image( args: argparse.Namespace, instance_config: InstanceConfig ) -> Optional[str]: + """ + Since the Docker image digest used to launch the Spark cluster is obtained by inspecting local + Docker images, we need to ensure that the Docker image exists locally or is pulled in all scenarios. + """ + # docker image is built locally then pushed if args.build: return build_and_push_docker_image(args) + + docker_url = "" if args.image: - return args.image + docker_url = args.image + else: + try: + docker_url = instance_config.get_docker_url() + except NoDockerImageError: + print( + PaastaColors.red( + "Error: No sha has been marked for deployment for the %s deploy group.\n" + "Please ensure this service has either run through a jenkins pipeline " + "or paasta mark-for-deployment has been run for %s\n" + % (instance_config.get_deploy_group(), args.service) + ), + sep="", + file=sys.stderr, + ) + return None - try: - docker_url = instance_config.get_docker_url() - except NoDockerImageError: - print( - PaastaColors.red( - "Error: No sha has been marked for deployment for the %s deploy group.\n" - "Please ensure this service has either run through a jenkins pipeline " - "or paasta mark-for-deployment has been run for %s\n" - % (instance_config.get_deploy_group(), args.service) - ), - sep="", - file=sys.stderr, - ) - return None print( "Please wait while the image (%s) is pulled (times out after 5m)..." % docker_url,