Partition Reassignments
Pilot executes partition reassignments with managed throttling, progress tracking, and cancellation support. Reassignments can be triggered from proposals, the API, or self-healing.
Throttle Management
Pilot manages Kafka replication throttles to prevent reassignments from overwhelming brokers.
| Variable | Default | Description |
|---|---|---|
PILOT_THROTTLE_RATE_MB | 50 | Default throttle rate (MB/s) |
PILOT_THROTTLE_MAX_RATE_MB | 1000 | Highest rate the tuning API accepts (MB/s) |
PILOT_THROTTLE_MANAGED | true | Pilot sets and removes replication throttles for its moves |
With PILOT_THROTTLE_MANAGED=true, Pilot sets throttles for its moves and removes only the ones it set (see Throttles Pilot Did Not Set). Standalone Pilot also removes the throttles an earlier run of Pilot left, once Kafka lists no reassignment in progress (see Reassignments Found at Startup).
Set it to false when another tool manages throttles:
- Pilot sets no replication throttles. Its moves run under the throttles you set.
- A throttle rate change through
PUT /api/v1/reassignments/tuning, MCP or the UI is only stored and says that no broker uses it. - Standalone proposals are marked unsafe to apply (
throttles_externally_managed), so self-healing skips them and a manual apply needsforce=true.
In HA mode, Pilot also removes only the throttles it set, and it runs no removal at startup; see HA replication throttles.
Throttles Pilot Did Not Set
Pilot never changes or removes a replication throttle it did not set.
- A broker that already has its own
leader.replication.throttled.rate,follower.replication.throttled.rateorreplica.alter.log.dirs.io.max.bytes.per.secondkeeps it. Pilot’s moves on that broker run under it. - On a topic, Pilot adds only the
leader.replication.throttled.replicasandfollower.replication.throttled.replicasentries the topic does not list yet, and later removes only those. A list of*stays as it is. - A value someone changes after Pilot set it stays when Pilot’s moves end.
- Cluster-wide dynamic defaults and static broker settings are never changed.
Standalone Pilot records each broker rate it did not set once in the audit log as throttles.ownership. HA mode records an operator’s change as throttles.ha-ownership.
Limits:
- If Pilot could not save its record of a throttle before a restart, that throttle stays. Remove it with
kafka-configs --alter --delete-config. - If another tool adds the same throttle entry while Pilot’s moves run, it is removed together with Pilot’s.
- When Pilot removes the last entry of a
leader.replication.throttled.replicasorfollower.replication.throttled.replicaslist, in standalone and HA mode, Kafka keeps the key with an empty value. Kafka cannot remove a list only while it is empty, so Pilot leaves the key. An empty list throttles nothing, and Pilot’s topic configuration shows it as Inherited, like the default;kafka-configs --describestill lists it. To remove it, Unset the key in the bulk configuration dialog or runkafka-configs --alter --delete-config.
Active execution cards show the Target throttle for that operation: the follower replication limit on the brokers that receive new replicas. It is not a cluster-wide bandwidth cap or a measured transfer rate.
Different target limits are shown as Mixed limits. Missing broker configuration is shown as Unavailable. Operations without new replica destinations, such as leadership-only changes, show Not applicable. An operation found at startup shows no target throttle.
Concurrency Control
PILOT_MOVE_MAX_PER_BROKER=20 # Max concurrent moves per brokerPartitions are queued and submitted in batches, respecting the per-broker concurrency limit. Pilot submits new partitions as capacity becomes available.
Progress Tracking
Open Execution to inspect active operations and their history. Pilot periodically checks the status of all tracked assignments:
- Active - partitions currently being moved by Kafka
- Pending - partitions queued, waiting for broker capacity
- Completed - moves finished successfully
- Failed - moves that encountered errors
- Cancelled - assignments recorded as cancelled
Progress counts completed assignments out of the submitted targets. It does not measure bytes copied or provide a transfer ETA. Queued assignments remain unfinished work even when Kafka has no active transfers.
GET /api/v1/reassignments returns the same operations. A bulk operation lists at most 1000 assignments, preferring those in progress, unconfirmed or failed, and assignment_counts counts all of them (total, completed, failed, cancelled, in_progress, uncertain, pending). uncertain counts HA assignments whose outcome is not yet confirmed. Add ?full=true to list every assignment.
GET /api/v1/reassignments/{id}/assignments searches all assignments of one bulk operation by topic, partition, or assignment ID (search) and by status. It lists at most 1000 matches, preferring those in progress, unconfirmed or failed, and matched counts all of them. The search and status filter under Execution also cover every assignment. See the OpenAPI specification for the response schema.
Execution Time
An execution has no time limit. It runs until every move is done or it is stopped: by a cancel, by a self-heal’s time window or, in standalone Pilot, by a Pilot shutdown.
- Slow moves are never stopped for taking long.
- Gone brokers. A move to a broker that left the cluster waits 10 minutes for it to return. After that, a queued move is marked Failed and never reaches Kafka. A move already in Kafka that makes no progress is cancelled back to its previous replicas and marked Failed.
- Cluster emergencies. While the controller is unhealthy or a similar hard-health problem lasts, Pilot submits no new moves. Moves already in Kafka continue.
- Expired license. No new moves start. Moves already in Kafka finish. The execution then waits until a valid license returns or someone cancels it. Cancelling needs no license.
- Stuck executions. An execution that makes no progress blocks other reassignments (
409) and self-healing repairs until you cancel it. - Leftover moves. A move that no execution drives any more and that still runs 12 hours after it was submitted is cancelled back to its original replicas and shown as timed out. The cancel is recorded in the audit log. Moves found at startup are not reverted.
In HA mode, only a cancel or a self-heal’s time window ends an execution early. Other stops, such as a failover, suspend the operation, and recovery resumes it. For more on HA mode, see High Availability.
How Operations End
Every operation that moves partitions ends by the same rule, however it was started:
| Operation | MCP tool | Audit action |
|---|---|---|
| Proposal apply | apply_proposal | reassignments.apply |
| Self-heal | - | selfheal.apply |
| Broker drain | set_broker_maintenance | broker.maintenance.set |
| Topic or partition redistribution | redistribute_topic, redistribute_partition | reassignments.apply |
| Bulk reassignment | bulk_reassign_partitions | reassignments.apply |
| Revert from the audit log | revert_audit_event | reassignments.apply.revert |
An ended operation shows one of these statuses:
| Status under Execution | When |
|---|---|
| Completed | Every move completed, or some completed and the rest failed on their own. The failed count is shown beside the status |
| Failed | Moves failed and none completed |
| Cancelled | A user cancelled it, a self-heal’s time window closed, or Pilot stopped it early |
A proposal apply or a self-heal marks its proposal applied, failed or cancelled. One exception: a self-heal stopped by its time window reads Cancelled here, but its proposal is marked failed. So is the proposal of an apply that standalone Pilot stops early without a cancel, for example at a shutdown. See Audit Logging for what is recorded.
GET /api/v1/reassignments and the MCP list_reassignments tool report the same status and count failed moves in failed_partitions. In HA mode an interrupted operation resumes after a failover; see High Availability.
Cancellation
Use Cancel remaining operation or the API to request cancellation. Kafka cancellation may remain unconfirmed, and completed assignments remain changed. Review the final replica placement and both active and historical outcomes after cancelling. Cancellation does not remove broker maintenance or exclusion settings. Pilot does not cancel moves found at startup. A cancel is recorded in the audit log as reassignments.cancel, in HA mode as <kind>.cancel_requested, for example drain.cancel_requested.
Cancelling needs no license: Cancel remaining operation, Cancel All, POST /api/v1/reassignments/{id}/cancel with an operation ID or all, and the MCP and chat tool cancel_reassignment work with a missing, expired or invalid license. Authentication and the write scope still apply. See Licensing.
Reassignments Found at Startup
This section describes standalone Pilot. In High Availability mode, Pilot resumes its own operations from its journal after a failover and lists no moves at startup; partitions another tool is moving are excluded from new plans instead.
When Pilot starts, it asks Kafka for partition moves already in progress and shows them as one operation, Found at Startup (observed: true in the API). They can be Pilot’s own moves from before the restart or another tool’s.
- Pilot does not cancel, revert or tune these moves.
POST /api/v1/reassignments/{id}/cancelreturns400for them, and the IDallskips them (skippedObservedCount). To cancel them, usekafka-reassign-partitions --cancel. - Until they end, Pilot starts no moves of its own. The proposal status reads Partition moves in progress, and applies, self-healing and rolling restarts wait. Drains, redistributions, bulk reassignments, audit-log reverts and forced applies return
409with reasonmoves_found_at_startup, also withforce=true. Previews still run. - A move cancelled outside Pilot is shown as Cancelled with
Ended outside Pilot. - Pilot does not continue the unsent part of an earlier plan. Apply the next proposal once the moves end.
- Pilot only sees moves on topics it may describe. If another tool might be moving other topics, check with
kafka-reassign-partitions --listbefore applying. - With
PILOT_THROTTLE_MANAGED=true, Pilot keeps existing throttles while these moves run. Afterwards it removes the throttles an earlier run of Pilot left and records them in the audit log asthrottles.reconcile.
While Pilot reads the moves at startup, the proposal status reads Checking partition moves. If the listing keeps failing, Pilot proceeds without it after 5 minutes at the latest and logs a warning.
Topic Redistribution Preview
The topic redistribution dialog reviews partition targets before applying them. API clients use POST /api/v1/topics/{topic}/redistribute with "preview": true for the same planning step. Topic and single-partition previews need no license; applying needs a valid license, and without one the dialog shows the preview with Apply Changes disabled.
A topic preview uses cached cluster metadata no older than 60 seconds. Missing, incomplete, or older metadata returns 503 Service Unavailable; retry after the next metadata refresh. Selected brokers that are unavailable or in maintenance are rejected. Applying with "preview": false rechecks availability and safety against current state, so a preview is not a guarantee that the change can still be submitted.
In High Availability mode, a live topic or single-partition redistribution needs an Idempotency-Key header and is accepted as one operation of kind redistribution before the response, which adds its operationId. Repeating the request with the same key and input answers 202 with the accepted operation. Another operation in progress refuses a live request with 409; a preview reads nothing from the operation journal and still runs.
Apply-Time Safety Gating
Every mutation endpoint that moves partitions runs a live cluster-health pre-flight before submitting to Kafka. This applies to applying a proposal, topic and single-partition redistribution, bulk reassignment, broker maintenance, and audit-log revert.
Hard-health blockers (not overridable)
The following return 409 Conflict and cannot be bypassed with force=true:
- Controller unhealthy
- A majority of brokers unavailable
- Sustained ISR shrink
The majority check leaves out brokers in maintenance, also when they are stopped after a drain.
Moves found at startup (not overridable)
While moves Pilot found at startup run, each of these endpoints returns 409 Conflict with reason moves_found_at_startup, also with force=true, and with reason checking_partition_moves while Pilot still checks for them. Previews still run.
Soft reasons (overridable, audited)
Reasons such as a stale proposal topology fingerprint or reassignments already in flight, other than moves found at startup, return 409 Conflict with guidance to re-submit with ?force=true. A forced override is recorded in the audit log.
A standalone apply names the cause in reason: reassignments_in_flight while Kafka moves a partition of a topic Pilot is moving, and reassignment_status_unavailable while Pilot cannot read Kafka’s partition moves; retry the latter shortly. force=true skips both checks. Another tool’s moves on other topics count only while they run from before Pilot started, as moves found at startup.
Rolling-restart exclusion
Reassignments are blocked while a rolling restart is in progress, and broker drains are blocked for the same reason. Partition moves and rolling restarts are mutually exclusive.
Operator-supplied replica sets
When you supply an explicit replica set (single-partition or bulk reassignment), Pilot validates it against the live cluster before submitting. A set is rejected when it is empty, contains duplicate or negative broker IDs, or would fall below the replication-factor floor for the partition (the larger of the original RF and min.insync.replicas + 1). The single-partition endpoint returns 400/409; the bulk endpoint reports the entry in its results (see Bulk Reassignment). The replication factor is preserved, never silently grown. Unhealthy brokers in a proposal-driven set are dropped and substituted back up to the original RF where possible; if a safe set cannot be formed, the partition is skipped rather than submitted with a shrunk assignment.
In High Availability mode, a set that adds a replica on a broker in maintenance is refused too, because HA never sends such a move: the single-partition endpoint returns 409 with code HA_MAINTENANCE_TARGET, also for a preview, and the bulk endpoint reports the entry in its results.
Bulk Reassignment
POST /api/v1/topics/{topic}/partitions/bulk moves several partitions of one topic as one operation. Each entry takes the same fields as the single-partition endpoint, plus the partition number:
{
"description": "Move orders partitions off broker 3",
"partitions": [
{ "partition": 0, "replicas": [1, 2, 4] },
{ "partition": 1, "replicas": [2, 4, 1] }
]
}Pilot validates and plans each entry on its own, then executes all planned live moves as one monitored operation with strategy BULK_MANUAL, through the same throttled path as topic and single-partition redistribution. The response returns once execution has started. Follow the operation under Execution or with GET /api/v1/reassignments/{id}, and cancel it with POST /api/v1/reassignments/{id}/cancel.
| Response field | Meaning |
|---|---|
results | One result per request entry, in request order: partition, success, preview, the planned changes, and error when the entry was rejected |
started | Whether an operation started. Present when the request has a live entry |
bulkId | Operation ID for the reassignment endpoints. Present when started is true |
message | Outcome summary. Present when the request has a live entry |
The top-level success is always true on 200; check started and each result.
- Rejected entries. An entry is reported with
success: falseand anerror, and is never executed, when its replica set is empty, has duplicate or negative broker IDs, or would fall below the replication-factor floor, when its partition is listed more than once (every entry for that partition), or when it cannot be planned, for example because its current placement cannot be read. The remaining live entries still run. If every live entry is rejected, nothing starts andstartedisfalse. - Live requests. A request with at least one live entry runs the hard-health pre-flight and holds the reassignment slot until the operation ends, so another mutating reassignment gets
409meanwhile. It is audited asreassignments.apply, including the entries that were not executed. - Previews. A request whose entries are all previews plans from cached metadata and starts nothing. It takes no reassignment slot, writes no audit record and sends nothing to Kafka. It still requires a license.
- High Availability. In HA mode, a request with a live entry needs an
Idempotency-Keyheader, and repeating it with the same key and input answers202with the accepted operation. The planned live moves are accepted as one operation of kindbulk; the response addsoperationId, which is also thebulkId, or answers202withstatus: "pending"while a large accept is written. An entry that adds a replica on a broker in maintenance is rejected inresults. Thereassignments.applyevent names at most 20 of the entries that were not executed and counts the rest;resultslists every one. - An empty
partitionslist returns400.
Stale Placement Protection
Every move records the replicas it starts from. Before sending a move to Kafka, Pilot checks the partition’s current replicas against the plan. If they no longer match it, the partition is marked Failed with stale plan: live replicas [...] no longer match the planned source [...] and is not sent to Kafka. Plan it again from the current placement.
A live single-partition or bulk redistribution plans from the partition’s current replicas. If they cannot be read, the single-partition endpoint returns 503 Service Unavailable and changes nothing, and a bulk entry is rejected. Previews use cached metadata, so a preview’s oldReplicas can be out of date.
Preferred Leader Election
A preferred leader election hands each partition’s leadership back to its preferred replica, the first in its replica list. POST /api/v1/preferred-leader-election checks every partition of the topics whose names do not start with __, or the topics and partitions the body names; POST /api/v1/topics/{topic}/preferred-leader-election checks one topic, or the partitions of it the body names. Pilot asks Kafka to elect the partitions another replica leads, and Kafka decides each one. The response lists every partition checked with oldLeader, newLeader, success and error, so a 200 can carry partitions whose election failed. A named topic or partition that Kafka does not know returns 404 and elects nothing, and a rolling restart in progress returns 409. An election checks no cluster health and sets no throttle.
In High Availability mode, an election needs an Idempotency-Key header and runs as one operation of kind election, listed under Execution with strategy PREFERRED_LEADER_ELECTION, which a successor finishes after a failover. It runs beside a running rebalance or other data movement, as in standalone mode. Partitions Kafka lists as being reassigned are not elected and fail with Partition is being reassigned; partitions the running movement has yet to finish moving fail with Partition is being reassigned by operation and the movement’s ID. See Supported actions for how HA answers an election.
API Endpoints
| Method | Path | Description | License |
|---|---|---|---|
POST | /api/v1/topics/{topic}/redistribute | Redistribute all partitions of a topic | Apply only |
POST | /api/v1/topics/{topic}/partitions/{partition}/redistribute | Reassign a single partition | Apply only |
POST | /api/v1/topics/{topic}/partitions/bulk | Reassign several partitions of a topic as one operation | Yes |
POST | /api/v1/preferred-leader-election | Cluster-wide preferred leader election | Yes |
POST | /api/v1/topics/{topic}/preferred-leader-election | Topic-specific preferred leader election | Yes |
POST | /api/v1/reassignments/{id}/cancel | Cancel an operation, or every active one Pilot started with the ID all | No |
Apply only: a preview ("preview": true) needs no license. See the API reference for request and response schemas, including the force parameter and 409 error bodies.
Prometheus Metrics
Key reassignment metrics:
| Metric | Description |
|---|---|
pilot_reassignment_active | Currently active moves |
pilot_reassignment_pending | Queued moves |
pilot_reassignment_last_progress_timestamp_seconds | When an execution last started, submitted a move or saw a move end |
pilot_reassignment_completed_total | Cumulative completions |
pilot_reassignment_duration_seconds | Time per partition move |
pilot_reassignment_broker_active_moves | Active moves per broker |
See Prometheus Metrics for the full reference.