Skip to content

Commit faa60bd

Browse files
cawright-rhCameron Wright
andauthored
[KafkaMigration] Updating common.go to properly check if usedForKafkaAdmin is set (#103)
* Updating common.go to properly check if usedForKafkaAdmin is set * removing innefectual assignment * updating generated boilerplate information --------- Co-authored-by: Cameron Wright <[email protected]>
1 parent 607fa5f commit faa60bd

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/boilerplate/header.generated.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2024 Cisco Systems, Inc. and/or its affiliates
1+
Copyright 2025 Cisco Systems, Inc. and/or its affiliates
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

hack/boilerplate/header.go.generated.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2024 Cisco Systems, Inc. and/or its affiliates
2+
Copyright 2025 Cisco Systems, Inc. and/or its affiliates
33

44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

pkg/util/kafka/common.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,12 @@ func GetBootstrapServersService(cluster *v1beta1.KafkaCluster) (string, error) {
191191

192192
// GetBrokerContainerPort return broker container port
193193
func GetBrokerContainerPort(cluster *v1beta1.KafkaCluster) (int32, error) {
194+
usedForKafkaAdminSet := false
194195
containerPort := int32(0)
195196
for _, lc := range cluster.Spec.ListenersConfig.InternalListeners {
196197
if lc.UsedForKafkaAdminCommunication { // Optional override to return a port from a different listener. Needed if b2b communication is on an external listener and and you want the koperator to interact with kafka over a different port.
197198
containerPort = lc.ContainerPort
199+
usedForKafkaAdminSet = true
198200
break
199201
}
200202
if lc.UsedForInnerBrokerCommunication && !lc.UsedForControllerCommunication {
@@ -203,14 +205,16 @@ func GetBrokerContainerPort(cluster *v1beta1.KafkaCluster) (int32, error) {
203205
}
204206
}
205207

206-
for _, lc := range cluster.Spec.ListenersConfig.ExternalListeners {
207-
if lc.UsedForKafkaAdminCommunication {
208-
containerPort = lc.ContainerPort
209-
break
210-
}
211-
if lc.UsedForInnerBrokerCommunication {
212-
containerPort = lc.ContainerPort
213-
break
208+
if !usedForKafkaAdminSet {
209+
for _, lc := range cluster.Spec.ListenersConfig.ExternalListeners {
210+
if lc.UsedForKafkaAdminCommunication {
211+
containerPort = lc.ContainerPort
212+
break
213+
}
214+
if lc.UsedForInnerBrokerCommunication {
215+
containerPort = lc.ContainerPort
216+
break
217+
}
214218
}
215219
}
216220

0 commit comments

Comments
 (0)