Skip to content

Commit

Permalink
fix: check the VO from the task queues before submitting pilots
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Feb 29, 2024
1 parent ae56101 commit c167f0c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
6 changes: 4 additions & 2 deletions src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,12 @@ def _getNumberOfJobsNeedingPilots(self, waitingPilots: int, queue: str):
return 0
taskQueueDict = result["Value"]

# Get the number of jobs that would match the capability of the CE
# Get the number of jobs that would match the capability of the CE and the VO
waitingSupportedJobs = 0
for tq in taskQueueDict.values():
waitingSupportedJobs += tq["Jobs"]
ownerGroup = tq.get("OwnerGroup", "")
if Registry.getVOForGroup(ownerGroup) == self.vo:
waitingSupportedJobs += tq["Jobs"]

# Get the number of jobs that need pilots
return max(0, waitingSupportedJobs - waitingPilots)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@


CONFIG = """
Registry
{
Groups
{
dteam_user
{
VO = dteam
}
dummyVO_user
{
VO = dummyVO
}
}
}
Resources
{
Sites
Expand Down Expand Up @@ -180,35 +194,51 @@ def pilotWrapperDirectory(tmp_path_factory):
def test_getNumberOfJobsNeedingPilots(sd, mocker):
"""Make sure it returns the number of needed pilots"""

# 1. No waiting job, no waiting pilot
# No waiting job, no waiting pilot
# Because it requires an access to a DB, we mock the value returned by the Matcher
mocker.patch.object(sd, "matcherClient", autospec=True)
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({})
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=0, queue="ce1.site3.com_condor")
assert numberToSubmit == 0

# 2. 10 waiting jobs, no waiting pilot
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 10}})
# 10 waiting jobs, no waiting pilot, wrong VO: dummyVO != dteam
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 10, "OwnerGroup": "dummyVO_user"}})
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=0, queue="ce1.site3.com_condor")
assert numberToSubmit == 0

# 10 waiting jobs, no waiting pilot, right VO
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 10, "OwnerGroup": "dteam_user"}})
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=0, queue="ce1.site3.com_condor")
assert numberToSubmit == 10

# 3. 10 waiting jobs split into 2 task queues, no waiting pilot
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 8}, "TQ2": {"Jobs": 2}})
# 10 waiting jobs split into 2 task queues, no waiting pilot, wrong VO: dummyVO != dteam
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK(
{"TQ1": {"Jobs": 8, "OwnerGroup": "dteam_user"}, "TQ2": {"Jobs": 2, "OwnerGroup": "dummyVO_user"}}
)
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=0, queue="ce1.site3.com_condor")
assert numberToSubmit == 8

# 10 waiting jobs split into 2 task queues, no waiting pilot, right VO
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK(
{"TQ1": {"Jobs": 8, "OwnerGroup": "dteam_user"}, "TQ2": {"Jobs": 2, "OwnerGroup": "dteam_user"}}
)
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=0, queue="ce1.site3.com_condor")
assert numberToSubmit == 10

# 4. 10 waiting jobs, 5 waiting pilots
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 10}})
# 10 waiting jobs, 5 waiting pilots
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 10, "OwnerGroup": "dteam_user"}})
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=5, queue="ce1.site3.com_condor")
assert numberToSubmit == 5

# 5. 10 waiting jobs split into 2 task queues, 10 waiting pilots
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 8}, "TQ2": {"Jobs": 2}})
# 10 waiting jobs split into 2 task queues, 10 waiting pilots
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK(
{"TQ1": {"Jobs": 8, "OwnerGroup": "dteam_user"}, "TQ2": {"Jobs": 2, "OwnerGroup": "dteam_user"}}
)
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=10, queue="ce1.site3.com_condor")
assert numberToSubmit == 0

# 6.10 waiting jobs, 20 waiting pilots
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 10}})
# 10 waiting jobs, 20 waiting pilots
sd.matcherClient.getMatchingTaskQueues.return_value = S_OK({"TQ1": {"Jobs": 10, "OwnerGroup": "dteam_user"}})
numberToSubmit = sd._getNumberOfJobsNeedingPilots(waitingPilots=20, queue="ce1.site3.com_condor")
assert numberToSubmit == 0

Expand Down

0 comments on commit c167f0c

Please sign in to comment.