Skip to content

Commit

Permalink
Merge pull request #10105 from germanfgv/askApproval
Browse files Browse the repository at this point in the history
Manage rule approval requirements for tape sites
  • Loading branch information
amaltaro authored Dec 2, 2020
2 parents 673acd3 + f899ee8 commit f94a5ac
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/python/WMComponent/RucioInjector/RucioInjectorPoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,16 @@ def insertContainerRules(self):
elif self.testRSEs:
rseName = "%s_Test" % rseName

#Checking whether we need to ask for rule approval
try:
if self.rucio.requiresApproval(rseName):
ruleKwargs['ask_approval'] = True
except WMRucioException as exc:
msg = str(exc)
msg += "\nUnable to check approval requirements. Will retry again in the next cycle."
logging.error(msg)
continue

logging.info("Creating container rule for %s against RSE %s", container, rseName)
logging.debug("Container rule will be created with keyword args: %s", ruleKwargs)
try:
Expand Down
18 changes: 17 additions & 1 deletion src/python/WMCore/Services/Rucio/Rucio.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from rucio.client import Client
from rucio.common.exception import (AccountNotFound, DataIdentifierNotFound, AccessDenied, DuplicateRule,
DataIdentifierAlreadyExists, DuplicateContent, InvalidRSEExpression,
UnsupportedOperation, FileAlreadyExists, RuleNotFound)
UnsupportedOperation, FileAlreadyExists, RuleNotFound, RSENotFound)
from Utils.MemoryCache import MemoryCache
from WMCore.WMException import WMException

Expand Down Expand Up @@ -789,6 +789,22 @@ def pickRSE(self, rseExpression='rse_type=TAPE\cms_type=test', rseAttribute='ddm
choice = weightedChoice(rsesWithWeights)
return choice

def requiresApproval(self, rse):
"""
_requiresApproval_
Returns wether or not the specified RSE requires rule approval.
:param res: string containing the Rucio RSE name
:returns: True if the RSE requires approval to write (rule property)
"""
try:
attrs = self.cli.list_rse_attributes(rse)
except RSENotFound as exc:
msg = "Error retrieving attributes for RSE: {}. Error: {}".format(rse, str(exc))
raise WMRucioException(msg)
return attrs.get('requires_approval', False)


def isContainer(self, didName, scope='cms'):
"""
Checks whether the DID name corresponds to a container type or not.
Expand Down
9 changes: 9 additions & 0 deletions test/python/WMCore_t/Services_t/Rucio_t/Rucio_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,15 @@ def testPickRSE(self):
self.assertTrue(len(resp) == 2)
self.assertTrue(resp[1] is True or resp[1] is False)

def testRequiresApproval(self):
"""
Test the `pickRSE` method
"""
resp = self.myRucio.requiresApproval("T1_UK_RAL_Tape_Test")
self.assertTrue(resp)
resp = self.myRucio.requiresApproval("T1_FR_CCIN2P3_Tape_Test")
self.assertFalse(resp)

def testIsTapeRSE(self):
"""
Test the `isTapeRSE` utilitarian function
Expand Down

0 comments on commit f94a5ac

Please sign in to comment.