Skip to main content

kraft-last-standing

CI Build Status
PyPI Package Python versions

Recover an Apache Kafka® cluster that has permanently lost its KRaft controller quorum.

Checkout the complete documentation →

When a dynamic KRaft quorum loses a majority of its voters, the lost voters can only be removed with quorum, and quorum can only be restored by removing the lost voters. kraft-last-standing breaks that loop by appending VotersRecord control records to the metadata log of a stopped, surviving controller, shrinking the voter set down to only that controller. Started again, it elects itself leader, and the cluster can make progress.

The blog post Never lose quorum in Apache Kafka® explains the approach and its consequences.

Installation

$ pip install --require-virtualenv kraft-last-standing

Usage

Find the most progressed copy of the metadata log, by probing every surviving broker and controller.

$ kraft-last-standing probe /var/lib/kafka/data/__cluster_metadata-0

Then, with every controller stopped, recover the chosen one.

$ kraft-last-standing recover \
    --metadata-dir /var/lib/kafka/data/__cluster_metadata-0 \
    --backup-dir /var/backups/kafka

Development

Install development requirements.

$ pip install --require-virtualenv -e '.[type-check,docs]'

Run unit tests, type check, and build the documentation.

$ make test
$ mypy
$ make docs

The integration tests run Apache Kafka® controllers in containers, using the apache/kafka image, and require Docker. The KAFKA_VERSION environment variable selects the version of the image, and defaults to 4.3.1.

$ make test-integration

To run the tests in parallel, pass the number of workers to pytest-xdist. Each test runs four containers that use around 600 MB of memory in total, so pick a number that fits in the memory available to Docker.

$ make test-integration test="-n 2"

The tests bind mount their temporary directories into the containers. When Docker runs in a virtual machine that only shares the home directory, which is the default for Colima, point pytest's temporary directory there.

$ mkdir -p ~/.cache/kraft-last-standing
$ make test-integration test=--basetemp=$HOME/.cache/kraft-last-standing/pytest

Lint and format with goose.

$ goose run --select=all

Metadata

Release files for kraft-last-standing 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kraft-last-standing 1.0.0
File Size Uploaded Provenance Actions
kraft_last_standing-1.0.0.tar.gz 27.0 kB With provenance Details for kraft_last_standing-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kraft-last-standing 1.0.0
File Interpreter ABI Platform Actions
kraft_last_standing-1.0.0-py3-none-any.whl Python 3 none any Details for kraft_last_standing-1.0.0-py3-none-any.whl

Total release size: 56.1 kB

Release files / kraft_last_standing-1.0.0.tar.gz

Download URL kraft_last_standing-1.0.0.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d4c67d36eab8bb36bfecb9165b931b834269b3afd4f70c16f66c03819d258586
BLAKE2b-256 checksum
How to use checksums
50c89f527d3af2f65b0582ee055ebcb1fa79dbf2138aad722141388839eb781b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / kraft_last_standing-1.0.0-py3-none-any.whl

Download URL kraft_last_standing-1.0.0-py3-none-any.whl
Size 29.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
053aeaf01f73612c8cd4656e2ff7c7a1678869cdaf198b4c6ddce267bd242ddc
BLAKE2b-256 checksum
How to use checksums
dd72f3b180f9784f9e9bacfea43aef07429cc5c7603e7bcea2cea420802f231f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for kraft-last-standing 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for kraft_last_standing-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page