Repository: dmwm/wmcore
Issue: MSRuleceaner: None dataContainer passed to rucio.getBlocksInContainer() 

**Impact of the bug**
MSRulecleaner

**Describe the bug**
During the regular validation process we found an unexpected situation where (most probably) an empty value is passed to the 
`rucio.getBlocksInContainer()` method from `getRucioRules()` when trying to fetch `MStransferor` block level rules for a given workflow. It happens only from one pipeline: `plineMSTrBlock:` Meaning it must be related to workflows with `'InputDataset': None`, but I am sure there must be some additional condition in combination with the empty `InputDataset` because there are other workflows with no input but I see the bug revealed only for two of them. 

NOTE:
And the additional condition in order for the bug to reveal itslef is the workflow must reach `announced` status - for workflows in `completed-aborted` or `rejected` status we do not clean `MSTransferor` rules. 

Because of the constantly failing cleaning step the workflow will never be archived. Here are the stack dump [1] and the workflow representation [2]. 

[1]
```
2021-03-02 08:44:22,870:ERROR:MSRuleCleaner: plineMSTrBlock: General error from pipeline. Workflow: tivanov_TaskChain_MC_HG2103_Val_210225_113404_8309. Error:  
argument of type 'NoneType' is not iterable. 
Will retry again in the next cycle.
Traceback (most recent call last):
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/WMCore/MicroService/Unified/MSRuleCleaner.py", line 324, in _dispatchWflow
    pline.run(wflow)
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/Utils/Pipeline.py", line 140, in run
    return reduce(lambda obj, functor: functor(obj), self.funcLine, obj)
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/Utils/Pipeline.py", line 140, in <lambda>
    return reduce(lambda obj, functor: functor(obj), self.funcLine, obj)
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/Utils/Pipeline.py", line 72, in __call__
    return self.run(obj)
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/Utils/Pipeline.py", line 75, in run
    return self.func(obj, *self.args, **self.kwargs)
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/WMCore/MicroService/Unified/MSRuleCleaner.py", line 638, in getRucioRules
    blocks = self.rucio.getBlocksInContainer(dataCont)
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/WMCore/Services/Rucio/Rucio.py", line 227, in getBlocksInContainer
    if not self.isContainer(container):
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/cms/reqmgr2ms/0.4.6.pre8/lib/python2.7/site-packages/WMCore/Services/Rucio/Rucio.py", line 814, in isContainer
    response = self.cli.get_did(scope=scope, name=didName)
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/external/py2-rucio-clients/1.24.2.post1/lib/python2.7/site-packages/rucio/client/didclient.py", line 419, in get_did
    path = '/'.join([self.DIDS_BASEURL, quote_plus(scope), quote_plus(name)])
  File "/data/srv/HG2103f/sw/slc7_amd64_gcc630/external/python/2.7.13-comp2/lib/python2.7/urllib.py", line 1303, in quote_plus
    if ' ' in s:
TypeError: argument of type 'NoneType' is not iterable
```

[2]
```
2021-03-02 08:44:23,243:INFO:MSRuleCleaner: plineArchive: Proper conditions not met: Not properly cleaned workflow: tivanov_TaskChain_MC_HG2103_Val_210225_113404_8309. Skipping archival in t
he current cycle.
2021-03-02 08:44:23,245:DEBUG:MSRuleCleaner: 
----------------------------------------------------------
MSRuleCleanerWflow: {'CleanupStatus': {'plineAgentBlock': True,
                   'plineAgentCont': True,
                   'plineMSTrBlock': False,
                   'plineMSTrCont': False},
 'DataPileup': [],
 'ForceArchive': False,
 'IncludeParents': False,
 'InputDataset': None,
 'IsArchivalDelayExpired': False,
 'IsClean': False,
 'IsLogDBClean': True,
 'MCPileup': [],
 'OutputDatasets': [u'/RelValProdQCD_Pt_3000_3500_13/CMSSW_8_1_0-ProdQCD_Pt_3000_3500_13_TaskChain_MC_HG2103_Val_Todor_v1-v11/GEN-SIM',
                    u'/RelValProdQCD_Pt_3000_3500_13/CMSSW_8_1_0-RECOPRODUP15_TaskChain_MC_HG2103_Val_Todor_v1-v11/AODSIM',
                    u'/RelValProdQCD_Pt_3000_3500_13/CMSSW_8_1_0-RECOPRODUP15_TaskChain_MC_HG2103_Val_Todor_v1-v11/DQMIO',
                    u'/RelValProdQCD_Pt_3000_3500_13/CMSSW_8_1_0-RECOPRODUP15_TaskChain_MC_HG2103_Val_Todor_v1-v11/MINIAODSIM'],
 'ParentDataset': [],
 'ParentageResolved': True,
 'PlineMarkers': ['plineMSTrCont',
                  'plineMSTrBlock',
                  'plineAgentCont',
                  'plineAgentBlock',
                  'plineArchive'],
 'RequestName': u'tivanov_TaskChain_MC_HG2103_Val_210225_113404_8309',
 'RequestStatus': u'announced',
 'RequestTransition': [{u'DN': u'/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=tivanov/CN=726807/CN=Todor Trendafilov Ivanov',
                        u'Status': u'new',
                        u'UpdateTime': 1614249244},
                       {u'DN': u'/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=tivanov/CN=726807/CN=Todor Trendafilov Ivanov',
                        u'Status': u'assignment-approved',
                        u'UpdateTime': 1614249246},
                       {u'DN': u'/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=tivanov/CN=726807/CN=Todor Trendafilov Ivanov',
                        u'Status': u'assigned',
                        u'UpdateTime': 1614249246},
                       {u'DN': u'/DC=ch/DC=cern/OU=computers/CN=wmagent/vocms0192.cern.ch',
                        u'Status': u'staging',
                        u'UpdateTime': 1614256614},
                       {u'DN': u'/DC=ch/DC=cern/OU=computers/CN=wmagent/vocms0192.cern.ch',
                        u'Status': u'staged',
                        u'UpdateTime': 1614257185},
                       {u'DN': u'/DC=ch/DC=cern/OU=computers/CN=wmagent/vocms0192.cern.ch',
                        u'Status': u'acquired',
                        u'UpdateTime': 1614257896},
                       {u'DN': u'/DC=ch/DC=cern/OU=computers/CN=wmagent/vocms0192.cern.ch',
                        u'Status': u'running-open',
                        u'UpdateTime': 1614257896},
                       {u'DN': u'/DC=ch/DC=cern/OU=computers/CN=wmagent/vocms0192.cern.ch',
                        u'Status': u'running-closed',
                        u'UpdateTime': 1614260303},
                       {u'DN': u'/DC=ch/DC=cern/OU=computers/CN=wmagent/vocms0192.cern.ch',
                        u'Status': u'completed',
                        u'UpdateTime': 1614295740},
                       {u'DN': u'/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=tivanov/CN=726807/CN=Todor Trendafilov Ivanov',
                        u'Status': u'closed-out',
                        u'UpdateTime': 1614670081},
                       {u'DN': u'/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=tivanov/CN=726807/CN=Todor Trendafilov Ivanov',
                        u'Status': u'announced',
                        u'UpdateTime': 1614670086}],
 'RequestType': u'TaskChain',
 'RulesToClean': {'plineAgentBlock': [u'e401325334fe4bb39f26d1dd39957ae5',
                                      u'12e347e424f34f5581be0aa747dd6ca8',
                                      u'fc67bcf1ab1d43c9a8aa9afd1ff5958f',
                                      u'1cb7ffed8ea94cb19c613a9f73c7c6f0'],
                  'plineAgentCont': [],
                  'plineMSTrBlock': [],
                  'plineMSTrCont': [u'2982732f0e3c4a18b9d14ba09232cd4a',
                                    u'd68666816355481895ddb1c18297f90f',
                                    u'4f4eb7bf258d42e7bd8f19e55971cec5',
                                    u'390203ebf6d54beb9f126f0505ea6ed2',
                                    u'56e95a513c7542fc818d553ed89479fb']},
 'TargetStatus': 'normal-archived',
 'TransferDone': True}
----------------------------------------------------------
```


**How to reproduce it**
Steps to reproduce the behavior:

**Expected behavior**
We should not break the call of `getRucioRules` because of an empty value passed to `getBlocksInContainer`.

**Additional context and error message**
Add any other context about the problem here, like error message and/or traceback. You might want to use triple back ticks to properly format it.


Changed files:
src/python/WMCore/MicroService/Unified/MSRuleCleaner.py

diff --git a/src/python/WMCore/MicroService/Unified/MSRuleCleaner.py b/src/python/WMCore/MicroService/Unified/MSRuleCleaner.py
index 4cbcd22c8..1e60da146 100644
--- a/src/python/WMCore/MicroService/Unified/MSRuleCleaner.py
+++ b/src/python/WMCore/MicroService/Unified/MSRuleCleaner.py
@@ -622,6 +622,8 @@ class MSRuleCleaner(MSCore):
         for dataType in mapRuleType[rucioAcct]:
             dataList = wflow[dataType] if isinstance(wflow[dataType], list) else [wflow[dataType]]
             for dataCont in dataList:
+                if dataCont is None:
+                    continue
                 self.logger.debug("getRucioRules: dataCont: %s", pformat(dataCont))
                 if checkGlobalLocks and dataCont in self.globalLocks:
                     msg = "Found dataset: %s in GlobalLocks. NOT considering it for filling the "