diff --git a/pipeline/console/container/build.py b/pipeline/console/container/build.py index 4f850447..15497700 100644 --- a/pipeline/console/container/build.py +++ b/pipeline/console/container/build.py @@ -25,7 +25,10 @@ def build_container(namespace: Namespace): pipeline_config = PipelineConfig.parse_obj(pipeline_config_yaml) - if pipeline_config.extras and pipeline_config.extras.get("turbo_registry", False): + turbo_registry = pipeline_config.extras and pipeline_config.extras.get( + "turbo_registry", False + ) + if turbo_registry: template = docker_templates.turbo_registry_template if not pipeline_config.runtime: @@ -83,6 +86,14 @@ def build_container(namespace: Namespace): docker_client = docker.from_env() new_container = docker_client.images.get(docker_image_id) + if turbo_registry: + if len(new_container.attrs["RootFS"]["Layers"]) > 1: + _print( + f"Turbo registry image built with multiple layers, this will cause issues with cold start optimization. Please contact Mystic support at support@mystic.ai", # noqa + "ERROR", + ) + raise Exception("Failed to build") + created_image_full_id = new_container.id.split(":")[1] created_image_short_id = created_image_full_id[:12] diff --git a/pipeline/console/container/push.py b/pipeline/console/container/push.py index efec1f92..9f53a296 100644 --- a/pipeline/console/container/push.py +++ b/pipeline/console/container/push.py @@ -87,7 +87,10 @@ def push_container(namespace: Namespace): docker_client: docker.DockerClient = docker.from_env(timeout=600) registry_params = {} - if pipeline_config.extras and pipeline_config.extras.get("turbo_registry", False): + turbo_registry = pipeline_config.extras and pipeline_config.extras.get( + "turbo_registry", False + ) + if turbo_registry: registry_params["turbo_registry"] = "yes" registry_info = http.get(endpoint="/v4/registry", params=registry_params) @@ -100,6 +103,14 @@ def push_container(namespace: Namespace): image = docker_client.images.get(pipeline_name) image_hash = image.id.split(":")[1] + if turbo_registry: + if len(image.attrs["RootFS"]["Layers"]) > 1: + _print( + f"Turbo registry image contains multiple layers, this will cause issues with cold start optimization. Please contact Mystic support at support@mystic.ai", # noqa + "ERROR", + ) + raise Exception("Failed to push") + hash_tag = image_hash[:12] image_to_push = pipeline_name + ":" + hash_tag image_to_push_reg = upload_registry + "/" + image_to_push @@ -148,7 +159,9 @@ def push_container(namespace: Namespace): pipeline_name = true_pipeline_name _push_docker_image( - docker_client=docker_client, image=image_to_push_reg, upload_token=upload_token + docker_client=docker_client, + image=image_to_push_reg, + upload_token=upload_token, ) new_deployment_request = http.post( @@ -183,7 +196,9 @@ def push_container(namespace: Namespace): def _push_docker_image( - docker_client: docker.DockerClient, image: str, upload_token: str + docker_client: docker.DockerClient, + image: str, + upload_token: str, ): resp = docker_client.images.push( image, diff --git a/pyproject.toml b/pyproject.toml index 3aa0f6f8..bc930ea0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pipeline-ai" -version = "2.4.0" +version = "2.4.1" description = "Pipelines for machine learning workloads." authors = [ "Paul Hetherington ",