Skip to content

Feat/dedicated broker metadata storage refresh - #349

Draft
eduardagarici wants to merge 2 commits into
mainfrom
feat/dedicated-broker-metadata-storage-refresh
Draft

eduardagarici wants to merge 2 commits into
mainfrom
feat/dedicated-broker-metadata-storage-refresh

Conversation

@eduardagarici

Copy link
Copy Markdown

Description

Adds opt-in dedicated KRaft metadata storage for broker-only nodes (brokerConfig.metadataStorage). The operator also live-migrates existing brokers to it automatically, one broker at a time. Enabling the field in the broker-only brokerConfigGroup is the only required step.

Today a broker's __cluster_metadata log is stored on a data disk (log.dirs). That ties metadata durability and I/O to topic-data disks, and makes data-disk changes risky. With this change, each opted-in broker gets a separate <cluster>-<id>-metadata PVC and metadata.log.dir=<mountPath>/kafka. The data disks, Cruise Control capacity and topic assignments are not changed.

What's included

API and admission

  • New field metadataStorage, which reuses the StorageConfig shape. It needs a PVC (pvcSpec) and rejects emptyDir and block-mode volumes.
  • It is valid only for KRaft nodes with processRoles: [broker].
  • Admission rejects:
    • removing the field, moving its mount path, replacing its PVC spec, or shrinking it;
    • mount paths that overlap other mounts;
    • emptyDir data storage on brokers that use it, because that data would be lost when the pod is replaced and could not be migrated;
    • removing a data disk before the broker's metadata migration is Ready.
  • New per-broker status field: status.brokersState[id].metadataStorageState.

Migration (migrate-broker-metadata init container)

  • Copies the stopped broker's metadata onto the new PVC before Kafka starts.
  • Its steps are durable and resumable: validate, format, copy, publish, verify, retire the source copy, record completion.
  • Accepts version 1 meta.properties. Also accepts version 0 (broker.id) with no bootstrap.checkpoint, as found on brokers already migrated from ZooKeeper to KRaft. The new copy is always written as version 1.
  • Logs each step.

Automatic, serialized rollout

  • A migration gate in handleRollingUpgrade allows at most one migration per cluster at a time, whatever concurrentBrokerRestartCountPerRack is set to. The next broker waits until the previous one is Ready and no other broker has offline or out-of-sync replicas.
  • The gate also applies when a crashed pod is being replaced, a path that skips the normal rolling-upgrade checks.
  • metadata.log.dir is not added to the live-mounted broker ConfigMap until no broker pod without the metadata volume remains. The operator also refuses to create a metadata-storage pod whose ConfigMap lacks the setting.

Lifecycle

  • The metadata PVC is deleted together with the data PVCs when a broker is removed. NotFound errors are tolerated.
  • Readiness is recorded durably as an annotation on the metadata PVC.

Docs

  • docs/broker-metadata-storage.md: preconditions, the automatic rollout, monitoring commands, failure handling, the fencing limitation and broker removal.
  • An optional example in config/samples/kraft/simplekafkacluster_kraft.yaml.
  • A link from the README.

Requirements and limitations

  • Kafka 3.9+. Brokers must be KRaft broker-only, including brokers already migrated from ZooKeeper; controllers and combined nodes are not supported.
  • Reverse migration is not supported. Removing the field is rejected.
  • A failed migration leaves that pod in its init container and stops the rollout until it is resolved. No source metadata is deleted.
  • Known follow-up: metadata PVC cleanup on broker removal is attempted only once. If a broker ID is re-added without metadataStorage, a leftover PVC can block reconciliation.

Type of Change

  • New Feature
  • Documentation

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

Checklist notes:

• I left the contributing-guidelines box for you to tick, since only you can confirm you've read them.
•  make test  passed.
• Lint ( golangci-lint  v2.14.0) reported 0 issues in the root module after the final change; the  api/  module last passed before the final change, which left  api/  untouched.
•  make license-header-check  last passed before the final round of changes and wasn't re-run.

Eduard Agarici and others added 2 commits October 1, 2026 16:41
Add opt-in dedicated metadata PVCs for broker-only KRaft nodes, with fail-closed offline migration from existing data disks, retained backups, and source-disk protection until recovery. Keep controller storage unchanged. Include generated schemas, migration guidance, unit coverage, and a Kafka 3.9.2 smoke test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make enabling brokerConfig.metadataStorage the only required step: the
operator now migrates broker-only nodes one at a time and guards the
migration lifecycle end to end.

Migration orchestration:
- Add a one-per-cluster migration gate to handleRollingUpgrade. A
  metadata migration restart waits until no other opted-in broker is
  mid-migration and no other broker has offline/out-of-sync replicas,
  independent of concurrentBrokerRestartCountPerRack and also on the
  crashed-container path.
- Project per-broker metadataStorageState (Ready) into status from a
  durable PVC annotation.
- Defer metadata.log.dir in the live-mounted broker ConfigMap until no
  broker pod without the metadata volume remains, and refuse to create
  a metadata-storage pod whose ConfigMap lacks it.

Migration script:
- Accept version 0 meta.properties (broker.id) and a missing
  bootstrap.checkpoint from finalized ZooKeeper-to-KRaft brokers, while
  writing version 1 at the destination.
- Log each migration phase.

Lifecycle and admission:
- Delete the metadata PVC together with data PVCs on broker removal,
  tolerating NotFound.
- Reject data-disk removal until the broker's metadata storage is Ready.
- Reject metadataStorage when any data storage is emptyDir/non-PVC.
- Share kraft-metadata, metadata.log.dir and migration.broker.kRaftMode
  constants instead of string literals.

Docs: replace the manual one-broker-at-a-time procedure with the
automatic rollout and monitoring guidance; require Kafka 3.9+.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant