fix(topics): clamp default replication factor to broker count#2420
Open
fix(topics): clamp default replication factor to broker count#2420
Conversation
CreateTopic defaulted replicationFactor to 3 in both the topic-create modal and the MCP inspector's "create new topic" flow. On single-broker clusters (local-byoc dev environments, etc.) that rejected the request with "not enough replicas". Clamp the default to min(3, brokersOnline) and fall back to 3 while KafkaInfo is loading.
Contributor
Author
|
Not needed, closing for now |
The RPCN onboarding Add Topic step spread TOPIC_FORM_DEFAULTS (replicationFactor: 3) into the form and renders the RF field as readOnly in AdvancedTopicSettings. On single-broker clusters (local-byoc dev environments) that meant the user saw RF=3 with no way to edit, and CreateTopic failed with "not enough replicas". Override replicationFactor at form init with min(default, brokersOnline) via useGetKafkaInfoQuery so the readOnly value matches what the broker can actually satisfy.
Scope back to the user-visible topic-create paths only. The MCP inspector's "create new topic" flow is out of scope for this PR.
useForm captures defaultValues at mount; when the KafkaInfo query
resolves after mount the RF field stays at its initial 3. Pass
defaultValues through both `defaultValues` and `values` with
`resetOptions: { keepDirtyValues: true }` so the form reactively
picks up the clamped replicationFactor once brokersOnline is known,
without clobbering fields the user has already edited.
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.
Summary
Three topic-create surfaces in Console hardcoded `replicationFactor: 3`. On single-broker clusters (local-byoc dev environments, degraded prod edges) that caused CreateTopic to fail with "not enough replicas". The RPCN onboarding form was the most visible case because the RF input is rendered `readOnly` — users could see the `3` but had no way to change it.
Files changed:
All three use `useGetKafkaInfoQuery` to read `brokersOnline` and fall back to the original `3` while the query is loading. On 3+ broker clusters the behavior is unchanged.
Note: the legacy `pages/topics/CreateTopicModal/create-topic-modal.tsx` already reads the default from the broker's `default.replication.factor` config, so it's already correct provided the broker config is correct.
Test plan