From bc07f2895fca6e6fe01ab29a2b116b626ff9d2ef Mon Sep 17 00:00:00 2001 From: fstagni Date: Fri, 29 Sep 2023 13:36:27 +0200 Subject: [PATCH] fix: better reporting of errors --- Pilot/pilotCommands.py | 11 +++++------ Pilot/pilotTools.py | 4 ++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Pilot/pilotCommands.py b/Pilot/pilotCommands.py index 6505f2f4..549c5f88 100644 --- a/Pilot/pilotCommands.py +++ b/Pilot/pilotCommands.py @@ -194,8 +194,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. @@ -293,7 +292,7 @@ def _locateInstallationScript(self): self.pp.rootPath, ) ) - sys.exit(1) + self.exitWithError(1) try: # change permission of the script @@ -695,7 +694,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(): @@ -776,7 +775,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 @@ -1023,7 +1022,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: diff --git a/Pilot/pilotTools.py b/Pilot/pilotTools.py index f4889da2..35bc51f2 100644 --- a/Pilot/pilotTools.py +++ b/Pilot/pilotTools.py @@ -696,6 +696,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()