]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/workunit.py: use "overrides" as the default settings of workunit 14371/head
authorKefu Chai <kchai@redhat.com>
Sat, 1 Apr 2017 15:04:22 +0000 (23:04 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 7 Apr 2017 05:30:07 +0000 (13:30 +0800)
otherwise the settings in "workunit" tasks are always overridden by the
settings in template config. so we'd better follow the way of how
"install" task updates itself with the "overrides" settings: it uses the
"overrides" as the *defaults*.

Fixes: http://tracker.ceph.com/issues/19429
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 47080150a17d238f38d9da824d227393ad767aad)

qa/tasks/workunit.py

index 1214a9d72dac1719d03ac562f8a857754b393f32..27a00eae2f4514e2a07db972eb33e208acbbeec2 100644 (file)
@@ -5,6 +5,7 @@ import logging
 import pipes
 import os
 
+from copy import deepcopy
 from util import get_remote_for_role
 
 from teuthology import misc
@@ -127,10 +128,18 @@ def task(ctx, config):
     assert isinstance(config.get('clients'), dict), \
         'configuration must contain a dictionary of clients'
 
-    overrides = ctx.config.get('overrides', {})
-    misc.deep_merge(config, overrides.get('workunit', {}))
-
-    for spec, cls in [('branch', Branch), ('tag', Refspec), ('sha1', Refspec)]:
+    # mimic the behavior of the "install" task, where the "overrides" are
+    # actually the defaults of that task. in other words, if none of "sha1",
+    # "tag", or "branch" is specified by a "workunit" tasks, we will update
+    # it with the information in the "workunit" sub-task nested in "overrides".
+    overrides = deepcopy(ctx.config.get('overrides', {}).get('workunit', {}))
+    refspecs = {'branch': Branch, 'tag': Refspec, 'sha1': Refspec}
+    if any(map(lambda i: i in config, refspecs.iterkeys())):
+        for i in refspecs.iterkeys():
+            overrides.pop(i, None)
+    misc.deep_merge(config, overrides)
+
+    for spec, cls in refspecs.iteritems():
         refspec = config.get(spec)
         if refspec:
             refspec = cls(refspec)