Skip to content

Commit

Permalink
fix: getQueue should not override the tags
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Feb 8, 2024
1 parent c35948e commit 7d387f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions src/DIRAC/ConfigurationSystem/Client/Helpers/Resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,29 +200,31 @@ def getSiteGrid(site):
def getQueue(site, ce, queue):
"""Get parameters of the specified queue"""
grid = site.split(".")[0]

# Get CE parameters
result = gConfig.getOptionsDict(f"/Resources/Sites/{grid}/{site}/CEs/{ce}")
if not result["OK"]:
return result
resultDict = result["Value"]
ceDict = result["Value"]

tags = set(fromChar(ceDict.get("Tag")) or [])
requiredTags = set(fromChar(ceDict.get("RequiredTag")) or [])

# Get queue defaults
# Get queue parameters
result = gConfig.getOptionsDict(f"/Resources/Sites/{grid}/{site}/CEs/{ce}/Queues/{queue}")
if not result["OK"]:
return result
resultDict.update(result["Value"])

# Handle tag lists for the queue
for tagFieldName in ("Tag", "RequiredTag"):
tags = []
ceTags = resultDict.get(tagFieldName)
if ceTags:
tags = fromChar(ceTags)
queueTags = resultDict.get(tagFieldName)
if queueTags:
queueTags = fromChar(queueTags)
tags = list(set(tags + queueTags))
if tags:
resultDict[tagFieldName] = tags
queueDict = result["Value"]

# Union the sets to combine tags and required tags from CE and queue
tags = tags.union(set(fromChar(queueDict.get("Tag")) or []))
requiredTags = requiredTags.union(set(fromChar(queueDict.get("RequiredTag")) or []))

resultDict = {**ceDict, **queueDict}
if tags:
resultDict["Tag"] = list(tags)
if requiredTags:
resultDict["RequiredTag"] = list(requiredTags)

resultDict["Queue"] = queue
return S_OK(resultDict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,5 @@ def test_getQueue():
"LocalCEType": "Pool/Singularity",
"OS": "linux_AlmaLinux_9.4.2104",
}

assert sorted(result["Value"].pop("Tag")) == sorted(expectedDict.pop("Tag"))
assert result["Value"] == expectedDict

0 comments on commit 7d387f7

Please sign in to comment.