[CORE-16880] kafka: autocreate internal topics with correct properties#31234
Merged
WillemKauf merged 5 commits intoJul 22, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Kafka metadata-driven auto-creation so that internal topics (e.g. _schemas, __consumer_offsets, _redpanda.audit_log) are created with subsystem-specific configurations rather than cluster-default topic properties, preventing silent misconfiguration when auto_create_topics_enabled=true.
Changes:
- Special-case internal topics in the Kafka metadata auto-create path to use the correct topic configurations (and delegate
__consumer_offsetscreation togroup_initializer). - Factor out canonical internal topic configurations/properties into reusable helpers (
schema_registry_topic_configuration,audit_log_topic_properties,cluster::internal_topic_replication). - Add coverage via both ducktape and C++ fixture tests to validate internal-topic auto-creation behavior.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/rptest/tests/internal_topic_protection_test.py | Adds ducktape coverage asserting internal topics auto-created via Metadata get correct partitions/RF/configs. |
| src/v/security/audit/client.cc | Uses shared audit_log_topic_properties() accessor when creating the audit topic. |
| src/v/security/audit/BUILD | Adds new audit topic helper sources/headers to the audit library target. |
| src/v/security/audit/audit_log_topic.h | Introduces public accessor for intended audit log topic properties. |
| src/v/security/audit/audit_log_topic.cc | Implements audit log topic properties (delete policy + 7-day retention). |
| src/v/pandaproxy/schema_registry/service.cc | Uses kafka::schema_registry_topic_configuration() helper instead of locally building properties. |
| src/v/pandaproxy/schema_registry/kafka_client_transport.cc | Prevents metadata probe from auto-creating _schemas by setting allow_auto_topic_creation=false. |
| src/v/kafka/server/tests/metadata_test.cc | Adds fixture test ensuring internal topics auto-created by metadata have correct configs. |
| src/v/kafka/server/handlers/topics/types.h | Exposes schema_registry_topic_configuration() helper in the kafka topics types API. |
| src/v/kafka/server/handlers/topics/types.cc | Implements schema registry internal topic configuration helper. |
| src/v/kafka/server/handlers/metadata.cc | Special-cases internal topics during metadata-driven auto-create to avoid cluster defaults. |
| src/v/kafka/server/group_initializer.cc | Centralizes internal-topic RF selection via cluster::internal_topic_replication(). |
| src/v/cluster/members_table.h | Declares cluster::internal_topic_replication() helper. |
| src/v/cluster/members_table.cc | Implements RF helper based on internal_topic_replication_factor vs node count. |
| src/v/cluster/controller.cc | Reuses cluster::internal_topic_replication() in controller::internal_topic_replication(). |
| src/v/cluster/BUILD | Adds config dependency to the members_table target for the new helper implementation. |
WillemKauf
force-pushed
the
metadata-autocreate-internal-topics
branch
from
July 22, 2026 18:21
3785fd8 to
1a09986
Compare
kafka: autocreate internal topics with correct propertieskafka: autocreate internal topics with correct properties
WillemKauf
force-pushed
the
metadata-autocreate-internal-topics
branch
from
July 22, 2026 18:48
1a09986 to
d889f7c
Compare
andrwng
reviewed
Jul 22, 2026
andrwng
reviewed
Jul 22, 2026
WillemKauf
force-pushed
the
metadata-autocreate-internal-topics
branch
from
July 22, 2026 19:53
d889f7c to
7a60605
Compare
For later use in the `kafka/server/handlers/metadata` layer when autocreating this topic.
For later use in the `kafka/server/handlers/metadata` layer when autocreating this topic.
For later use in the `kafka/server/handlers/metadata` layer when autocreating this topic. Also extract `controller::internal_topic_replication()` into a free function in `cluster/members_table.h`, so that callers without access to the controller can compute the replication factor for internal topics.
The auto create topics path would always create topics with default cluster configurations. This is very incorrect for certain special topics such as `_schemas`, `__consumer_offsets`, or our internal `_redpanda.audit_log` topic. Use the newly available config accessors for these specific topics, and use them when autocreating these topics to ensure we are constructing these topics with the correct properties.
End to end tests that perform a metadata request on some specific internal topics, and assert that the topics were created with the intended topic properties.
WillemKauf
force-pushed
the
metadata-autocreate-internal-topics
branch
from
July 22, 2026 20:00
7a60605 to
f6ac88a
Compare
andrwng
approved these changes
Jul 22, 2026
bharathv
approved these changes
Jul 22, 2026
WillemKauf
requested review from
a team and
pgellert
and removed request for
a team
July 22, 2026 21:25
Collaborator
CI test resultstest results on build#87585
|
Contributor
Author
|
/backport v26.2.x |
Collaborator
|
/backport v26.1.x |
Collaborator
|
/backport v25.3.x |
Collaborator
|
/backport v25.2.x |
Collaborator
|
Failed to create a backport PR to v25.2.x branch. I tried: |
This was referenced Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The auto create topics path would always create topics with default cluster configurations. This is very incorrect for certain special topics such as
_schemas,__consumer_offsets, or our internal_redpanda.audit_logtopic.Pull these topic's special configs into publicly available accessors, and use these when autocreating these topics to ensure we are constructing these topics with the correct properties.
Fixes #31213
Backports Required
Release Notes
Bug Fixes