Skip to content

Commit

Permalink
feat(VOMS2CS): report errors from IAM getUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
andresailer committed Sep 13, 2024
1 parent 183c1d4 commit e6c5eea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/DIRAC/ConfigurationSystem/Client/VOMS2CSSynchronizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def _getUsers(self):
vomsSrv = VOMSService(self.vo)
voms_users = returnValueOrRaise(vomsSrv.getUsers())
if self.compareWithIAM:
self.compareUsers(voms_users, iam_users)
self.compareUsers(voms_users.get("Users", {}), iam_users.get("Users", {}))
return voms_users

def syncCSWithVOMS(self):
Expand All @@ -259,9 +259,9 @@ def syncCSWithVOMS(self):
if not result["OK"]:
self.log.error("Could not retrieve user information", result["Message"])
return result
if getUserErrors := result.get("Errors", []):
if getUserErrors := result["Value"]["Errors"]:
self.adminMsgs["Errors"].extend(getUserErrors)
self.vomsUserDict = result["Value"]
self.vomsUserDict = result["Value"]["Users"]
message = f"There are {len(self.vomsUserDict)} user entries in VOMS for VO {self.vomsVOName}"
self.adminMsgs["Info"].append(message)
self.log.info("VOMS user entries", message)
Expand Down
7 changes: 5 additions & 2 deletions src/DIRAC/Core/Security/IAMService.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def convert_iam_to_voms(self, iam_output):
return converted_output

def getUsers(self):
"""Extract users from IAM user dump.
:return: dictionary of: "Users": user dictionary keyed by the user DN, "Errors": list of error messages
"""
self.iam_users_raw = self._getIamUserDump()
users = {}
errors = []
Expand All @@ -140,6 +144,5 @@ def getUsers(self):
self.log.error("Could not convert", f"{user['name']} {e!r}")
self.log.error("There were in total", f"{len(errors)} errors")
self.userDict = dict(users)
result = S_OK(users)
result["Errors"] = errors
result = S_OK({"Users": users, "Errors": errors})
return result
5 changes: 3 additions & 2 deletions src/DIRAC/Core/Security/VOMSService.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def attGetUserNickname(self, dn, _ca=None):
def getUsers(self):
"""Get all the users of the VOMS VO with their detailed information
:return: user dictionary keyed by the user DN
:return: dictionary of: "Users": user dictionary keyed by the user DN, "Errors": empty list
"""
if not self.urls:
return S_ERROR(DErrno.ENOAUTH, "No VOMS server defined")
Expand Down Expand Up @@ -148,4 +148,5 @@ def getUsers(self):
resultDict[dn]["nickname"] = attribute.get("value")

self.userDict = dict(resultDict)
return S_OK(resultDict)
# for consistency with IAM interface, we add Errors
return S_OK({"Users": resultDict, "Errors": []})

0 comments on commit e6c5eea

Please sign in to comment.