Skip to content

Commit 5f5df10

Browse files
authored
Merge pull request #8126 from chrisburr/get-it-working
[9.0] Remove platform validation
2 parents 2e7a79a + 993e6b8 commit 5f5df10

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
lines changed

src/DIRAC/WorkloadManagementSystem/Agent/JobAgent.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sys
99
import re
1010
import time
11+
from pathlib import Path
1112

1213
from diraccfg import CFG
1314

@@ -17,6 +18,7 @@
1718
from DIRAC.Core.Base.AgentModule import AgentModule
1819
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
1920
from DIRAC.Core.Security import Properties
21+
from DIRAC.Core.Security.ProxyFile import writeChainToTemporaryFile
2022
from DIRAC.Core.Utilities import DErrno
2123
from DIRAC.Core.Utilities.ObjectLoader import ObjectLoader
2224
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
@@ -626,13 +628,15 @@ def _submitJob(
626628

627629
self.log.info("Submitting JobWrapper", f"{os.path.basename(wrapperFile)} to {self.ceName}CE")
628630

629-
# Pass proxy to the CE
630-
proxy = proxyChain.dumpAllToString()
631-
if not proxy["OK"]:
632-
self.log.error("Invalid proxy", proxy)
633-
return S_ERROR("Payload Proxy Not Found")
631+
# Pass proxy to the CE, writing it to a temporary file to ensure the DiracX token is included
632+
retVal = writeChainToTemporaryFile(proxyChain)
633+
if not retVal["OK"]:
634+
self.log.error("Invalid proxy", retVal["Message"])
635+
return S_ERROR("Failed to write proxy to temporary file")
636+
proxyLocation = Path(retVal["Value"])
637+
payloadProxy = proxyLocation.read_text()
638+
proxyLocation.unlink()
634639

635-
payloadProxy = proxy["Value"]
636640
try:
637641
result = self.computingElement.submitJob(
638642
wrapperFile,

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def test_submitJob(mocker, mockJWInput, expected):
611611
("Pool/Singularity", jobScript % "1", (["Failed to find singularity"], []), ([], [])),
612612
],
613613
)
614-
def test_submitAndCheckJob(mocker, manageJobFiles, localCE, job, expectedResult1, expectedResult2):
614+
def test_submitAndCheckJob(mocker, manageJobFiles, localCE, job, expectedResult1, expectedResult2, tmp_path):
615615
"""Test the submission and the management of the job status."""
616616
jobID = "123"
617617
jobExecutablePath, jobWrapperPath, jobWrapperConfigPath = manageJobFiles
@@ -635,7 +635,12 @@ def test_submitAndCheckJob(mocker, manageJobFiles, localCE, job, expectedResult1
635635
),
636636
)
637637
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.JobAgent._sendFailoverRequest", return_value=S_OK())
638-
mocker.patch("DIRAC.Core.Security.X509Chain.X509Chain.dumpAllToString", return_value=S_OK())
638+
empty_file_path = tmp_path / "empty_file"
639+
empty_file_path.touch()
640+
mocker.patch(
641+
"DIRAC.WorkloadManagementSystem.Agent.JobAgent.writeChainToTemporaryFile",
642+
return_value=S_OK(str(empty_file_path)),
643+
)
639644
mocker.patch(
640645
"DIRAC.Resources.Computing.SingularityComputingElement.SingularityComputingElement.submitJob",
641646
return_value=S_ERROR("Failed to find singularity"),
@@ -712,7 +717,7 @@ def test_submitAndCheckJob(mocker, manageJobFiles, localCE, job, expectedResult1
712717
assert len(jobAgent.computingElement.taskResults) == 0
713718

714719

715-
def test_submitAndCheck2Jobs(mocker):
720+
def test_submitAndCheck2Jobs(mocker, tmp_path):
716721
"""Test the submission and the management of the job status.
717722
718723
This time, a first job is successfully submitted, but the second submission fails.
@@ -728,7 +733,17 @@ def test_submitAndCheck2Jobs(mocker):
728733
),
729734
)
730735
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.JobAgent.JobAgent._sendFailoverRequest", return_value=S_OK())
731-
mocker.patch("DIRAC.Core.Security.X509Chain.X509Chain.dumpAllToString", return_value=S_OK())
736+
737+
def make_empty_file(*args, **kwargs):
738+
"""Create an empty file and return its path."""
739+
empty_file_path = tmp_path / "empty_file"
740+
empty_file_path.touch()
741+
return S_OK(str(empty_file_path))
742+
743+
mocker.patch(
744+
"DIRAC.WorkloadManagementSystem.Agent.JobAgent.writeChainToTemporaryFile",
745+
make_empty_file,
746+
)
732747
mocker.patch(
733748
"DIRAC.Resources.Computing.InProcessComputingElement.InProcessComputingElement.submitJob",
734749
side_effect=[S_OK(), S_ERROR("ComputingElement error")],

src/DIRAC/WorkloadManagementSystem/Utilities/JobModel.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,6 @@ def checkThatSitesAndBannedSitesAreNotMutuallyExclusive(self) -> Self:
184184
raise ValueError("sites and bannedSites are mutually exclusive")
185185
return self
186186

187-
@field_validator("platform")
188-
def checkPlatform(cls, v: str):
189-
if v:
190-
res = getDIRACPlatforms()
191-
if not res["OK"]:
192-
raise ValueError(res["Message"])
193-
if v not in res["Value"]:
194-
raise ValueError("Invalid platform")
195-
return v
196-
197187
@field_validator("priority")
198188
def checkPriorityBounds(cls, v):
199189
minPriority = Operations().getValue("JobDescription/MinPriority", 0)

src/DIRAC/WorkloadManagementSystem/Utilities/test/Test_JobModel.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,6 @@ def test_platformValidator_valid():
183183
assert job.platform == "x86_64-slc6-gcc62-opt"
184184

185185

186-
def test_platformValidator_invalid():
187-
"""Test the platform validator with invalid input."""
188-
with patch(
189-
"DIRAC.WorkloadManagementSystem.Utilities.JobModel.getDIRACPlatforms",
190-
return_value=S_OK(["x86_64-slc6-gcc62-opt"]),
191-
):
192-
with pytest.raises(ValidationError):
193-
BaseJobDescriptionModel(executable=EXECUTABLE, platform="x86_64-slc6-gcc62-opt2")
194-
195-
196186
@pytest.mark.parametrize(
197187
"validSites, selectedSites",
198188
[

0 commit comments

Comments
 (0)