Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sweep:integration] fix: AREXCE should break when a valid delegation ID is found #7376

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 17 additions & 24 deletions src/DIRAC/Resources/Computing/AREXComputingElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def _prepareDelegation(self):
def _getDelegationIDs(self):
"""Query and return the delegation IDs.

This happens when the call is from self.renewDelegations.
This happens when the call is from self.renewDelegation.
More info at
https://www.nordugrid.org/arc/arc6/tech/rest/rest.html#jobs-management
https://www.nordugrid.org/arc/arc6/tech/rest/rest.html#delegations-management
Expand All @@ -285,7 +285,7 @@ def _getDelegationIDs(self):
result = self._request("get", query)
if not result["OK"]:
self.log.warn("Issue while interacting with the delegations.", result["Message"])
return S_OK([])
return result
response = result["Value"]

# If there is no delegation, response.json is expected to return an exception
Expand Down Expand Up @@ -319,18 +319,17 @@ def _getProxyFromDelegationID(self, delegationID):
# Submit the POST request to get the delegation
result = self._request("post", query, params=params)
if not result["OK"]:
self.log.error("Issue while interacting with delegation ", f"{delegationID}: {result['Message']}")
return S_ERROR(f"Issue while interacting with delegation {delegationID}: {result['Message']}")
self.log.error("Could not get a proxy for", f"delegation {delegationID}: {result['Message']}")
return S_ERROR(f"Could not get a proxy for delegation {delegationID}: {result['Message']}")
response = result["Value"]

proxyContent = response.text
proxy = X509Chain()
result = proxy.loadChainFromString(proxyContent)
result = proxy.loadChainFromString(response.text)
if not result["OK"]:
self.log.error(
"Issue while trying to load proxy content from delegation", f"{delegationID}: {result['Message']}"
)
return S_ERROR("Issue while trying to load proxy content from delegation")
return result

return S_OK(proxy)

Expand Down Expand Up @@ -446,6 +445,7 @@ def submitJob(self, executableFile, proxy, numberOfJobs=1, inputs=None, outputs=

# If we are here, we have found the right delegationID to use
currentDelegationID = delegationID
break

if not currentDelegationID:
# No existing delegation, we need to prepare one
Expand Down Expand Up @@ -642,28 +642,20 @@ def getCEStatus(self):
#############################################################################

def _renewDelegation(self, delegationID):
"""Renew the delegation
"""Renew the delegation if needed

:params delegationID: delegation ID to renew
"""
# Prepare the command
params = {"action": "get"}
query = self._urlJoin(os.path.join("delegations", delegationID))

# Submit the POST request to get the proxy
result = self._request("post", query, params=params)
result = self._getProxyFromDelegationID(delegationID)
if not result["OK"]:
self.log.error("Could not get a proxy for", f"delegation {delegationID}: {result['Message']}")
return S_ERROR(f"Could not get a proxy for delegation {delegationID}")
response = result["Value"]
return result
proxy = result["Value"]

proxy = X509Chain()
result = proxy.loadChainFromString(response.text)
if not result["OK"]:
self.log.error("Could not load proxy for", f"delegation {delegationID}: {result['Message']}")
return S_ERROR(f"Could not load proxy for delegation {delegationID}")
# Do we have the right proxy to perform a delegation renewal?
if self.proxy.getDIRACGroup() != proxy.getDIRACGroup():
return S_OK()

# Now test and renew the proxy
# Check if the proxy is long enough
result = proxy.getRemainingSecs()
if not result["OK"]:
self.log.error(
Expand All @@ -677,11 +669,12 @@ def _renewDelegation(self, delegationID):
# No need to renew. Proxy is long enough
return S_OK()

self.log.verbose(
self.log.notice(
"Renewing delegation",
f"{delegationID} whose proxy expires at {timeLeft}",
)
# Proxy needs to be renewed - try to renew it

# First, get a new CSR from the delegation
params = {"action": "renew"}
query = self._urlJoin(os.path.join("delegations", delegationID))
Expand Down
Loading