Expand description
Captures the inputs a point-in-time restore needs, and puts committed consumer-group offsets back after one.
krabka restore rebuilds a log directory out of a KIP-405 archive, and it
needs three things the archive does not hold. Two are files on a broker’s
own disk: <log.dir>/remote-log-metadata/snapshot, without which a segment
the old cluster had already released is indistinguishable from a live one,
and the controller’s newest <end-offset>-<epoch>.checkpoint, which is
where topic configuration, ACLs, client quotas, SCRAM credentials and
finalized feature levels live. The third is not a file at all: the committed
offsets of every consumer group, which sit in the compacted, never-tiered
__consumer_offsets topic.
All three are destroyed by the disaster that makes an operator reach for a restore, so a copy has to exist before it. This tool makes that copy and checks it.
§Why a tool and not a kubectl exec
The krabka container image is built from an apko base and has no shell, no
cp and no tar, so kubectl exec and kubectl cp cannot take a file off
a running broker. The supported copy is this binary, run beside the broker
with the same volume mounted read-only — a CronJob in the same namespace —
or on the node itself. Both snapshot files are written temp-then-rename, so
a reader that opens one by name always sees a whole file.
Group offsets need a cluster rather than a volume, so the same run takes
them over the ordinary Kafka wire protocol, with ListGroups and
OffsetFetch. Nothing here speaks a krabka-private API key, which is what
lets the same capture run against a cluster that is not krabka.
§The four subcommands
capture copies the inputs into the archive under
restore-inputs/<capture-id>/, beside the tiered segments the restore reads,
with a manifest.json recording each artifact’s size and SHA-256. list
names the captures. verify re-reads one and checks it against those
digests, which is the check a backup is worth nothing without. restore- offsets commits a capture’s offsets into a restored cluster, so a group
resumes where it stopped instead of at auto.offset.reset.
§Exit codes
0 success, EXIT_BAD_ARGUMENT, EXIT_UNREADABLE, EXIT_INTEGRITY
and EXIT_CLUSTER. They line up with krabka restore’s own where the two
tools mean the same thing, because one runbook branches on both.
The crate is a library as well as a binary, for the same reason
krabka-guard, krabka-barrier and krabka-format are: a test that spawns
the binary needs a Cargo working tree to build it from, and a Bazel test
sandbox has none. Tests call run_from_args in process instead.
The operations in run return an OperationReport with an outcome and ordered diagnostics, including progress before an error. They do not print. run() renders those diagnostics for the CLI.
Re-exports§
pub use self::cli::Cli;pub use self::cli::Command;pub use self::error::BackupError;pub use self::error::EXIT_BAD_ARGUMENT;pub use self::error::EXIT_CLUSTER;pub use self::error::EXIT_INTEGRITY;pub use self::error::EXIT_UNREADABLE;pub use self::report::BackupEvent;pub use self::report::OperationReport;
Modules§
- archive
- The archive the capture is written to: the
--archive-*flags turned into an object store, plus the operations this tool needs from it. - capture
- Finding the two restore inputs that live on a node’s disk, and naming the capture they are written into.
- cli
- The
krabka-backupcommand line. - connection
- Kafka-compatible
--command-configsecurity for cluster connections. - diskless
- Committed diskless-WAL index capture.
- error
- The one error type the tool reports, and the exit codes it maps onto.
- manifest
- What a capture writes beside its artifacts, and the check that reads it back.
- offsets
- Committed consumer-group offsets: the one restore input that is not a file on a node.
- report
- Structured operation results and the command boundary’s terminal reporting.
- run
- What each subcommand does, and the one place that talks to a cluster.
Functions§
- run
- Run one parsed command line, mapping its error onto an exit code.
- run_
from_ args - Run the tool from an argv-style iterator, returning its exit code.