fix(msk): report the broker's advertised hostname from GetBootstrapBrokers (#8404)

With Floci in a container and no bootstrap hostname configured,
GetBootstrapBrokers returned the broker container's IP, a bare address
where AWS returns broker hostnames. The broker's internal listener
already advertises <container-name>:9092, so a client that bootstrapped
from the IP was handed that name by the first Metadata response anyway.
GetBootstrapBrokers now returns <container-name>:9092.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-14 23:04:43 -04:00
1 parent 246d82ec57
commit 7a682dcd00
3 files changed
+17 -14

No files matched your search

@@ -179,16 +179,18 @@ public class RedpandaManager {
if (inContainer) {
hostListenerPorts.put(clusterIdentityKey(cluster), kafkaHostPort);
// GetBootstrapBrokers reports the Docker-network address unless the host listener
// was asked for explicitly, which keeps sibling containers working by default. When
// it was, both listeners are listed: a client connects through whichever entry it can
// reach, and the broker then advertises that listener's address. The container name
// (not its IP) fails fast on the host, where it does not resolve, while an unroutable
// IP would wait for a connect timeout. It goes first for callers that read only the
// first entry.
// GetBootstrapBrokers reports the internal listener by the name the broker advertises
// for it, a hostname as on AWS: a client that bootstrapped from the container IP would
// be handed that name by the first Metadata response anyway. When the host listener
// was asked for explicitly, both listeners are listed: a client connects through
// whichever entry it can reach, and the broker then advertises that listener's
// address. The container name fails fast on the host, where it does not resolve,
// while an unroutable IP would wait for a connect timeout. It goes first for callers
// that read only the first entry.
String internalListenerAddr = containerName + ":" + KAFKA_PORT;
cluster.setBootstrapBrokers(explicitBootstrapHostname().isPresent()
? containerName + ":" + KAFKA_PORT + "," + hostListenerAddr
: kafkaEndpoint.host() + ":" + kafkaEndpoint.port());
? internalListenerAddr + "," + hostListenerAddr
: internalListenerAddr);
LOG.infov("Redpanda host listener for MSK cluster {0} published at {1}",
cluster.getClusterName(), hostListenerAddr);
} else {