Skip to content

Commit

Permalink
fix: better reporting of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Oct 2, 2023
1 parent d394f20 commit 239d945
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Pilot/pilotCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ def execute(self):
self.log.error(
"%s MB < %s MB, not enough local disk space available, exiting" % (diskSpace, self.pp.minDiskSpace)
)
sys.exit(1)

self.exitWithError(1)

class InstallDIRAC(CommandBase):
"""Basically, this is used to call dirac-install with the passed parameters.
Expand Down Expand Up @@ -292,7 +291,7 @@ def _locateInstallationScript(self):
self.pp.rootPath,
)
)
sys.exit(1)
self.exitWithError(1)

try:
# change permission of the script
Expand Down Expand Up @@ -694,7 +693,7 @@ def execute(self):
resourceDict = json.loads(resourceDict.strip().split("\n")[-1])
except ValueError:
self.log.error("The pilot command output is not json compatible.")
sys.exit(1)
self.exitWithError(1)

self.pp.queueParameters = resourceDict
for queueParamName, queueParamValue in self.pp.queueParameters.items():
Expand Down Expand Up @@ -773,7 +772,7 @@ def execute(self):
numberOfGPUs = 0
except ValueError:
self.log.error("Wrong Command output %s" % result)
sys.exit(1)
self.exitWithError(1)

# If NumberOfProcessors or MaxRAM are defined in the resource configuration, these
# values are preferred
Expand Down Expand Up @@ -1006,7 +1005,7 @@ def execute(self):
self.log.info("Queue length (which is also set as CPUTimeLeft) is %f" % self.pp.jobCPUReq)
except ValueError:
self.log.error("Pilot command output does not have the correct format")
sys.exit(1)
self.exitWithError(1)
# now setting this value in local file
cfg = ["-FDMH"]
if self.pp.useServerCertificate:
Expand Down
4 changes: 4 additions & 0 deletions Pilot/pilotTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,10 @@ def executeAndGetOutput(self, cmd, environDict=None):

def exitWithError(self, errorCode):
"""Wrapper around sys.exit()"""
self.log.info("Content of pilot.cfg")
with open("pilot.cfg") as f:
print(f.read())

self.log.info("List of child processes of current PID:")
retCode, _outData = self.executeAndGetOutput(
"ps --forest -o pid,%%cpu,%%mem,tty,stat,time,cmd -g %d" % os.getpid()
Expand Down

0 comments on commit 239d945

Please sign in to comment.