From 33a8e2042ff6596b83f4de6d26127e7634c6e070 Mon Sep 17 00:00:00 2001 From: Boris Feld Date: Fri, 24 May 2019 11:44:59 +0200 Subject: [PATCH 1/3] Add support for specific Docker tag in spawn_data_pipeline.py --- infra/spawn_data_pipeline.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/infra/spawn_data_pipeline.py b/infra/spawn_data_pipeline.py index 3d3cb637be..1158be78f3 100644 --- a/infra/spawn_data_pipeline.py +++ b/infra/spawn_data_pipeline.py @@ -69,6 +69,8 @@ def main(): id_mapping = {} + docker_tag = os.getenv("DOCKER_TAG", None) + # First pass, do the template rendering and dependencies resolution tasks = [] @@ -105,6 +107,14 @@ def main(): payload["dependencies"] = new_dependencies + # Override the Docker image tag if needed + if docker_tag: + base_image = payload["payload"]["image"] + tagless_image = base_image.rsplit(":", 1)[0] + + new_image = "{}:{}".format(tagless_image, docker_tag) + payload["payload"]["image"] = new_image + tasks.append((task_id, payload)) # Now sends them From 2cf996f44f8b666ddaf38a4d2fa7a4dcca5c3a44 Mon Sep 17 00:00:00 2001 From: Boris Feld Date: Fri, 24 May 2019 12:23:40 +0200 Subject: [PATCH 2/3] Use the TAG env variable instead --- infra/spawn_data_pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/spawn_data_pipeline.py b/infra/spawn_data_pipeline.py index 1158be78f3..66f1fa3191 100644 --- a/infra/spawn_data_pipeline.py +++ b/infra/spawn_data_pipeline.py @@ -69,7 +69,7 @@ def main(): id_mapping = {} - docker_tag = os.getenv("DOCKER_TAG", None) + docker_tag = os.getenv("TAG", None) # First pass, do the template rendering and dependencies resolution tasks = [] From c80983c23464250cdf7159e4002c140b6d0704df Mon Sep 17 00:00:00 2001 From: Boris Feld Date: Fri, 24 May 2019 12:27:20 +0200 Subject: [PATCH 3/3] Check if there is an existing Docker tag Crash if it exists and it's not latest --- infra/spawn_data_pipeline.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/infra/spawn_data_pipeline.py b/infra/spawn_data_pipeline.py index 66f1fa3191..a38b76fc52 100644 --- a/infra/spawn_data_pipeline.py +++ b/infra/spawn_data_pipeline.py @@ -110,7 +110,13 @@ def main(): # Override the Docker image tag if needed if docker_tag: base_image = payload["payload"]["image"] - tagless_image = base_image.rsplit(":", 1)[0] + splitted_image = base_image.rsplit(":", 1) + + if len(splitted_image) > 1: + err_msg = "Docker tag should be None or 'latest', not {!r}" + assert splitted_image[1] == "latest", err_msg.format(splitted_image[1]) + + tagless_image = splitted_image[0] new_image = "{}:{}".format(tagless_image, docker_tag) payload["payload"]["image"] = new_image