Skip to content

Commit 5bbdb2d

Browse files
committed
Minor fixes
1 parent 2588092 commit 5bbdb2d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ topics:
198198
partitions: 2
199199
```
200200
201-
This spec can by then applied:
201+
This spec can be then applied:
202202
203203
```
204204
Plant=myplant Env=myenv ./kafka-ops --apply --spec kafka-cluster-example3.yaml --template --var Env=realenv --var One=more

kafka-ops.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ func applySpecFile(admin *sarama.ClusterAdmin) error {
364364
fmt.Printf("TASK [TOPIC : Delete topic %s] %s\n", topic.Name, strings.Repeat("*", 52))
365365
} else {
366366
topic.State = "present"
367-
fmt.Printf("TASK [TOPIC : Create topic %s (partitions=%d, replicas=%d)] %s\n", topic.Name, topic.Partitions, topic.ReplicationFactor, strings.Repeat("*", 25))
368367
}
369368
currentTopic, found := currentTopics[topic.Name]
370369

@@ -377,6 +376,7 @@ func applySpecFile(admin *sarama.ClusterAdmin) error {
377376
if topic.ReplicationFactor < 1 {
378377
topic.ReplicationFactor = autoReplicationFactor
379378
}
379+
fmt.Printf("TASK [TOPIC : Create topic %s (partitions=%d, replicas=%d)] %s\n", topic.Name, topic.Partitions, topic.ReplicationFactor, strings.Repeat("*", 25))
380380
err := createTopic(topic, admin)
381381
if err != nil {
382382
printResult(Error, broker, err.Error(), topic)
@@ -401,10 +401,15 @@ func applySpecFile(admin *sarama.ClusterAdmin) error {
401401
var topicAltered bool = false
402402
var topicConfigAlterNeeded = false
403403
// Check the replication-factor
404-
if topic.ReplicationFactor > 0 && int16(topic.ReplicationFactor) != currentTopic.ReplicationFactor {
405-
printResult(Error, broker, "Cannot change replication-factor. Consider doing it manually with kafka-reassign-partitions utility or re-creating the topic", topic)
406-
numError++
407-
if errorStop { break } else { continue }
404+
if topic.ReplicationFactor > 0 {
405+
fmt.Printf("TASK [TOPIC : Modify topic %s (partitions=%d, replicas=%d)] %s\n", topic.Name, topic.Partitions, topic.ReplicationFactor, strings.Repeat("*", 25))
406+
if int16(topic.ReplicationFactor) != currentTopic.ReplicationFactor {
407+
printResult(Error, broker, "Cannot change replication-factor. Consider doing it manually with kafka-reassign-partitions utility or re-creating the topic", topic)
408+
numError++
409+
if errorStop { break } else { continue }
410+
}
411+
} else {
412+
fmt.Printf("TASK [TOPIC : Modify topic %s (partitions=%d)] %s\n", topic.Name, topic.Partitions, strings.Repeat("*", 37))
408413
}
409414
// Check the partitions count
410415
if int32(topic.Partitions) != currentTopic.NumPartitions {

0 commit comments

Comments
 (0)