testcontainers / testcontainers/testcontainers-java
Bad KAFKA_ADVERTISED_LISTENERS when exposing host ports to the container
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 2g 17h
- PR unite (30g)
- 9
Descrizione
This issue relates to the Kafka module.
When using the testcontainers utility to expose host ports to all containers (see https://www.testcontainers.org/features/networking/#exposing-host-ports-to-the-container), KafkaContainer faills to start Kafka due to an internal misconfiguration.
The error seen from the Kafka container logs is the following:
java.lang.IllegalArgumentException: requirement failed: Each listener must have a different port, listeners: PLAINTEXT://localhost:32889,BROKER://192.168.0.2:9092,BROKER://172.17.0.4:9092
From my analysis, it seems that, when using the feature, testcontainers adds the additional bridge network to each container which messes up with the setup of the KAFKA_ADVERTISED_LISTENERS environment variable of the KafkaContainer class (see https://github.com/testcontainers/testcontainers-java/blob/master/modules/kafka/src/main/java/org/testcontainers/containers/KafkaContainer.java#L115-L121).
We change the affected part to use different ports when multiple networks are present, but I'm not sure of the implications. Any thoughts on the subject?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da modules/kafka/src/main/java/org/testcontainers/containers/KafkaContainer.java intorno alle righe 115-121 e consulta la documentazione sul networking relativa all’esposizione delle porte dell’host ai container. Riproduci il problema con una rete bridge aggiuntiva e verifica come viene assemblato KAFKA_ADVERTISED_LISTENERS. Il lavoro è completato quando KafkaContainer si avvia correttamente con porte di ascolto distinte in questa configurazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- docker, java, kafka
- Ambito
- distributed-systems, networking, testing
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100