Skip to content

Commit

Permalink
Merge pull request #208 from fstagni/fixes_5
Browse files Browse the repository at this point in the history
[devel] Better reporting of errors
  • Loading branch information
fstagni authored Oct 3, 2023
2 parents 7457488 + 5c50aa9 commit e1505d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Pilot/pilotCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -293,7 +292,7 @@ def _locateInstallationScript(self):
self.pp.rootPath,
)
)
sys.exit(1)
self.exitWithError(1)

try:
# change permission of the script
Expand Down Expand Up @@ -634,6 +633,10 @@ def __init__(self, pilotParams):
def execute(self):
"""Calls dirac-admin-add-pilot"""

if not which("dirac-admin-add-pilot") or not self.pp.pilotReference:
self.log.info("Skipping module")
return

if self.pp.useServerCertificate:
pilotOwnerGroup = "certificate_group"
else:
Expand Down Expand Up @@ -695,7 +698,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 @@ -776,7 +779,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 @@ -1023,7 +1026,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 @@ -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()
Expand Down

0 comments on commit e1505d9

Please sign in to comment.