Skip to content

Commit

Permalink
Create consts
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Unisikhin committed Dec 5, 2024
1 parent 5aac2eb commit 9fda477
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ch_tools/monrun_checks/ch_orphaned_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from ch_tools.chadmin.internal.zookeeper import get_zk_node
from ch_tools.common.result import CRIT, OK, WARNING, Result

MAIN_ERROR_MESSAGE_PATTER = r"(Code:\s\d+\.\sDB::Exception:\s).*(\s\([A-Z_]*\)\s\(version\s.*\s\(official build\)\)).*"
SPARE_ERROR_MESSAGE_PATTER = r"(Code:\s\d+\.\sDB::Exception:\s).*"


@click.command("orphaned-objects")
@click.option(
Expand Down Expand Up @@ -105,10 +108,8 @@ def _zk_get_orphaned_objects_state(


def _error_message_format(error_msg: str) -> str:
main_pattern = r"(Code:\s\d+\.\sDB::Exception:\s).*(\s\([A-Z_]*\)\s\(version\s.*\s\(official build\)\)).*"
spare_pattern = r"(Code:\s\d+\.\sDB::Exception:\s).*"
if re.match(main_pattern, error_msg):
error_msg = re.sub(main_pattern, r"\1...\2", error_msg)
elif re.match(spare_pattern, error_msg):
error_msg = re.sub(main_pattern, r"\1...", error_msg)
if re.match(MAIN_ERROR_MESSAGE_PATTER, error_msg):
error_msg = re.sub(MAIN_ERROR_MESSAGE_PATTER, r"\1...\2", error_msg)
elif re.match(SPARE_ERROR_MESSAGE_PATTER, error_msg):
error_msg = re.sub(SPARE_ERROR_MESSAGE_PATTER, r"\1...", error_msg)
return error_msg

0 comments on commit 9fda477

Please sign in to comment.