Bug 1305139 - schedule checksums related tasks in nightly graph. r=aki,Callek

MozReview-Commit-ID: 659wCXm3ob5

--HG--
extra : rebase_source : 356175ba6ffa8678f412d333376d3a86e7919988
This commit is contained in:
Mihai Tabara 2017-02-07 22:44:12 -05:00
Родитель 35f3b97b30
Коммит 0065603413
14 изменённых файлов: 397 добавлений и 107 удалений

Просмотреть файл

@ -0,0 +1,12 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
implementation: taskgraph.task.beetmover_checksums:BeetmoverChecksumsTask
transforms:
- taskgraph.transforms.beetmover_checksums:transforms
- taskgraph.transforms.task:transforms
kind-dependencies:
- checksums-signing

Просмотреть файл

@ -10,5 +10,4 @@ transforms:
- taskgraph.transforms.task:transforms
kind-dependencies:
- nightly-l10n
- nightly-l10n-signing

Просмотреть файл

@ -9,5 +9,4 @@ transforms:
- taskgraph.transforms.task:transforms
kind-dependencies:
- build
- build-signing

Просмотреть файл

@ -0,0 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
implementation: taskgraph.task.checksums_signing:ChecksumsSigningTask
transforms:
- taskgraph.transforms.checksums_signing:transforms
- taskgraph.transforms.task:transforms
kind-dependencies:
- beetmover
- beetmover-l10n

Просмотреть файл

@ -188,3 +188,15 @@ of Taskcluster's task artifacts, (archive.mozilla.org as one place) and in the
process determines the final location and a "pretty" name (versioned product name)
This separate kind uses logic specific to localized artifacts, such as including
the language in the final artifact names.
checksums-signing
----------------
Checksums-signing take as input the checksums file generated by beetmover tasks
and sign it via the signing scriptworkers. Returns the same file signed and
additional detached signature.
beetmover-checksums
-------------------
Beetmover, takes specific artifact checksums and pushes it to a location outside
of Taskcluster's task artifacts (archive.mozilla.org as one place) and in the
process determines the final location and "pretty" names it (version product name)

Просмотреть файл

@ -9,25 +9,20 @@ from . import transform
class BeetmoverTask(transform.TransformTask):
"""
A task implementing a signing job. These depend on nightly build jobs and
sign the artifacts after a build has completed.
We use a dictionary to create the input to the transforms.
It will have added to it keys `build-label`, the label for the build task,
and `build-platform` / `build-type`, its platform and type.
A task implementing a beetmover job. These depend on nightly build and signing
jobs and transfer the artifacts to S3 after build and signing are completed.
"""
@classmethod
def get_inputs(cls, kind, path, config, params, loaded_tasks):
if config.get('kind-dependencies', []) != ["build", "build-signing"] and \
config.get('kind-dependencies', []) != ["nightly-l10n", "nightly-l10n-signing"]:
if config.get('kind-dependencies', []) != ["build-signing"] and \
config.get('kind-dependencies', []) != ["nightly-l10n-signing"]:
raise Exception("Beetmover kinds must depend on builds or signing builds")
for task in loaded_tasks:
if not task.attributes.get('nightly'):
continue
if task.kind not in config.get('kind-dependencies'):
continue
beetmover_task = {}
beetmover_task['dependent-task'] = task
beetmover_task = {'dependent-task': task}
yield beetmover_task

Просмотреть файл

@ -0,0 +1,28 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
from . import transform
class BeetmoverChecksumsTask(transform.TransformTask):
"""
A task implementing a beetmover job specific for checksums.These depend on
the checksums signing jobs and transfer the checksums files to S3 after
it's being generated and signed.
"""
@classmethod
def get_inputs(cls, kind, path, config, params, loaded_tasks):
if config.get('kind-dependencies', []) != ["checksums-signing"]:
raise Exception("Beetmover checksums tasks depend on checksums signing tasks")
for task in loaded_tasks:
if not task.attributes.get('nightly'):
continue
if task.kind not in config.get('kind-dependencies'):
continue
beetmover_checksums_task = {'dependent-task': task}
yield beetmover_checksums_task

Просмотреть файл

@ -0,0 +1,27 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
from . import transform
class ChecksumsSigningTask(transform.TransformTask):
"""
A task implementing a checksums signing job. These depend on beetmover jobs
and sign the checksums after its being generated by beetmover
"""
@classmethod
def get_inputs(cls, kind, path, config, params, loaded_tasks):
if (config.get('kind-dependencies', []) != ["beetmover", "beetmover-l10n"]):
raise Exception("Checksums signing tasks must depend on beetmover tasks")
for task in loaded_tasks:
if not task.attributes.get('nightly'):
continue
if task.kind not in config.get('kind-dependencies'):
continue
checksums_signing_task = {'dependent-task': task}
yield checksums_signing_task

Просмотреть файл

@ -174,26 +174,22 @@ def make_task_description(config, jobs):
dep_job = job['dependent-task']
treeherder = job.get('treeherder', {})
treeherder.setdefault('symbol', 'tc(BM-S)')
dep_th_platform = dep_job.task.get('extra', {}).get(
'treeherder', {}).get('machine', {}).get('platform', '')
treeherder.setdefault('platform',
"{}/opt".format(dep_th_platform))
treeherder.setdefault('tier', 1)
treeherder.setdefault('kind', 'build')
label = job.get('label', "beetmover-{}".format(dep_job.label))
dependent_kind = str(dep_job.kind)
dependencies = {dependent_kind: dep_job.label}
# taskid_of_manifest always refers to the unsigned task
if "signing" in dependent_kind:
if len(dep_job.dependencies) > 1:
raise NotImplementedError(
"can't beetmove a signing task with multiple dependencies")
"Can't beetmove a signing task with multiple dependencies")
signing_dependencies = dep_job.dependencies
dependencies.update(signing_dependencies)
treeherder.setdefault('symbol', 'tc(BM-S)')
else:
treeherder.setdefault('symbol', 'tc(BM)')
attributes = {
'nightly': dep_job.attributes.get('nightly', False),
@ -207,9 +203,7 @@ def make_task_description(config, jobs):
'label': label,
'description': "{} Beetmover".format(
dep_job.task["metadata"]["description"]),
# do we have to define worker type somewhere?
'worker-type': 'scriptworker-prov-v1/beetmoverworker-v1',
# bump this to nightly / release when applicable+permitted
'scopes': ["project:releng:beetmover:nightly"],
'dependencies': dependencies,
'attributes': attributes,
@ -220,12 +214,10 @@ def make_task_description(config, jobs):
yield task
def generate_upstream_artifacts(taskid_to_beetmove, platform, locale=None, signing=False):
task_type = "build"
mapping = UPSTREAM_ARTIFACT_UNSIGNED_PATHS
if signing:
task_type = "signing"
mapping = UPSTREAM_ARTIFACT_SIGNED_PATHS
def generate_upstream_artifacts(signing_task_ref, build_task_ref, platform,
locale=None):
build_mapping = UPSTREAM_ARTIFACT_UNSIGNED_PATHS
signing_mapping = UPSTREAM_ARTIFACT_SIGNED_PATHS
artifact_prefix = 'public/build'
if locale:
@ -233,92 +225,67 @@ def generate_upstream_artifacts(taskid_to_beetmove, platform, locale=None, signi
platform = "{}-l10n".format(platform)
upstream_artifacts = [{
"taskId": {"task-reference": taskid_to_beetmove},
"taskType": task_type,
"paths": ["{}/{}".format(artifact_prefix, p) for p in mapping[platform]],
"taskId": {"task-reference": build_task_ref},
"taskType": "build",
"paths": ["{}/{}".format(artifact_prefix, p)
for p in build_mapping[platform]],
"locale": locale or "en-US",
}, {
"taskId": {"task-reference": signing_task_ref},
"taskType": "signing",
"paths": ["{}/{}".format(artifact_prefix, p)
for p in signing_mapping[platform]],
"locale": locale or "en-US",
}]
if not locale and "android" in platform:
# edge case to support 'multi' locale paths
multi_platform = "{}-multi".format(platform)
upstream_artifacts.append({
"taskId": {"task-reference": taskid_to_beetmove},
"taskType": task_type,
"paths": ["{}/{}".format(artifact_prefix, p) for p in mapping[multi_platform]],
"locale": "multi",
})
return upstream_artifacts
def generate_signing_upstream_artifacts(taskid_to_beetmove, taskid_of_manifest, platform,
locale=None):
upstream_artifacts = generate_upstream_artifacts(taskid_to_beetmove, platform, locale,
signing=True)
if locale:
artifact_prefix = 'public/build/{}'.format(locale)
else:
artifact_prefix = 'public/build'
manifest_path = "{}/balrog_props.json".format(artifact_prefix)
upstream_artifacts.append({
"taskId": {"task-reference": taskid_of_manifest},
upstream_artifacts.extend([{
"taskId": {"task-reference": build_task_ref},
"taskType": "build",
"paths": [manifest_path],
"locale": locale or "en-US",
})
"paths": ["{}/{}".format(artifact_prefix, p)
for p in build_mapping[multi_platform]],
"locale": "multi",
}, {
"taskId": {"task-reference": signing_task_ref},
"taskType": "signing",
"paths": ["{}/{}".format(artifact_prefix, p)
for p in signing_mapping[multi_platform]],
"locale": "multi",
}])
return upstream_artifacts
def generate_build_upstream_artifacts(taskid_to_beetmove, platform, locale=None):
upstream_artifacts = generate_upstream_artifacts(taskid_to_beetmove, platform, locale,
signing=False)
return upstream_artifacts
@transforms.add
def make_task_worker(config, jobs):
for job in jobs:
valid_beetmover_signing_job = (len(job["dependencies"]) == 2 and
valid_beetmover_job = (len(job["dependencies"]) == 2 and
any(['signing' in j for j in job['dependencies']]))
valid_beetmover_build_job = len(job["dependencies"]) == 1
if not valid_beetmover_build_job and not valid_beetmover_signing_job:
raise NotImplementedError(
"beetmover tasks must have either 1 or 2 dependencies. "
"If 2, one of those must be a signing task"
)
if not valid_beetmover_job:
raise NotImplementedError("Beetmover must have two dependencies.")
build_kind = None
signing_kind = None
locale = job["attributes"].get("locale")
platform = job["attributes"]["build_platform"]
build_task = None
signing_task = None
for dependency in job["dependencies"].keys():
if 'signing' in dependency:
signing_kind = dependency
signing_task = dependency
else:
build_kind = dependency
build_task = dependency
if signing_kind:
taskid_to_beetmove = "<" + str(signing_kind) + ">"
taskid_of_manifest = "<" + str(build_kind) + ">"
update_manifest = True
upstream_artifacts = generate_signing_upstream_artifacts(
taskid_to_beetmove, taskid_of_manifest, platform, locale
)
else:
taskid_to_beetmove = "<" + str(build_kind) + ">"
update_manifest = False
upstream_artifacts = generate_build_upstream_artifacts(
taskid_to_beetmove, platform, locale
signing_task_ref = "<" + str(signing_task) + ">"
build_task_ref = "<" + str(build_task) + ">"
upstream_artifacts = generate_upstream_artifacts(
signing_task_ref, build_task_ref, platform, locale
)
worker = {'implementation': 'beetmover',
'update_manifest': update_manifest,
'upstream-artifacts': upstream_artifacts}
if locale:
worker["locale"] = locale
job["worker"] = worker
yield job

Просмотреть файл

@ -0,0 +1,149 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Transform the checksums signing task into an actual task description.
"""
from __future__ import absolute_import, print_function, unicode_literals
from taskgraph.transforms.base import TransformSequence
from taskgraph.util.schema import validate_schema
from taskgraph.transforms.task import task_description_schema
from voluptuous import Schema, Any, Required, Optional
# Voluptuous uses marker objects as dictionary *keys*, but they are not
# comparable, so we cast all of the keys back to regular strings
task_description_schema = {str(k): v for k, v in task_description_schema.schema.iteritems()}
transforms = TransformSequence()
taskref_or_string = Any(
basestring,
{Required('task-reference'): basestring})
beetmover_checksums_description_schema = Schema({
Required('dependent-task'): object,
Required('depname', default='build'): basestring,
Optional('label'): basestring,
Optional('treeherder'): task_description_schema['treeherder'],
Optional('locale'): basestring,
})
@transforms.add
def validate(config, jobs):
for job in jobs:
label = job.get('dependent-task', object).__dict__.get('label', '?no-label?')
yield validate_schema(
beetmover_checksums_description_schema, job,
"In checksums-signing ({!r} kind) task for {!r}:".format(config.kind, label))
@transforms.add
def make_beetmover_checksums_description(config, jobs):
for job in jobs:
dep_job = job['dependent-task']
treeherder = job.get('treeherder', {})
treeherder.setdefault('symbol', 'tc-BMcs(N)')
dep_th_platform = dep_job.task.get('extra', {}).get(
'treeherder', {}).get('machine', {}).get('platform', '')
treeherder.setdefault('platform',
"{}/opt".format(dep_th_platform))
treeherder.setdefault('tier', 1)
treeherder.setdefault('kind', 'build')
label = job.get('label', "beetmover-{}".format(dep_job.label))
dependent_kind = str(dep_job.kind)
dependencies = {dependent_kind: dep_job.label}
for k, v in dep_job.dependencies.items():
if k.startswith('beetmover'):
dependencies[k] = v
attributes = {
'nightly': dep_job.attributes.get('nightly', False),
'build_platform': dep_job.attributes.get('build_platform'),
'build_type': dep_job.attributes.get('build_type'),
}
if dep_job.attributes.get('locale'):
treeherder['symbol'] = 'tc-BMcs({})'.format(dep_job.attributes.get('locale'))
attributes['locale'] = dep_job.attributes.get('locale')
task = {
'label': label,
'description': "Beetmover {} ".format(
dep_job.task["metadata"]["description"]),
'worker-type': 'scriptworker-prov-v1/beetmoverworker-v1',
'scopes': ["project:releng:beetmover:nightly"],
'dependencies': dependencies,
'attributes': attributes,
'run-on-projects': dep_job.attributes.get('run_on_projects'),
'treeherder': treeherder,
}
yield task
def generate_upstream_artifacts(refs, platform, locale=None):
common_paths = [
"public/target.checksums",
"public/target.checksums.asc",
]
upstream_artifacts = [{
"taskId": {"task-reference": refs["signing"]},
"taskType": "signing",
"paths": common_paths,
"locale": locale or "en-US",
}, {
"taskId": {"task-reference": refs["beetmover"]},
"taskType": "beetmover",
"paths": ["public/balrog_props.json"],
"locale": locale or "en-US",
}]
if not locale and "android" in platform:
# edge case to support 'multi' locale paths
upstream_artifacts.extend([{
"taskId": {"task-reference": refs["signing"]},
"taskType": "signing",
"paths": common_paths,
"locale": "multi"
}])
return upstream_artifacts
@transforms.add
def make_beetmover_checksums_worker(config, jobs):
for job in jobs:
valid_beetmover_job = (len(job["dependencies"]) == 2)
if not valid_beetmover_job:
raise NotImplementedError("Beetmover checksums must have two dependencies.")
locale = job["attributes"].get("locale")
platform = job["attributes"]["build_platform"]
refs = {
"beetmover": None,
"signing": None,
}
for dependency in job["dependencies"].keys():
if dependency.startswith("beetmover"):
refs['beetmover'] = "<{}>".format(dependency)
else:
refs['signing'] = "<{}>".format(dependency)
if None in refs.values():
raise NotImplementedError("Beetmover checksums must have a beetmover and signing dependency!")
upstream_artifacts = generate_upstream_artifacts(refs,
platform, locale)
worker = {'implementation': 'beetmover',
'upstream-artifacts': upstream_artifacts}
if locale:
worker["locale"] = locale
job["worker"] = worker
yield job

Просмотреть файл

@ -25,9 +25,6 @@ def make_beetmover_description(config, jobs):
group = 'tc-BM-L10n'
# add the locale code
if 'signing' in label:
symbol = 'S{}'.format(locale)
else:
symbol = locale
treeherder = {

Просмотреть файл

@ -0,0 +1,95 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Transform the checksums signing task into an actual task description.
"""
from __future__ import absolute_import, print_function, unicode_literals
from taskgraph.transforms.base import TransformSequence
from taskgraph.util.schema import validate_schema
from taskgraph.transforms.task import task_description_schema
from voluptuous import Schema, Any, Required, Optional
# Voluptuous uses marker objects as dictionary *keys*, but they are not
# comparable, so we cast all of the keys back to regular strings
task_description_schema = {str(k): v for k, v in task_description_schema.schema.iteritems()}
transforms = TransformSequence()
taskref_or_string = Any(
basestring,
{Required('task-reference'): basestring})
checksums_signing_description_schema = Schema({
Required('dependent-task'): object,
Required('depname', default='beetmover'): basestring,
Optional('label'): basestring,
Optional('treeherder'): task_description_schema['treeherder'],
})
@transforms.add
def validate(config, jobs):
for job in jobs:
label = job.get('dependent-task', object).__dict__.get('label', '?no-label?')
yield validate_schema(
checksums_signing_description_schema, job,
"In checksums-signing ({!r} kind) task for {!r}:".format(config.kind, label))
@transforms.add
def make_checksums_signing_description(config, jobs):
for job in jobs:
dep_job = job['dependent-task']
treeherder = job.get('treeherder', {})
treeherder.setdefault('symbol', 'tc-cs(N)')
dep_th_platform = dep_job.task.get('extra', {}).get(
'treeherder', {}).get('machine', {}).get('platform', '')
treeherder.setdefault('platform',
"{}/opt".format(dep_th_platform))
treeherder.setdefault('tier', 1)
treeherder.setdefault('kind', 'build')
label = job.get('label', "checksumssigning-{}".format(dep_job.label))
dependencies = {"beetmover": dep_job.label}
attributes = {
'nightly': dep_job.attributes.get('nightly', False),
'build_platform': dep_job.attributes.get('build_platform'),
'build_type': dep_job.attributes.get('build_type'),
}
if dep_job.attributes.get('locale'):
treeherder['symbol'] = 'tc-cs({})'.format(dep_job.attributes.get('locale'))
attributes['locale'] = dep_job.attributes.get('locale')
upstream_artifacts = [{
"taskId": {"task-reference": "<beetmover>"},
"taskType": "beetmover",
"paths": [
"public/target.checksums",
],
"formats": ["gpg"]
}]
task = {
'label': label,
'description': "Checksum signing {} ".format(
dep_job.task["metadata"]["description"]),
'worker-type': "scriptworker-prov-v1/signing-linux-v1",
'worker': {'implementation': 'scriptworker-signing',
'upstream-artifacts': upstream_artifacts,
'max-run-time': 3600},
'scopes': [
"project:releng:signing:cert:nightly-signing",
"project:releng:signing:format:gpg"
],
'dependencies': dependencies,
'attributes': attributes,
'run-on-projects': dep_job.attributes.get('run_on_projects'),
'treeherder': treeherder,
}
yield task

Просмотреть файл

@ -296,10 +296,6 @@ task_description_schema = Schema({
# the maximum time to spend signing, in seconds
Required('max-run-time', default=600): int,
# taskid of task with artifacts to beetmove
# beetmover template key
Required('update_manifest'): bool,
# locale key, if this is a locale beetmover job
Optional('locale'): basestring,
@ -366,6 +362,8 @@ GROUP_NAMES = {
'tc-L10n': 'Localised Repacks executed by Taskcluster',
'tc-BM-L10n': 'Beetmover for locales executed by Taskcluster',
'tc-Up': 'Balrog submission of updates, executed by Taskcluster',
'tc-cs': 'Checksum signing executed by Taskcluster',
'tc-BMcs': 'Beetmover checksums, executed by Taskcluster',
'Aries': 'Aries Device Image',
'Nexus 5-L': 'Nexus 5-L Device Image',
'Cc': 'Toolchain builds',
@ -564,7 +562,6 @@ def build_beetmover_payload(config, task, task_def):
task_def['payload'] = {
'maxRunTime': worker['max-run-time'],
'upload_date': config.params['build_date'],
'update_manifest': worker['update_manifest'],
'upstreamArtifacts': worker['upstream-artifacts']
}
if worker.get('locale'):