Skip to main content

Crate krabka_format

Crate krabka_format 

Source
Expand description

Formats the log directories of a krabka broker node.

A KRaft node will not boot against an unformatted directory: the broker treats one as operator error and aborts startup. Formatting seeds Kafka’s meta.properties, the bootstrap records, and the singleton VotersRecord, and can provision seed SCRAM credentials at the same time. One run formats every directory of the node, as kafka-storage format does, and writes the cluster and directory ids in Kafka’s 22-character base64 form. docs/format-divergences.md in the repository lists where the command differs from kafka-storage format, and why.

MetaProperties reads and writes meta.properties byte for byte as Kafka does. The broker reads the file through it, and so can any tool that has to find the identity of a formatted directory.

run_with_records takes further MetadataRecords from the caller and seeds them into the same stream. A restore tool that rebuilds a cluster from tiered-storage archives hands over the topic and partition records it recovered that way, and the broker then boots with those topics present.

This is the krabka format command from the monorepo’s krabka-cli. That crate also drives the gres layer, which is why it could not follow the broker into this repository; the command itself needs only krabka_metadata and [krabka_security]. It is a library as well as a binary so krabka-cli can call it rather than carry a second copy.

Structs§

Cli
The formatter’s command line.
ClusterId
A Kafka cluster id: the identity that every node of a cluster shares.
DirectoryId
A log directory’s stable id (KIP-858). The metadata directory’s id is also the node’s KIP-853 voter identity.
FormatArgs
MetaProperties
The content of a version 1 meta.properties.
ScramSpec

Enums§

KafkaUuidError
A string that is not a Kafka Uuid.
MetaPropertiesError
Why a meta.properties does not read.
MetadataRecord
The seed record type run_with_records accepts, re-exported so a caller building a bootstrap stream does not have to name krabka_metadata itself.

Constants§

FAIL_AFTER_ENV
The environment variable that makes a run fail after it writes the file of the given name. It is a test seam: it is how the tests interrupt a run partway through, to show that the next run recovers.
LATEST_PRODUCTION_METADATA_VERSION
The metadata.version a cluster formats at when neither --release-version nor --feature metadata.version names one: Kafka 4.3’s MetadataVersion.LATEST_PRODUCTION, 4.3-IV0.
META_PROPERTIES
The file name, Kafka’s MetaPropertiesEnsemble.META_PROPERTIES_NAME.
META_PROPERTIES_TMP
The name of the file while it is written, before the rename that publishes it. PropertiesUtils.writePropertiesFile adds .tmp.
META_PROPERTIES_VERSION
The version of the file that a KRaft node writes, MetaPropertiesVersion.V1.

Functions§

parse_node_id
Parses a node id as Kafka’s node.id: an int that is not negative.
random_uuid
Returns a random id, as Kafka’s Uuid.randomUuid does: never the zero id or the id with value one, and never one whose string form starts with -, which a command-line parser would read as an option.
run
Formats the metadata log directory and args.log_dirs, returning the process exit code.
run_from_args
Run the formatter from an argv-style iterator, returning its exit code.
run_from_args_with_records
Run the formatter from an argv-style iterator, seeding extra alongside the records the flags produce, and return its exit code.
run_from_args_with_records_to
run_from_args_with_records, with the progress lines of a successful format written to progress instead of stdout; run_with_records_to says why a caller wants that.
run_with_records
Formats the metadata log directory and args.log_dirs with extra seeded alongside the records the flags produce, returning the process exit code.
run_with_records_to
run_with_records, with Kafka’s progress lines written to progress instead of stdout.
verify_ensemble
Kafka’s MetaPropertiesEnsemble.verify, over the readable files of the directories of one node, sorted by path.