@@ -280,7 +280,7 @@ def _prepareDelegation(self):
280
280
def _getDelegationIDs (self ):
281
281
"""Query and return the delegation IDs.
282
282
283
- This happens when the call is from self.renewDelegations .
283
+ This happens when the call is from self.renewDelegation .
284
284
More info at
285
285
https://www.nordugrid.org/arc/arc6/tech/rest/rest.html#jobs-management
286
286
https://www.nordugrid.org/arc/arc6/tech/rest/rest.html#delegations-management
@@ -293,7 +293,7 @@ def _getDelegationIDs(self):
293
293
result = self ._request ("get" , query )
294
294
if not result ["OK" ]:
295
295
self .log .warn ("Issue while interacting with the delegations." , result ["Message" ])
296
- return S_OK ([])
296
+ return result
297
297
response = result ["Value" ]
298
298
299
299
# If there is no delegation, response.json is expected to return an exception
@@ -327,18 +327,17 @@ def _getProxyFromDelegationID(self, delegationID):
327
327
# Submit the POST request to get the delegation
328
328
result = self ._request ("post" , query , params = params )
329
329
if not result ["OK" ]:
330
- self .log .error ("Issue while interacting with delegation " , f"{ delegationID } : { result ['Message' ]} " )
331
- return S_ERROR (f"Issue while interacting with delegation { delegationID } : { result ['Message' ]} " )
330
+ self .log .error ("Could not get a proxy for " , f"delegation { delegationID } : { result ['Message' ]} " )
331
+ return S_ERROR (f"Could not get a proxy for delegation { delegationID } : { result ['Message' ]} " )
332
332
response = result ["Value" ]
333
333
334
- proxyContent = response .text
335
334
proxy = X509Chain ()
336
- result = proxy .loadChainFromString (proxyContent )
335
+ result = proxy .loadChainFromString (response . text )
337
336
if not result ["OK" ]:
338
337
self .log .error (
339
338
"Issue while trying to load proxy content from delegation" , f"{ delegationID } : { result ['Message' ]} "
340
339
)
341
- return S_ERROR ( "Issue while trying to load proxy content from delegation" )
340
+ return result
342
341
343
342
return S_OK (proxy )
344
343
@@ -454,6 +453,7 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=
454
453
455
454
# If we are here, we have found the right delegationID to use
456
455
currentDelegationID = delegationID
456
+ break
457
457
458
458
if not currentDelegationID :
459
459
# No existing delegation, we need to prepare one
@@ -650,28 +650,20 @@ def getCEStatus(self):
650
650
#############################################################################
651
651
652
652
def _renewDelegation (self , delegationID ):
653
- """Renew the delegation
653
+ """Renew the delegation if needed
654
654
655
655
:params delegationID: delegation ID to renew
656
656
"""
657
- # Prepare the command
658
- params = {"action" : "get" }
659
- query = self ._urlJoin (os .path .join ("delegations" , delegationID ))
660
-
661
- # Submit the POST request to get the proxy
662
- result = self ._request ("post" , query , params = params )
657
+ result = self ._getProxyFromDelegationID (delegationID )
663
658
if not result ["OK" ]:
664
- self .log .error ("Could not get a proxy for" , f"delegation { delegationID } : { result ['Message' ]} " )
665
- return S_ERROR (f"Could not get a proxy for delegation { delegationID } " )
666
- response = result ["Value" ]
659
+ return result
660
+ proxy = result ["Value" ]
667
661
668
- proxy = X509Chain ()
669
- result = proxy .loadChainFromString (response .text )
670
- if not result ["OK" ]:
671
- self .log .error ("Could not load proxy for" , f"delegation { delegationID } : { result ['Message' ]} " )
672
- return S_ERROR (f"Could not load proxy for delegation { delegationID } " )
662
+ # Do we have the right proxy to perform a delegation renewal?
663
+ if self .proxy .getDIRACGroup () != proxy .getDIRACGroup ():
664
+ return S_OK ()
673
665
674
- # Now test and renew the proxy
666
+ # Check if the proxy is long enough
675
667
result = proxy .getRemainingSecs ()
676
668
if not result ["OK" ]:
677
669
self .log .error (
@@ -685,11 +677,12 @@ def _renewDelegation(self, delegationID):
685
677
# No need to renew. Proxy is long enough
686
678
return S_OK ()
687
679
688
- self .log .verbose (
680
+ self .log .notice (
689
681
"Renewing delegation" ,
690
682
f"{ delegationID } whose proxy expires at { timeLeft } " ,
691
683
)
692
684
# Proxy needs to be renewed - try to renew it
685
+
693
686
# First, get a new CSR from the delegation
694
687
params = {"action" : "renew" }
695
688
query = self ._urlJoin (os .path .join ("delegations" , delegationID ))
0 commit comments