diff --git a/src/go/rpk/pkg/cli/cmd/topic/create.go b/src/go/rpk/pkg/cli/cmd/topic/create.go index 218e9dc261a8..6f4ba6d74301 100644 --- a/src/go/rpk/pkg/cli/cmd/topic/create.go +++ b/src/go/rpk/pkg/cli/cmd/topic/create.go @@ -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() } @@ -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