Repository: dmwm/wmcore
Issue: Error assigning ACDC for merge of StepChain

Another problem caused by the parentage mapping update. I have this error in testbed (vocms0731), but I'm pretty sure the same problem is also in production.
```
INFO:cherrypy.error:[26/Feb/2019:22:15:15]  Assign request amaltaro_ACDCMerge_StepChain_ReDigi3_HG1903_Validation_190226_221447_8324, input args: {u'SoftTimeout': 129600, u'BlockCloseMaxEvents': 200000000, u'MaxMergeEvents': 50000, u'CustodialSites': [], u'Override': {u'eos-lfn-prefix': u'root://eoscms.cern.ch//eos/cms/store/logs/prod/recent/TESTBED'}, u'ProcessingString': 'StepChain_ReDigi3_HG1903_Validation_TEST_Alan_v11', u'TrustSitelists': False, u'UnmergedLFNBase': '/store/unmerged', u'CustodialSubType': 'Move', u'TrustPUSitelists': False, u'GracePeriod': 1000, u'MergedLFNBase': '/store/backfill/1', 'HardTimeout': 130600, u'BlockCloseMaxWaitTime': 72000, u'MaxMergeSize': 4294967296, u'AcquisitionEra': 'Integ_Test', u'NonCustodialSubType': 'Replica', u'NonCustodialSites': [], u'MinMergeSize': 2147483648, u'RequestPriority': 220000, u'SiteWhitelist': [u'T1_US_FNAL', u'T2_CH_CERN'], u'BlockCloseMaxSize': 5000000000000, u'ProcessingVersion': 11, u'Dashboard': 'integration', u'Team': 'testbed-vocms0193', u'AutoApproveSubscriptionSites': [], u'BlockCloseMaxFiles': 500, u'SiteBlacklist': [], u'SubscriptionPriority': 'Low', u'RequestStatus': 'assigned'} ...
[26/Feb/2019:22:15:16]  Error for request args {u'SoftTimeout': 129600, u'BlockCloseMaxEvents': 200000000, 'DeleteFromSource': False, u'MaxMergeEvents': 50000, u'CustodialSites': [], u'Override': {u'eos-lfn-prefix': u'root://eoscms.cern.ch//eos/cms/store/logs/prod/recent/TESTBED'}, u'ProcessingString': 'StepChain_ReDigi3_HG1903_Validation_TEST_Alan_v11', 'NonCustodialGroup': 'DataOps', u'TrustSitelists': False, 'ChainParentageMap': {}, 'CustodialGroup': 'DataOps', u'UnmergedLFNBase': '/store/unmerged', u'CustodialSubType': 'Move', u'TrustPUSitelists': False, u'GracePeriod': 1000, u'MergedLFNBase': '/store/backfill/1', 'HardTimeout': 130600, u'BlockCloseMaxWaitTime': 72000, u'MaxMergeSize': 4294967296, u'AcquisitionEra': 'Integ_Test', u'NonCustodialSubType': 'Replica', u'NonCustodialSites': [], u'MinMergeSize': 2147483648, u'RequestPriority': 220000, u'SiteWhitelist': [u'T1_US_FNAL', u'T2_CH_CERN'], u'BlockCloseMaxSize': 5000000000000, u'ProcessingVersion': 11, u'Dashboard': 'integration', u'Team': 'testbed-vocms0193', 'AllowOpportunistic': False, u'AutoApproveSubscriptionSites': [], u'BlockCloseMaxFiles': 500, u'SiteBlacklist': [], u'SubscriptionPriority': 'Low', u'RequestStatus': 'assigned', 'MaxWaitTime': 86400}: Traceback (most recent call last):
  File "/data/srv/beHG1903b/sw/slc7_amd64_gcc630/cms/reqmgr2/1.2.0.pre3/lib/python2.7/site-packages/WMCore/ReqMgr/Service/Request.py", line 421, in _handleAssignmentStateTransition
    workload.updateArguments(request_args)
  File "/data/srv/beHG1903b/sw/slc7_amd64_gcc630/cms/reqmgr2/1.2.0.pre3/lib/python2.7/site-packages/WMCore/WMSpec/WMWorkload.py", line 1954, in updateArguments
    self.updateStepParentageMap()
  File "/data/srv/beHG1903b/sw/slc7_amd64_gcc630/cms/reqmgr2/1.2.0.pre3/lib/python2.7/site-packages/WMCore/WMSpec/WMWorkload.py", line 245, in updateStepParentageMap
    stepHelper = topLevelTask.getStepHelper(cmsRunNumber)
  File "/data/srv/beHG1903b/sw/slc7_amd64_gcc630/cms/reqmgr2/1.2.0.pre3/lib/python2.7/site-packages/WMCore/WMSpec/WMTask.py", line 274, in getStepHelper
    stepType = step.stepType()
AttributeError: 'NoneType' object has no attribute 'stepType'
```

Changed files:
src/python/WMCore/WMSpec/WMWorkload.py

diff --git a/src/python/WMCore/WMSpec/WMWorkload.py b/src/python/WMCore/WMSpec/WMWorkload.py
index e5bdfe180..287f9fe26 100644
--- a/src/python/WMCore/WMSpec/WMWorkload.py
+++ b/src/python/WMCore/WMSpec/WMWorkload.py
@@ -134,15 +134,6 @@ class WMWorkloadHelper(PersistencyHelper):
         """
         self.data.properties.stepMapping = mapping
 
-    def setStepParentageMapping(self, mapping):
-        """
-        _setStepParentageMapping_
-
-        Used for StepChains. Set a wider dictionary structure with a mapping between
-        parent and child steps as well as dataset parentage
-        """
-        self.data.properties.stepParentageMapping = mapping
-
     def getStepMapping(self):
         """
         _getStepMapping_
@@ -152,6 +143,15 @@ class WMWorkloadHelper(PersistencyHelper):
         """
         return getattr(self.data.properties, "stepMapping", None)
 
+    def setStepParentageMapping(self, mapping):
+        """
+        _setStepParentageMapping_
+
+        Used for StepChains. Set a wider dictionary structure with a mapping between
+        parent and child steps as well as dataset parentage
+        """
+        self.data.properties.stepParentageMapping = mapping
+
     def getStepParentageMapping(self):
         """
         _getStepParentageMapping_
@@ -235,6 +235,9 @@ class WMWorkloadHelper(PersistencyHelper):
         :return: just updates the workload property: stepParentageMapping
         """
         topLevelTask = next(self.taskIterator())
+        if topLevelTask.taskType() == "Merge":
+            # handle ACDC for merge jobs, see #9051. Nothing to do here
+            return
 
         parentMap = self.getStepParentageMapping()
         listOfStepNames = parentMap.keys()