From 6229422a360fc01eabedd75bc6d110e8c64a51b2 Mon Sep 17 00:00:00 2001 From: Nikita Unisikhin Date: Fri, 6 Dec 2024 16:10:22 +0300 Subject: [PATCH] Refactoring, update ch_tools/common/config.py --- ch_tools/common/config.py | 4 ++++ ch_tools/monrun_checks/ch_orphaned_objects.py | 11 +---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ch_tools/common/config.py b/ch_tools/common/config.py index cc7d3769..727ec55c 100644 --- a/ch_tools/common/config.py +++ b/ch_tools/common/config.py @@ -84,6 +84,10 @@ "pattern": "\n", "replacement": " ", }, + { + "pattern": r"(Code:\s\d+\.\sDB::Exception:\s).*(\s\([A-Z_]*\)\s\(version\s.*\s\(official build\)\)\s).*", + "replacement": r"\1...\2...", + }, ], }, }, diff --git a/ch_tools/monrun_checks/ch_orphaned_objects.py b/ch_tools/monrun_checks/ch_orphaned_objects.py index c16cc43c..959e2b8f 100644 --- a/ch_tools/monrun_checks/ch_orphaned_objects.py +++ b/ch_tools/monrun_checks/ch_orphaned_objects.py @@ -1,5 +1,3 @@ -import re - import click from ch_tools.chadmin.cli.object_storage_group import STATE_LOCAL_PATH @@ -9,8 +7,6 @@ from ch_tools.chadmin.internal.zookeeper import get_zk_node from ch_tools.common.result import CRIT, OK, WARNING, Result -ERROR_MESSAGE_PATTERN = r"(Code:\s\d+\.\sDB::Exception:\s).*(\s\([A-Z_]*\)\s\(version\s.*\s\(official build\)\)\s).*" - @click.command("orphaned-objects") @click.option( @@ -56,7 +52,7 @@ def orphaned_objects_command( return Result(CRIT, str(e)) total_size = state.orphaned_objects_size - error_msg = _error_message_format(state.error_msg) + error_msg = state.error_msg if error_msg != "": return Result(CRIT, error_msg) @@ -104,8 +100,3 @@ def _zk_get_orphaned_objects_state( ) -> "OrphanedObjectsState": zk_data = get_zk_node(ctx, state_zk_path) return OrphanedObjectsState.from_json(zk_data) - - -def _error_message_format(error_msg: str) -> str: - error_msg = re.sub(ERROR_MESSAGE_PATTERN, r"\1...\2...", error_msg) - return error_msg