Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorten the error message in orphaned-objects monrun check #265

Merged
merged 12 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added regular pattern for handle errors in orphaned-objects monrun check
Nikita Unisikhin committed Dec 5, 2024
commit 4b72bedefdf3839cf41c9721528e4c6ec53f4ed0
4 changes: 4 additions & 0 deletions ch_tools/monrun_checks/ch_orphaned_objects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import click
import re

from ch_tools.chadmin.cli.object_storage_group import STATE_LOCAL_PATH
from ch_tools.chadmin.internal.object_storage.orphaned_objects_state import (
@@ -53,6 +54,9 @@ def orphaned_objects_command(

total_size = state.orphaned_objects_size
error_msg = state.error_msg

pattern = r"(Code:\s\d+\.\sDB::Exception:\s).*(\([A-Z_]*\)\s\(version\s.*\s\(official build\)\)).*"
error_msg = re.sub(pattern, r"...", error_msg)

if error_msg != "":
return Result(CRIT, error_msg)
2 changes: 1 addition & 1 deletion tests/features/monrun.feature
Original file line number Diff line number Diff line change
@@ -504,7 +504,7 @@ Feature: ch-monitoring tool
"""

Scenario: Check clickhouse orphaned objects with not empty error_msg
When we create file /tmp/object_storage_cleanup_state.json with data "{ \"orphaned_objects_size\": 0, \"error_msg\": \"ERROR\" }"
When we create file /tmp/object_storage_cleanup_state.json with data "{ \"orphaned_objects_size\": 0, \"error_msg\": \"27. DB::Exception: Cannot parse: input:: expected '\\t' before: 'klg%2D1acvr8hmq0n16qm5%2Edb%2Eyandex%2Enet\\ndefault\\n6736d483-516a-4892-87d4-084d5c1f6d3c\\n': While executing SystemRemoteDataPaths. (SOME_OTHER_ERROR_CODE) (version 24.8.5.115 (official build)) Query: SELECT obj_path, obj_size FROM _system.listing_objects_from_object_storage AS object_storage LEFT ANTI JOIN remoteSecure('klg-1acvr8hmq0n16qm5.db.yandex.net', system.remote_data_paths) AS object_table ON object_table.remote_path = object_storage.obj_path AND object_table.disk_name = 'object_storage' SETTINGS traverse_shadow_remote_data_paths=1 FORMAT TabSeparated (klg-1acvr8hmq0n16qm5.mdb.yandex.net)\" }"
And we execute command on clickhouse01
"""
ch-monitoring orphaned-objects --state-local