Skip to content

Commit

Permalink
chadmin: --replication-task-error filtering option for partition mani…
Browse files Browse the repository at this point in the history
…pulation commands (#227)
  • Loading branch information
Alex-Burmak authored Aug 22, 2024
1 parent 0254617 commit 617b5cc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ch_tools/chadmin/cli/partition_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def partition_group():
type=int,
help="Filter out replication tasks with more than the specified number of postponements.",
)
@option(
"--replication-task-error",
"--replication-task-exception",
"replication_task_exception",
help="Filter out replication tasks by the specified exception.",
)
@option(
"--detached", is_flag=True, help="Show detached partitions instead of attached."
)
Expand Down Expand Up @@ -253,6 +259,12 @@ def attach_partitions_command(
type=int,
help="Filter out replication tasks with more than the specified number of postponements.",
),
option(
"--replication-task-error",
"--replication-task-exception",
"replication_task_exception",
help="Filter out replication tasks by the specified exception.",
),
constraint=RequireAtLeast(1),
)
@option("-k", "--keep-going", is_flag=True, help="Do not stop on the first error.")
Expand All @@ -276,6 +288,7 @@ def detach_partitions_command(
has_replication_tasks,
min_replication_task_postpone_count,
max_replication_task_postpone_count,
replication_task_exception,
keep_going,
dry_run,
):
Expand All @@ -291,6 +304,7 @@ def detach_partitions_command(
has_replication_tasks=has_replication_tasks,
min_replication_task_postpone_count=min_replication_task_postpone_count,
max_replication_task_postpone_count=max_replication_task_postpone_count,
replication_task_exception=replication_task_exception,
format_="JSON",
)["data"]
for p in partitions:
Expand Down Expand Up @@ -371,6 +385,12 @@ def detach_partitions_command(
type=int,
help="Filter out replication tasks with more than the specified number of postponements.",
),
option(
"--replication-task-error",
"--replication-task-exception",
"replication_task_exception",
help="Filter out replication tasks by the specified exception.",
),
option(
"-l",
"--limit",
Expand Down Expand Up @@ -408,6 +428,7 @@ def reattach_partitions_command(
has_replication_tasks,
min_replication_task_postpone_count,
max_replication_task_postpone_count,
replication_task_exception,
limit,
keep_going,
limit_errors,
Expand Down Expand Up @@ -437,6 +458,7 @@ def _table_formatter(partition):
has_replication_tasks=has_replication_tasks,
min_replication_task_postpone_count=min_replication_task_postpone_count,
max_replication_task_postpone_count=max_replication_task_postpone_count,
replication_task_exception=replication_task_exception,
limit=limit,
format_="JSON",
)["data"]
Expand Down Expand Up @@ -705,11 +727,13 @@ def get_partitions(
has_replication_tasks=None,
min_replication_task_postpone_count=None,
max_replication_task_postpone_count=None,
replication_task_exception=None,
detached=None,
order_by=None,
limit=None,
format_=None,
):
# pylint: disable=too-many-locals
order_by = {
"size": "sum(bytes_on_disk) DESC",
"parts": "parts DESC",
Expand Down Expand Up @@ -828,6 +852,9 @@ def get_partitions(
{% endif -%}
{% if max_replication_task_postpone_count -%}
AND num_postponed <= {{ max_replication_task_postpone_count }}
{% endif -%}
{% if replication_task_exception -%}
AND last_exception {{ format_str_match(replication_task_exception) }}
{% endif -%}
)
{% endif -%}
Expand Down Expand Up @@ -857,6 +884,7 @@ def get_partitions(
has_replication_tasks=has_replication_tasks,
min_replication_task_postpone_count=min_replication_task_postpone_count,
max_replication_task_postpone_count=max_replication_task_postpone_count,
replication_task_exception=replication_task_exception,
order_by=order_by,
limit=limit,
format_=format_,
Expand Down

0 comments on commit 617b5cc

Please sign in to comment.