Repository: dmwm/wmcore
Issue: Keep only ruleID instead of the full Rucio rule for MSRuleCleaner 

**Impact of the bug**
MSRuleCleaner

**Describe the bug**
NOT exactly a bug:
While validating the Service in testbed, we figured out that we have quite a big and extensive log we preserve per every workflow. And while running the service in DEBUG mode at some point we are dumping the whole workflow representation into the log. Which is not a bug by itself, but we are also keeping the full Rucio rule in the workflow, which contains a lot of unneeded information like [1]. And this is just for a DID with only two blocks, while we are having some containers with  several K blocks. The only reason for recording all that information into the workflow was just for keeping into the log the `ruleID`s we are deleting associated with the `DID` (block or container) to which it relates. And since now we know the information (the link between `ruleID` and `DID`) is preserved into the Rucio database (even though not that easy to be accessed), we decided to drop the` DID` and go only with the `ruleID`.

We should also change the log level for the deletion message itself from DEBUG to INFO.

[1]
```
 'RulesToClean': {'plineAgentBlock': [{u'account': u'wma_test',
                                       u'activity': u'Production Output',
                                       u'child_rule_id': None,
                                       u'comments': u'WMAgent automatic container rule',
                                       u'copies': 1,
                                       u'created_at': datetime.datetime(2020, 11, 17, 14, 32, 49),
                                       u'did_type': u'DATASET',
                                       u'eol_at': None,
                                       u'error': None,
                                       u'expires_at': datetime.datetime(2020, 11, 17, 20, 50, 30),
                                       u'grouping': u'DATASET',
                                       u'id': u'00f877d0f91241d9a24be04cebf10f93',
                                       u'ignore_account_limit': False,
                                       u'ignore_availability': False,
                                       u'locked': False,
                                       u'locks_ok_cnt': 1,
                                       u'locks_replicating_cnt': 0,
                                       u'locks_stuck_cnt': 0,
                                       u'meta': u'"{\\\\"agentHost\\\\": \\\\"vocms0193.cern.ch\\\\", \\\\"userAgent\\\\": \\\\"WMAgent\\\\"}"',
                                       u'name': u'/RelValDarkSUSY_14TeV/DMWM_Test-SC_LHE_Ext_HG2011_Val_Todor_MSRuleCleaner_v1-v11/GEN-SIM#b9a66f7e-27a6-4f00-9b61-4ea431473dcb',
                                       u'notification': u'NO',
                                       u'priority': 3,
                                       u'purge_replicas': False,
                                       u'rse_expression': u'T2_CH_CERN_Test',
                                       u'scope': u'cms',
                                       u'source_replica_expression': None,
                                       u'split_container': False,
                                       u'state': u'OK',
                                       u'stuck_at': None,
                                       u'subscription_id': None,
                                       u'updated_at': datetime.datetime(2020, 11, 17, 19, 50, 30),
                                       u'weight': None},
                                      {u'account': u'wma_test',
                                       u'activity': u'Production Output',
                                       u'child_rule_id': None,
                                       u'comments': u'WMAgent automatic container rule',
                                       u'copies': 1,
                                       u'created_at': datetime.datetime(2020, 11, 17, 14, 42, 51),
                                       u'did_type': u'DATASET',
                                       u'eol_at': None,
                                       u'error': None,
                                       u'expires_at': datetime.datetime(2020, 11, 17, 20, 50, 30),
                                       u'grouping': u'DATASET',
                                       u'id': u'adf1fda1a29c4cc3b15d52ad4e5af4bc',
                                       u'ignore_account_limit': False,
                                       u'ignore_availability': False,
                                       u'locked': False,
                                       u'locks_ok_cnt': 7,
                                       u'locks_replicating_cnt': 0,
                                       u'locks_stuck_cnt': 0,
                                       u'meta': u'"{\\\\"agentHost\\\\": \\\\"vocms0193.cern.ch\\\\", \\\\"userAgent\\\\": \\\\"WMAgent\\\\"}"',
                                       u'name': u'/RelValDarkSUSY_14TeV/DMWM_Test-SC_LHE_Ext_HG2011_Val_Todor_MSRuleCleaner_v1-v11/GEN-SIM-DIGI-RAW#2655420e-c4ea-401f-ba2d-c7969a3ad92b',
                                       u'notification': u'NO',
                                       u'priority': 3,
                                       u'purge_replicas': False,
                                       u'rse_expression': u'T2_CH_CERN_Test',
                                       u'scope': u'cms',
                                       u'source_replica_expression': None,
                                       u'split_container': False,
                                       u'state': u'OK',
                                       u'stuck_at': None,
                                       u'subscription_id': None,
                                       u'updated_at': datetime.datetime(2020, 11, 17, 19, 50, 30),
                                       u'weight': None}],
                  'plineAgentCont': []},
```


**How to reproduce it**
Just read the logs of the current implementation of the service

**Expected behavior**
Just keep the `ruleID` into the workflow representation and log only it while deleting.

**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 526710380..03c43aa62 100644
--- a/src/python/WMCore/MicroService/Unified/MSRuleCleaner.py
+++ b/src/python/WMCore/MicroService/Unified/MSRuleCleaner.py
@@ -396,12 +396,14 @@ class MSRuleCleaner(MSCore):
         # Find all the output placement rules created by the agents
         for dataCont in wflow['OutputDatasets']:
             if gran == 'container':
-                wflow['RulesToClean'][currPline].extend(self.rucio.listDataRules(dataCont, account=rucioAcct))
+                for rule in self.rucio.listDataRules(dataCont, account=rucioAcct):
+                    wflow['RulesToClean'][currPline].append(rule['id'])
             elif gran == 'block':
                 try:
                     blocks = self.rucio.getBlocksInContainer(dataCont)
                     for block in blocks:
-                        wflow['RulesToClean'][currPline].extend(self.rucio.listDataRules(block, account=rucioAcct))
+                        for rule in self.rucio.listDataRules(block, account=rucioAcct):
+                            wflow['RulesToClean'][currPline].append(rule['id'])
                 except WMRucioDIDNotFoundException:
                     msg = "Container: %s not found in Rucio for workflow: %s."
                     self.logger.info(msg, dataCont, wflow['RequestName'])
@@ -422,21 +424,15 @@ class MSRuleCleaner(MSCore):
         delResults = []
         if self.msConfig['enableRealMode']:
             for rule in wflow['RulesToClean'][currPline]:
-                msg = "%s: Deleting rule['id']: %s "
-                msg += "For did: %s"
-                self.logger.info(msg, currPline, rule['id'], rule['name'])
-                delResult = self.rucio.deleteRule(rule['id'])
+                self.logger.info("%s: Deleting ruleId: %s ", currPline, rule)
+                delResult = self.rucio.deleteRule(rule)
                 delResults.append(delResult)
                 if not delResult:
-                    msg = "%s: Failed to delete rule['id']: %s "
-                    msg += "For did: %s"
-                    self.logger.warning(msg, currPline, rule['id'], rule['name'])
+                    self.logger.warning("%s: Failed to delete ruleId: %s ", currPline, rule)
         else:
             for rule in wflow['RulesToClean'][currPline]:
                 delResults.append(True)
-                msg = "%s: Is about to delete rule['id']: %s "
-                msg += "For did: %s"
-                self.logger.debug(msg, currPline, rule['id'], rule['name'])
+                self.logger.info("%s: DRY-RUN: Is about to delete ruleId: %s ", currPline, rule)
 
         # Set the cleanup flag:
         wflow['CleanupStatus'][currPline] = all(delResults)