From 93b282a460cec657538200a12ae60ae4de059294 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 9 Oct 2020 00:07:56 +0000 Subject: [PATCH] Bug 1651538 - Relabel docker images with the prefix "docker-image" instead of "build-docker-image". r=tomprince Differential Revision: https://phabricator.services.mozilla.com/D82807 --- taskcluster/docs/kinds.rst | 2 +- taskcluster/taskgraph/docker.py | 2 +- taskcluster/taskgraph/morph.py | 2 +- taskcluster/taskgraph/task.py | 4 +--- taskcluster/taskgraph/test/test_morph.py | 2 +- taskcluster/taskgraph/transforms/cached_tasks.py | 5 +---- taskcluster/taskgraph/transforms/docker_image.py | 6 +++--- taskcluster/taskgraph/transforms/task.py | 2 +- 8 files changed, 10 insertions(+), 15 deletions(-) diff --git a/taskcluster/docs/kinds.rst b/taskcluster/docs/kinds.rst index 846e521b19f3..a16dacb35b99 100644 --- a/taskcluster/docs/kinds.rst +++ b/taskcluster/docs/kinds.rst @@ -192,7 +192,7 @@ Tasks of the ``docker-image`` kind build the Docker images in which other Docker tasks run. The tasks to generate each docker image have predictable labels: -``build-docker-image-``. +``docker-image-``. Docker images are built from subdirectories of ``taskcluster/docker``, using ``docker build``. There is currently no capability for one Docker image to diff --git a/taskcluster/taskgraph/docker.py b/taskcluster/taskgraph/docker.py index 2fe7ae84baf5..ca92c82bfed2 100644 --- a/taskcluster/taskgraph/docker.py +++ b/taskcluster/taskgraph/docker.py @@ -25,7 +25,7 @@ from . import GECKO def load_image_by_name(image_name, tag=None): params = {'level': six.ensure_text(os.environ.get('MOZ_SCM_LEVEL', '3'))} tasks = load_tasks_for_kind(params, 'docker-image') - task = tasks['build-docker-image-{}'.format(image_name)] + task = tasks['docker-image-{}'.format(image_name)] task_id = IndexSearch().should_replace_task( task, {}, task.optimization.get('index-search', [])) diff --git a/taskcluster/taskgraph/morph.py b/taskcluster/taskgraph/morph.py index b6ad96f1766e..bf3d48687860 100644 --- a/taskcluster/taskgraph/morph.py +++ b/taskcluster/taskgraph/morph.py @@ -68,7 +68,7 @@ def derive_misc_task( # this is why all docker image tasks are included in the target task graph: we # need to find them in label_to_taskid, even if nothing else required them - image_taskid = label_to_taskid["build-docker-image-" + image] + image_taskid = label_to_taskid["docker-image-" + image] provisioner_id, worker_type = get_worker_type( graph_config, "misc", parameters["level"], parameters.release_level() diff --git a/taskcluster/taskgraph/task.py b/taskcluster/taskgraph/task.py index 24fe12449057..3b699e31a5bc 100644 --- a/taskcluster/taskgraph/task.py +++ b/taskcluster/taskgraph/task.py @@ -18,7 +18,7 @@ class Task(object): - task: the task definition (JSON-able dictionary) - optimization: optimization to apply to the task (see taskgraph.optimize) - dependencies: tasks this one depends on, in the form {name: label}, for example - {'build': 'build-linux64/opt', 'docker-image': 'build-docker-image-desktop-test'} + {'build': 'build-linux64/opt', 'docker-image': 'docker-image-desktop-test'} - soft_dependencies: tasks this one may depend on if they are available post optimisation. They are set as a list of tasks label. - if_dependencies: only run this task if at least one of these dependencies @@ -54,8 +54,6 @@ class Task(object): def name(self): if self.label.startswith(self.kind + "-"): return self.label[len(self.kind)+1:] - elif self.label.startswith("build-docker-image-"): - return self.label[len("build-docker-image-"):] else: raise AttributeError("Task {} does not have a name.".format(self.label)) diff --git a/taskcluster/taskgraph/test/test_morph.py b/taskcluster/taskgraph/test/test_morph.py index 2f553fd056da..f7e114dc8066 100644 --- a/taskcluster/taskgraph/test/test_morph.py +++ b/taskcluster/taskgraph/test/test_morph.py @@ -82,7 +82,7 @@ def test_make_index_tasks(make_taskgraph, graph_config): }, } task = Task(kind='test', label='a', attributes={}, task=task_def) - docker_task = Task(kind='docker-image', label='build-docker-image-index-task', + docker_task = Task(kind='docker-image', label='docker-image-index-task', attributes={}, task={}) taskgraph, label_to_taskid = make_taskgraph({ task.label: task, diff --git a/taskcluster/taskgraph/transforms/cached_tasks.py b/taskcluster/taskgraph/transforms/cached_tasks.py index 7822831c99fd..193312515b0d 100644 --- a/taskcluster/taskgraph/transforms/cached_tasks.py +++ b/taskcluster/taskgraph/transforms/cached_tasks.py @@ -14,10 +14,7 @@ transforms = TransformSequence() def order_tasks(config, tasks): """Iterate image tasks in an order where parent tasks come first.""" - if config.kind == 'docker-image': - kind_prefix = 'build-docker-image-' - else: - kind_prefix = config.kind + '-' + kind_prefix = config.kind + '-' pending = deque(tasks) task_labels = {task['label'] for task in pending} diff --git a/taskcluster/taskgraph/transforms/docker_image.py b/taskcluster/taskgraph/transforms/docker_image.py index 82dde5c86118..63c433c62c38 100644 --- a/taskcluster/taskgraph/transforms/docker_image.py +++ b/taskcluster/taskgraph/transforms/docker_image.py @@ -138,7 +138,7 @@ def fill_template(config, tasks): # include some information that is useful in reconstructing this task # from JSON taskdesc = { - 'label': 'build-docker-image-' + image_name, + 'label': '{}-{}'.format(config.kind, image_name), 'description': description, 'attributes': { 'image_name': image_name, @@ -191,7 +191,7 @@ def fill_template(config, tasks): else: worker['docker-image'] = {'in-tree': 'image_builder'} deps = taskdesc.setdefault('dependencies', {}) - deps['docker-image'] = 'build-docker-image-image_builder' + deps['docker-image'] = '{}-image_builder'.format(config.kind) if packages: deps = taskdesc.setdefault('dependencies', {}) @@ -200,7 +200,7 @@ def fill_template(config, tasks): if parent: deps = taskdesc.setdefault('dependencies', {}) - deps['parent'] = 'build-docker-image-{}'.format(parent) + deps['parent'] = '{}-{}'.format(config.kind, parent) worker['env']['PARENT_TASK_ID'] = { 'task-reference': '', } diff --git a/taskcluster/taskgraph/transforms/task.py b/taskcluster/taskgraph/transforms/task.py index 5312a284b41d..d907c6b24580 100644 --- a/taskcluster/taskgraph/transforms/task.py +++ b/taskcluster/taskgraph/transforms/task.py @@ -448,7 +448,7 @@ def build_docker_worker_payload(config, task, task_def): if isinstance(image, dict): if 'in-tree' in image: name = image['in-tree'] - docker_image_task = 'build-docker-image-' + image['in-tree'] + docker_image_task = 'docker-image-' + image['in-tree'] task.setdefault('dependencies', {})['docker-image'] = docker_image_task image = {