From 1d2072337a7aee644cbcf561aa2496e60d4394a7 Mon Sep 17 00:00:00 2001 From: raghuvar-vijay Date: Wed, 18 Dec 2024 15:45:57 +0100 Subject: [PATCH] fix: Raise the error in decode_record fn to main in htcondor_revert_encodings.py & remove encoding of records for HTCondor --- .../htcondor_revert_encoding/htcondor_revert_encodings.py | 5 +++-- .../htcondor/src/auditor_htcondor_collector/collector.py | 7 ++----- media/website/content/migration.md | 4 +++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/auditor/scripts/htcondor_revert_encoding/htcondor_revert_encodings.py b/auditor/scripts/htcondor_revert_encoding/htcondor_revert_encodings.py index 70c376627..0eba67450 100644 --- a/auditor/scripts/htcondor_revert_encoding/htcondor_revert_encodings.py +++ b/auditor/scripts/htcondor_revert_encoding/htcondor_revert_encodings.py @@ -1,5 +1,6 @@ import json import os +from json.decoder import JSONDecodeError from urllib.parse import unquote import psycopg2 @@ -27,8 +28,8 @@ def decode_record(record_id, meta): decoded_meta = { key: [unquote(value) for value in values] for key, values in meta.items() } - except json.JSONDecodeError: - decoded_meta = {} # If JSON decoding fails, return an empty dict + except Exception as e: + raise JSONDecodeError(f"Error decoding meta: {e}", str(meta), 0) return decoded_record_id, json.dumps(decoded_meta) diff --git a/collectors/htcondor/src/auditor_htcondor_collector/collector.py b/collectors/htcondor/src/auditor_htcondor_collector/collector.py index 548ce3efa..ddf7a2dde 100644 --- a/collectors/htcondor/src/auditor_htcondor_collector/collector.py +++ b/collectors/htcondor/src/auditor_htcondor_collector/collector.py @@ -6,7 +6,6 @@ from datetime import datetime as dt from datetime import timezone from typing import List, Optional, Tuple -from urllib.parse import quote from pyauditor import ( AuditorClient, @@ -221,7 +220,7 @@ def _get_meta(self, job: dict) -> Meta: for item in entry if isinstance(entry, list) else [entry]: value = get_value(item, job) if value is not None: - values.append(quote(value, safe="")) + values.append(value) if key == "site": # site is a special case break if values: @@ -260,9 +259,7 @@ def _generate_record(self, job: dict) -> Record: meta = self._get_meta(job) try: - record_id = ( - f"{self.config.record_prefix}-{quote(job_id.encode('utf-8'), safe='')}" - ) + record_id = f"{self.config.record_prefix}-{job_id}" record = Record( record_id=record_id, start_time=dt.fromtimestamp(start_time, tz=timezone.utc), diff --git a/media/website/content/migration.md b/media/website/content/migration.md index 94952ce38..ae68ccc7b 100644 --- a/media/website/content/migration.md +++ b/media/website/content/migration.md @@ -4,7 +4,9 @@ description = "Migration Guide" weight = 3 +++ -# From 0.6.3 to unreleased/0.7.0 +# From 0.6.3 to unreleased/0.7.0 + +Please backup your db before proceeding with any changes that are listed below. ## Remove forbidden characters: The following changes only apply to users who are either using HTCondor collector (v0.6.3 and earlier) or slurm collector (v0.6.3 and earlier).