Bug 1486532 - Don't generate optional payload properties in generic-worker payloads r=ahal
☠☠ backed out by b38bcb2c577c ☠ ☠
authorPeter Moore <pmoore@mozilla.com>
Tue, 28 Aug 2018 08:59:11 +0000
changeset 482278 bce9cb28665c0bb100267cbb956290a00c447721
parent 482277 1f2c35dde932439e01e2e70a14df5a6d8be724d8
child 482279 cad015aaf131b90276537d91e2acf9379f4433d4
push id232
push userfmarier@mozilla.com
push dateWed, 05 Sep 2018 20:45:54 +0000
reviewersahal
bugs1486532
milestone63.0a1
Bug 1486532 - Don't generate optional payload properties in generic-worker payloads r=ahal Differential Revision: https://phabricator.services.mozilla.com/D4358
taskcluster/taskgraph/transforms/task.py
--- a/taskcluster/taskgraph/transforms/task.py
+++ b/taskcluster/taskgraph/transforms/task.py
@@ -966,57 +966,65 @@ def build_docker_worker_payload(config, 
 
     check_caches_are_volumes(task)
 
 
 @payload_builder('generic-worker')
 def build_generic_worker_payload(config, task, task_def):
     worker = task['worker']
 
+    task_def['payload'] = {
+        'command': worker['command'],
+        'maxRunTime': worker['max-run-time'],
+    }
+
+    env = worker.get('env', {})
+
+    if task.get('needs-sccache'):
+        env['USE_SCCACHE'] = '1'
+        # Disable sccache idle shutdown.
+        env['SCCACHE_IDLE_TIMEOUT'] = '0'
+    else:
+        env['SCCACHE_DISABLE'] = '1'
+
+    if env:
+        task_def['payload']['env'] = env
+
     artifacts = []
 
     for artifact in worker.get('artifacts', []):
         a = {
             'path': artifact['path'],
             'type': artifact['type'],
-            'expires': task_def['expires'],  # always expire with the task
         }
         if 'name' in artifact:
             a['name'] = artifact['name']
         artifacts.append(a)
 
+    if artifacts:
+        task_def['payload']['artifacts'] = artifacts
+
     # Need to copy over mounts, but rename keys to respect naming convention
     #   * 'cache-name' -> 'cacheName'
     #   * 'task-id'    -> 'taskId'
     # All other key names are already suitable, and don't need renaming.
     mounts = deepcopy(worker.get('mounts', []))
     for mount in mounts:
         if 'cache-name' in mount:
             mount['cacheName'] = mount.pop('cache-name')
         if 'content' in mount:
             if 'task-id' in mount['content']:
                 mount['content']['taskId'] = mount['content'].pop('task-id')
 
-    task_def['payload'] = {
-        'command': worker['command'],
-        'artifacts': artifacts,
-        'env': worker.get('env', {}),
-        'mounts': mounts,
-        'maxRunTime': worker['max-run-time'],
-        'osGroups': worker.get('os-groups', []),
-    }
+    if worker.get('mounts', []):
+        task_def['payload']['mounts'] = worker['mounts']
 
-    if task.get('needs-sccache'):
-        worker['env']['USE_SCCACHE'] = '1'
-        # Disable sccache idle shutdown.
-        worker['env']['SCCACHE_IDLE_TIMEOUT'] = '0'
-    else:
-        worker['env']['SCCACHE_DISABLE'] = '1'
+    if worker.get('os-groups', []):
+        task_def['payload']['osGroups'] = worker['os-groups']
 
-    # currently only support one feature (chain of trust) but this will likely grow
     features = {}
 
     if worker.get('chain-of-trust'):
         features['chainOfTrust'] = True
 
     if worker.get('taskcluster-proxy'):
         features['taskclusterProxy'] = True
 
@@ -1339,16 +1347,19 @@ def set_defaults(config, tasks):
             worker.setdefault('volumes', [])
             worker.setdefault('env', {})
             if 'caches' in worker:
                 for c in worker['caches']:
                     c.setdefault('skip-untrusted', False)
         elif worker['implementation'] == 'generic-worker':
             worker.setdefault('env', {})
             worker.setdefault('os-groups', [])
+            if worker['os-groups'] and worker['os'] != 'windows':
+                raise Exception('os-groups feature of generic-worker is only supported on '
+                                'Windows, not on {}'.format(worker['os']))
             worker.setdefault('chain-of-trust', False)
         elif worker['implementation'] in (
             'scriptworker-signing', 'beetmover', 'beetmover-push-to-release', 'beetmover-maven',
         ):
             worker.setdefault('max-run-time', 600)
         elif worker['implementation'] == 'push-apk':
             worker.setdefault('commit', False)