From 62361b148c87d2e8a384401d48adfb217c1fdae6 Mon Sep 17 00:00:00 2001 From: Wen Guan Date: Wed, 25 Sep 2024 10:48:36 +0200 Subject: [PATCH 1/2] update request2 timeout --- pilot/control/payload.py | 2 +- pilot/util/https.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pilot/control/payload.py b/pilot/control/payload.py index 7d091073..77b20aa7 100644 --- a/pilot/control/payload.py +++ b/pilot/control/payload.py @@ -444,7 +444,7 @@ def get_logging_info(job: JobData, args: object) -> dict: logger.info("correct logserver formal: logging_type;protocol://hostname:port") return {} - regex = r"logserver='(?P[^;]+);(?P[^:]+)://(?P[^:]+):(?P\d+)'" + regex = r"logserver=(?P[^;]+);(?P[^:]+)://(?P[^:]+):(?P\d+)" match = search(regex, logserver) if match: logging_type = match.group('logging_type') diff --git a/pilot/util/https.py b/pilot/util/https.py index a26c75ce..71efa45f 100644 --- a/pilot/util/https.py +++ b/pilot/util/https.py @@ -858,7 +858,8 @@ def request2(url: str = "", # Send the request securely try: logger.debug('sending data to server') - with urllib.request.urlopen(req, context=ssl_context, timeout=30) as response: + timeout = int(config.Pilot.http_maxtime) + with urllib.request.urlopen(req, context=ssl_context, timeout=timeout) as response: # Handle the response here logger.debug(f"response.status={response.status}, response.reason={response.reason}") ret = response.read().decode('utf-8') From 2729a514fedeb0836d50373b0b511b866de84079 Mon Sep 17 00:00:00 2001 From: Wen Guan Date: Wed, 25 Sep 2024 14:41:03 +0200 Subject: [PATCH 2/2] disable some labels because some loki can limit the number of labels --- pilot/util/lokirealtimelogger.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pilot/util/lokirealtimelogger.py b/pilot/util/lokirealtimelogger.py index 50b3a5cc..72933352 100644 --- a/pilot/util/lokirealtimelogger.py +++ b/pilot/util/lokirealtimelogger.py @@ -51,18 +51,22 @@ def format(self, record: logging.LogRecord) -> dict: formatted = { "timestamp": record.created, - "process": record.process, - "thread": record.thread, + # "process": record.process, + # "thread": record.thread, "function": record.funcName, "module": record.module, "name": record.name, "level": record.levelname, } + """ + # Not send all information, some loki services have limitations on number of labels. + record_keys = set(record.__dict__.keys()) for key in record_keys: if key not in formatted and key not in ['msg']: formatted[key] = getattr(record, key) + """ message = record.msg try: