Skip to content

Commit

Permalink
Refactoring, update ch_tools/common/config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Unisikhin committed Dec 6, 2024
1 parent 4b1fd6c commit 6229422
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 4 additions & 0 deletions ch_tools/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
},
],
},
},
Expand Down
11 changes: 1 addition & 10 deletions ch_tools/monrun_checks/ch_orphaned_objects.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import re

import click

from ch_tools.chadmin.cli.object_storage_group import STATE_LOCAL_PATH
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 6229422

Please sign in to comment.