Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpk: improve wording in topic create: replication factor must be odd #4786

Merged
merged 1 commit into from
May 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/go/rpk/pkg/cli/cmd/topic/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ the cleanup.policy=compact config option set.
if err := kerr.ErrorForCode(topic.ErrorCode); err != nil {
if errors.Is(err, kerr.InvalidPartitions) && partitions > 0 {
msg = fmt.Sprintf("INVALID_PARTITIONS: unable to create topic with %d partitions due to hardware constraints", partitions)
} else if errors.Is(err, kerr.InvalidReplicationFactor) && replicas%2 == 0 {
msg = "INVALID_REPLICATION_FACTOR: replication factor must be odd"
} else {
msg = err.Error()
}
Expand All @@ -114,7 +116,7 @@ the cleanup.policy=compact config option set.
}
cmd.Flags().StringArrayVarP(&configKVs, "topic-config", "c", nil, "key=value; Config parameters (repeatable; e.g. -c cleanup.policy=compact)")
cmd.Flags().Int32VarP(&partitions, "partitions", "p", 1, "Number of partitions to create per topic")
cmd.Flags().Int16VarP(&replicas, "replicas", "r", -1, "Replication factor; if -1, this will be the broker's default.replication.factor")
cmd.Flags().Int16VarP(&replicas, "replicas", "r", -1, "Replication factor (must be odd); if -1, this will be the broker's default.replication.factor")
cmd.Flags().BoolVarP(&dry, "dry", "d", false, "dry run: validate the topic creation request; do not create topics")

// Sept 2021
Expand Down