From fed7bfa2d54269babdc3a40a886be4e7faff63be Mon Sep 17 00:00:00 2001 From: Moritz Kiemer Date: Thu, 16 Jan 2025 16:44:40 +0100 Subject: [PATCH] counter conversion: continue upon error Change-Id: I0b9670cc43717e5e6e9d666d1396b9f319266df6 --- .../plugins/actions/counters_conversion.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmk/update_config/plugins/actions/counters_conversion.py b/cmk/update_config/plugins/actions/counters_conversion.py index 356681aa6cb..a79d14ef6cc 100644 --- a/cmk/update_config/plugins/actions/counters_conversion.py +++ b/cmk/update_config/plugins/actions/counters_conversion.py @@ -46,11 +46,17 @@ def convert_counter_files(counters_path: Path, logger: Logger) -> None: continue logger.debug(msg_temp, "converting", f) - f.write_text( - json.dumps( - [(k, repr(v)) for k, v in ast.literal_eval(content).items()], + try: + f.write_text( + json.dumps( + [(k, repr(v)) for k, v in ast.literal_eval(content).items()], + ) ) - ) + except Exception as exc: + # We've seen this conversion fail upon what seemed to be partially written files. + # After the fact, we've never seen any traces of them. + # At least continue with all the other files. + logger.warning(msg_temp, f"failed ({exc})", f) update_action_registry.register(