Yelp / kafka-utils

Apache License 2.0
313 stars 127 forks source link

When a decommission node is empty, don't crash on max/min functions #281

Closed lsterk closed 2 years ago

lsterk commented 2 years ago

If a broker is being decommissioned and it's already empty, we don't have any need to move other topics. Thus, partitions_to_move is an empty set.

Currently, the code will crash with an error:

[2021-11-09 15:36:05,992] [CRITICAL:main] Uncaught exception:
Traceback (most recent call last):
...
  File "<>/site-packages/kafka_utils/kafka_cluster_manager/cmds/decommission.py", line 112, in run_command
    for partition in partitions_to_move
ValueError: max() arg is an empty sequence

I added a unit test to reproduce this issue (it failed without these changes), and it passes now.

My understanding is that if the partitions_to_move is empty, then self.args.max_movement_size being 1 doesn't have any impact.

Release Plan

Patch version release