Skip to content
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

Respect a service's docker_registry for adhoc spark-runs #3728

Merged
merged 1 commit into from
Oct 23, 2023
Merged
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
18 changes: 16 additions & 2 deletions paasta_tools/cli/cmds/spark_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import yaml
from boto3.exceptions import Boto3Error
from service_configuration_lib import read_service_configuration
from service_configuration_lib import spark_config
from service_configuration_lib.spark_config import get_aws_credentials
from service_configuration_lib.spark_config import get_grafana_url
Expand Down Expand Up @@ -218,7 +219,7 @@ def add_subparser(subparsers):
list_parser.add_argument(
"--docker-registry",
help="Docker registry to push the Spark image built.",
default=DEFAULT_SPARK_DOCKER_REGISTRY,
default=None,
)

list_parser.add_argument(
Expand Down Expand Up @@ -1036,6 +1037,14 @@ def get_docker_cmd(
return inject_spark_conf_str(original_docker_cmd, spark_conf_str)


def _get_adhoc_docker_registry(service: str, soa_dir: str = DEFAULT_SOA_DIR) -> str:
if service is None:
raise NotImplementedError('"None" is not a valid service')

service_configuration = read_service_configuration(service, soa_dir)
return service_configuration.get("docker_registry", DEFAULT_SPARK_DOCKER_REGISTRY)


def build_and_push_docker_image(args: argparse.Namespace) -> Optional[str]:
"""
Build an image if the default Spark service image is not preferred.
Expand All @@ -1059,7 +1068,12 @@ def build_and_push_docker_image(args: argparse.Namespace) -> Optional[str]:
if cook_return != 0:
return None

docker_url = f"{args.docker_registry}/{docker_tag}"
registry_uri = args.docker_registry or _get_adhoc_docker_registry(
service=args.service,
soa_dir=args.yelpsoa_config_root,
)
Comment on lines +1071 to +1074
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the intent here is to allow --docker-registry to override whatever is in yelpsoa


docker_url = f"{registry_uri}/{docker_tag}"
command = f"docker tag {docker_tag} {docker_url}"
print(PaastaColors.grey(command))
retcode, _ = _run(command, stream=True)
Expand Down
Loading