Skip to content

Commit

Permalink
Merge pull request #4786 from r-vasquez/odd-replica-factor-text
Browse files Browse the repository at this point in the history
rpk: improve wording in topic create: replication factor must be odd
  • Loading branch information
twmb committed May 18, 2022
2 parents 0bdec59 + 2eeed76 commit 08958cd
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit 08958cd

Please sign in to comment.