Skip to content

Commit 71b16f0

Browse files
fix: Multiple small fixes to make it work with DIRAC and DiracX
1 parent 6629cd8 commit 71b16f0

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

Pilot/dirac-pilot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@
7676
receivedContent = ""
7777
if not sys.stdin.isatty():
7878
receivedContent = sys.stdin.read()
79+
7980
log = RemoteLogger(
8081
pilotParams.diracXServer,
8182
"Pilot",
8283
bufsize=pilotParams.loggerBufsize,
8384
pilotUUID=pilotParams.pilotUUID,
8485
debugFlag=pilotParams.debugFlag,
8586
jwt=pilotParams.jwt,
86-
isPilotLoggerOn=pilotParams.isLegacyLogging
87+
legacy_logging=pilotParams.isLegacyLogging
8788
)
88-
log.info(str(pilotParams.jwt))
8989
log.info("Remote logger activated")
9090
log.buffer.write(log.format_to_json(
9191
"INFO",

Pilot/pilotCommands.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,20 @@ def wrapper(self):
9090
self.log.info(
9191
"Flushing the remote logger buffer for pilot on sys.exit(): %s (exit code:%s)" % (pRef, str(exCode))
9292
)
93-
if self.pp.jwt:
94-
try:
95-
self.log.error(str(exCode))
96-
self.log.error(traceback.format_exc())
97-
self.log.buffer.flush(force=True)
98-
except Exception as exc:
99-
self.log.error("Remote logger couldn't be finalised %s " % str(exc))
100-
else:
101-
# No force here because there's no remote logger if we're here
102-
self.log.buffer.flush()
93+
94+
try:
95+
self.log.error(str(exCode))
96+
self.log.error(traceback.format_exc())
97+
self.log.buffer.flush(force=True)
98+
except Exception as exc:
99+
self.log.error("Remote logger couldn't be finalised %s " % str(exc))
103100

104101
raise
105102
except Exception as exc:
106103
# unexpected exit: document it and bail out.
107104
self.log.error(str(exc))
108105
self.log.error(traceback.format_exc())
109-
110-
if self.pp.jwt:
111-
# Force flush if it's a remote logger
112-
self.log.buffer.flush(force=True)
113-
else:
114-
self.log.buffer.flush()
106+
self.log.buffer.flush(force=True)
115107
raise
116108
finally:
117109
self.log.buffer.cancelTimer()

Pilot/pilotTools.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,13 @@ def sendMessage(diracx_URL, pilotUUID, legacy=False, jwt={}, rawMessage = []):
719719
"lines": rawMessage
720720
}
721721

722+
if not diracx_URL.endswith("/"):
723+
diracx_URL += "/"
724+
722725
if legacy:
723-
endpoint_path = "/api/pilots/legacy/message"
726+
endpoint_path = "api/pilots/legacy/message"
724727
else:
725-
endpoint_path = "/api/pilots/internal/message"
728+
endpoint_path = "api/pilots/internal/message"
726729

727730
config = TokenBasedRequest(
728731
diracx_URL=diracx_URL,
@@ -772,7 +775,7 @@ def __init__(self, pilotParams):
772775
flushInterval=interval,
773776
bufsize=bufsize,
774777
jwt=pilotParams.jwt,
775-
legacy_logging=self.pp.isLegacyLogging
778+
legacy_logging=pilotParams.isLegacyLogging
776779
)
777780

778781
self.log.isPilotLoggerOn = isPilotLoggerOn
@@ -1137,6 +1140,7 @@ def __set_remote_logging(self):
11371140
with open(cert, "rb") as fp:
11381141
self.jwt = extract_diracx_payload(fp.read())
11391142
self.isLegacyLogging = True
1143+
self.log.info("Successfully extracted token from proxy.")
11401144
else:
11411145
raise RuntimeError("Could not locate a proxy via X509_USER_PROXY")
11421146
else:

0 commit comments

Comments
 (0)