Skip to content

Commit 41c93fa

Browse files
authored
Merge pull request DIRACGrid#7792 from fstagni/cherry-pick-2-93ad9405b-integration
[sweep:integration] feat: SD will always bundle proxy
2 parents a9c0f75 + 8f88381 commit 41c93fa

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
lines changed

docs/source/AdministratorGuide/Systems/WorkloadManagement/tagsAndJobs.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Let's take an example::
3535
maxCPUTime = 200
3636
MaxTotalJobs = 5
3737
MaxWaitingJobs = 10
38-
BundleProxy = True
3938
RemoveOutput = True
4039
}
4140
# This queue has Tag = GPU. So it will accept:

docs/source/AdministratorGuide/Tutorials/installWMS.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ Then, as ``diracuser`` with the ``dirac_admin`` proxy, we need to define a CE in
227227
CPUTime = 40000
228228
MaxTotalJobs = 5
229229
MaxWaitingJobs = 10
230-
BundleProxy = True
231230
BatchError = /home/diracpilot/localsite/error
232231
ExecutableArea = /home/diracpilot/localsite/submission
233232
RemoveOutput = True

src/DIRAC/WorkloadManagementSystem/Agent/SiteDirector.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ def beginExecution(self):
168168
self.log.always("MaxPilotsToSubmit:", self.maxPilotsToSubmit)
169169

170170
# Build the dictionary of queues that are going to be used: self.queueDict
171-
result = self._buildQueueDict(siteNames, ceTypes, ces, tags)
172-
if not result:
171+
if not (result := self._buildQueueDict(siteNames, ceTypes, ces, tags))["OK"]:
173172
return result
174173

175174
# Stop the execution if there is no usable queue
@@ -449,16 +448,11 @@ def _submitPilotsToQueue(self, pilotsToSubmit: int, ce: ComputingElement, queue:
449448
"""
450449
self.log.info("Going to submit pilots", f"(a maximum of {pilotsToSubmit} pilots to {queue} queue)")
451450

452-
# Get parameters to generate the pilot executable
453-
bundleProxy = self.queueDict[queue].get("BundleProxy", False)
454-
proxy = None
455-
if bundleProxy:
456-
proxy = ce.proxy
457451
jobExecDir = self.queueDict[queue]["ParametersDict"].get("JobExecDir", "")
458452
envVariables = self.queueDict[queue]["ParametersDict"].get("EnvironmentVariables", None)
459453

460454
# Generate the executable
461-
executable = self._getExecutable(queue, proxy=proxy, jobExecDir=jobExecDir, envVariables=envVariables)
455+
executable = self._getExecutable(queue, proxy=ce.proxy, jobExecDir=jobExecDir, envVariables=envVariables)
462456

463457
# Submit the job
464458
submitResult = ce.submitJob(executable, "", pilotsToSubmit)
@@ -564,13 +558,11 @@ def _addPilotReferences(self, queue: str, pilotList: list[str], stampDict: dict[
564558
return result
565559
return S_OK()
566560

567-
def _getExecutable(
568-
self, queue: str, proxy: X509Chain = None, jobExecDir: str = "", envVariables: dict[str, str] = None
569-
):
561+
def _getExecutable(self, queue: str, proxy: X509Chain, jobExecDir: str = "", envVariables: dict[str, str] = None):
570562
"""Prepare the full executable for queue
571563
572564
:param queue: queue name
573-
:param proxy: flag that say if to bundle or not the proxy
565+
:param proxy: proxy to bundle
574566
:param jobExecDir: pilot execution dir (normally an empty string)
575567
576568
:returns: a string the options for the pilot
@@ -580,6 +572,7 @@ def _getExecutable(
580572
if not pilotOptions:
581573
self.log.warn("Pilots will be submitted without additional options")
582574
pilotOptions = []
575+
583576
pilotOptions = " ".join(pilotOptions)
584577
self.log.verbose(f"pilotOptions: {pilotOptions}")
585578

@@ -614,7 +607,7 @@ def _getPilotOptions(self, queue: str) -> list[str]:
614607
setup = gConfig.getValue("/DIRAC/Setup", "unknown")
615608
if setup == "unknown":
616609
self.log.error("Setup is not defined in the configuration")
617-
return [None, None]
610+
return []
618611
pilotOptions.append(f"-S {setup}")
619612
opsHelper = Operations(vo=self.vo, setup=setup)
620613

@@ -687,7 +680,7 @@ def _writePilotScript(
687680
self,
688681
workingDirectory: str,
689682
pilotOptions: str,
690-
proxy: X509Chain = None,
683+
proxy: X509Chain,
691684
pilotExecDir: str = "",
692685
envVariables: dict[str, str] = None,
693686
):
@@ -717,7 +710,6 @@ def _writePilotScript(
717710
location=location,
718711
CVMFS_locations=CVMFS_locations,
719712
)
720-
721713
return _writePilotWrapperFile(workingDirectory=workingDirectory, localPilot=localPilot)
722714

723715
#####################################################################################

src/DIRAC/WorkloadManagementSystem/Agent/test/Test_Agent_SiteDirector.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44

55
import datetime
66
import os
7+
from unittest.mock import MagicMock
8+
79
import pytest
810
from diraccfg import CFG
911

10-
from DIRAC import gLogger, gConfig
12+
from DIRAC import S_OK, gConfig, gLogger
1113
from DIRAC.ConfigurationSystem.Client import ConfigurationData
12-
from DIRAC.Core.Utilities.ProcessPool import S_OK
1314
from DIRAC.ResourceStatusSystem.Client.SiteStatus import SiteStatus
14-
1515
from DIRAC.WorkloadManagementSystem.Agent.SiteDirector import SiteDirector
1616
from DIRAC.WorkloadManagementSystem.Client import PilotStatus
1717

18-
1918
CONFIG = """
2019
Registry
2120
{
@@ -261,13 +260,35 @@ def test_getPilotWrapper(mocker, sd, pilotWrapperDirectory):
261260
"-e 1,2,3",
262261
} == set(pilotOptions)
263262

263+
proxyObject_mock = MagicMock()
264+
proxyObject_mock.dumpAllToString.return_value = S_OK("aProxy")
265+
264266
# Write pilot script
265-
res = sd._writePilotScript(pilotWrapperDirectory, pilotOptions)
267+
res = sd._writePilotScript(pilotWrapperDirectory, pilotOptions, proxyObject_mock)
266268

267269
# Make sure the file exists
268270
assert os.path.exists(res) and os.path.isfile(res)
269271

270272

273+
def test__submitPilotsToQueue(sd):
274+
"""Testing SiteDirector()._submitPilotsToQueue()"""
275+
# Create a MagicMock that does not have the workingDirectory
276+
# attribute (https://cpython-test-docs.readthedocs.io/en/latest/library/unittest.mock.html#deleting-attributes)
277+
# This is to use the SiteDirector's working directory, not the CE one
278+
ceMock = MagicMock()
279+
del ceMock.workingDirectory
280+
proxyObject_mock = MagicMock()
281+
proxyObject_mock.dumpAllToString.return_value = S_OK("aProxy")
282+
ceMock.proxy = proxyObject_mock
283+
284+
sd.queueCECache = {"ce1.site1.com_condor": {"CE": ceMock, "Hash": "3d0dd0c60fffa900c511d7442e9c7634"}}
285+
sd.queueSlots = {"ce1.site1.com_condor": {"AvailableSlots": 10}}
286+
sd._buildQueueDict()
287+
sd.sendSubmissionAccounting = False
288+
sd.sendSubmissionMonitoring = False
289+
assert sd._submitPilotsToQueue(1, ceMock, "ce1.site1.com_condor")["OK"]
290+
291+
271292
def test_updatePilotStatus(sd):
272293
"""Updating the status of some fake pilot references"""
273294
# 1. We have not submitted any pilots, there is nothing to update

src/DIRAC/WorkloadManagementSystem/Utilities/QueueUtilities.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ def getQueuesResolved(siteDict, queueCECache, vo=None, checkPlatform=False, inst
8181
if checkPlatform:
8282
setPlatform(ceDict, queueDict[queueName]["ParametersDict"])
8383

84-
bundleProxy = queueDict[queueName]["ParametersDict"].get("BundleProxy", ceDict.get("BundleProxy"))
85-
if bundleProxy and bundleProxy.lower() in ["true", "yes", "1"]:
86-
queueDict[queueName]["BundleProxy"] = True
87-
8884
return S_OK(queueDict)
8985

9086

0 commit comments

Comments
 (0)