Skip to content

Commit

Permalink
feat: changes to drop the system instance level in the CS
Browse files Browse the repository at this point in the history
  • Loading branch information
atsareg committed Sep 5, 2023
1 parent c8be7f8 commit 469a20e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
13 changes: 8 additions & 5 deletions src/DIRAC/ConfigurationSystem/Client/PathFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ def getSystemInstance(system, setup=False):
:return: str
"""
optionPath = Path.cfgPath("/DIRAC/Setups", setup or getDIRACSetup(), system)
instance = gConfigurationData.extractOptionFromCFG(optionPath)
if not instance:
raise RuntimeError(f"Option {optionPath} is not defined")
return instance
if "Setups" in gConfigurationData.getSectionsFromCFG("/DIRAC"):
optionPath = Path.cfgPath("/DIRAC/Setups", setup or getDIRACSetup(), system)
instance = gConfigurationData.extractOptionFromCFG(optionPath)
if not instance:
raise RuntimeError(f"Option {optionPath} is not defined")
return instance
# If /DIRAC/Setups is not present in the CS return empty instance string
return ""


def getSystemSection(system, instance=False, setup=False):
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 @@ -20,7 +20,7 @@
from DIRAC.Core.Utilities.TimeUtilities import fromString, toEpoch, second
from DIRAC.Core.Utilities.ClassAd.ClassAdLight import ClassAd
from DIRAC.ConfigurationSystem.Client.Helpers import cfgPath
from DIRAC.ConfigurationSystem.Client.PathFinder import getSystemInstance
from DIRAC.ConfigurationSystem.Client.PathFinder import getSystemSection
from DIRAC.WorkloadManagementSystem.Client.WMSClient import WMSClient
from DIRAC.WorkloadManagementSystem.Client.JobMonitoringClient import JobMonitoringClient
from DIRAC.WorkloadManagementSystem.Client.PilotManagerClient import PilotManagerClient
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
7 changes: 2 additions & 5 deletions src/DIRAC/WorkloadManagementSystem/JobWrapper/Watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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 @@ -113,10 +113,7 @@ def initialize(self):
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

0 comments on commit 469a20e

Please sign in to comment.