Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] Drop the system instance level in the CS #7186

Open
wants to merge 7 commits into
base: rel-v8r0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/DIRAC/ConfigurationSystem/Client/PathFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ def divideFullName(entityName, componentName=None):


def getSystemInstance(system, setup=False):
"""Find system instance name
"""Find system instance name.

:param str system: system name
:param str setup: setup name

:return: str
:return: str: instance name. If the system option is present
in the /DIRAC/Setups/<setup> section but is not given a value,
an empty string is returned
"""
optionPath = Path.cfgPath("/DIRAC/Setups", setup or getDIRACSetup(), system)

# If noSetupFlag is set to True, we do not have system instances in the configuration
noSetupFlag = gConfigurationData.extractOptionFromCFG("/DIRAC/NoSetup")
if noSetupFlag == "True":
return ""

setupToUse = setup or getDIRACSetup()
optionPath = Path.cfgPath("/DIRAC/Setups", setupToUse, system)
instance = gConfigurationData.extractOptionFromCFG(optionPath)
if not instance:
raise RuntimeError(f"Option {optionPath} is not defined")
Expand Down
7 changes: 2 additions & 5 deletions src/DIRAC/WorkloadManagementSystem/Agent/StalledJobAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from DIRAC import S_ERROR, S_OK, gConfig
from DIRAC.AccountingSystem.Client.Types.Job import Job
from DIRAC.ConfigurationSystem.Client.Helpers import cfgPath
from DIRAC.ConfigurationSystem.Client.PathFinder import getSystemInstance
from DIRAC.ConfigurationSystem.Client.PathFinder import getSystemSection
from DIRAC.Core.Base.AgentModule import AgentModule
from DIRAC.Core.Utilities import DErrno
from DIRAC.Core.Utilities.ClassAd.ClassAdLight import ClassAd
Expand Down Expand Up @@ -55,9 +55,6 @@ def initialize(self):
if not self.am_getOption("Enable", True):
self.log.info("Stalled Job Agent running in disabled mode")

wms_instance = getSystemInstance("WorkloadManagement")
if not wms_instance:
return S_ERROR("Can not get the WorkloadManagement system instance")
self.stalledJobsTolerantSites = self.am_getOption("StalledJobsTolerantSites", [])
self.stalledJobsToleranceTime = self.am_getOption("StalledJobsToleranceTime", 0)

Expand All @@ -67,7 +64,7 @@ def initialize(self):
self.matchedTime = self.am_getOption("MatchedTime", self.matchedTime)
self.rescheduledTime = self.am_getOption("RescheduledTime", self.rescheduledTime)

wrapperSection = cfgPath("Systems", "WorkloadManagement", wms_instance, "JobWrapper")
wrapperSection = f"{getSystemSection('WorkloadManagement')}/JobWrapper"

failedTime = self.am_getOption("FailedTimeHours", 6)
watchdogCycle = gConfig.getValue(cfgPath(wrapperSection, "CheckingTime"), 30 * 60)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def sja(mocker):
)
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobDB")
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobLoggingDB")
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.getSystemInstance", side_effect=mockNone)
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.getSystemSection", side_effect=mockNone)
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.JobMonitoringClient", return_value=MagicMock())
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.PilotManagerClient", return_value=MagicMock())
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.WMSClient", return_value=MagicMock())
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.getSystemInstance", return_value="/bof/bih")
mocker.patch("DIRAC.WorkloadManagementSystem.Agent.StalledJobAgent.getSystemSection", return_value="/bof/bih")

stalledJobAgent = StalledJobAgent()
stalledJobAgent._AgentModule__configDefaults = mockAM
Expand Down
10 changes: 2 additions & 8 deletions src/DIRAC/WorkloadManagementSystem/JobWrapper/Watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from DIRAC import S_ERROR, S_OK, gLogger
from DIRAC.ConfigurationSystem.Client.Config import gConfig
from DIRAC.ConfigurationSystem.Client.PathFinder import getSystemInstance
from DIRAC.ConfigurationSystem.Client.PathFinder import getSystemSection
from DIRAC.Core.Utilities import MJF
from DIRAC.Core.Utilities.Os import getDiskSpace
from DIRAC.Core.Utilities.Profiler import Profiler
Expand Down Expand Up @@ -104,13 +104,7 @@ def initialize(self):
else:
self.initialized = True

setup = gConfig.getValue("/DIRAC/Setup", "")
if not setup:
return S_ERROR("Can not get the DIRAC Setup value")
wms_instance = getSystemInstance("WorkloadManagement")
if not wms_instance:
return S_ERROR("Can not get the WorkloadManagement system instance")
self.section = f"/Systems/WorkloadManagement/{wms_instance}/JobWrapper"
self.section = f"{getSystemSection('WorkloadManagement')}/JobWrapper"

self.log.verbose("Watchdog initialization")
# Test control flags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_execute(mocker, executable, args, src, expectedResult):
"DIRAC.WorkloadManagementSystem.JobWrapper.JobWrapper.getSystemSection", side_effect=getSystemSectionMock
)
mocker.patch(
"DIRAC.WorkloadManagementSystem.JobWrapper.Watchdog.getSystemInstance", side_effect=getSystemSectionMock
"DIRAC.WorkloadManagementSystem.JobWrapper.Watchdog.getSystemSection", side_effect=getSystemSectionMock
)

if src:
Expand Down
Loading