Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kafka internal docker connection #2490

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

catinapoke
Copy link

What does this PR do?

I fixed passing alias name in startup script when it's possible.

Why is it important?

You can't connect to kafka container from other container at the same docker network.
Details: https://www.confluent.io/blog/kafka-listeners-explained/

Related issues

I have stumbled into issue with connecting from app docker container to kafka docker container at the same network. I tried many options including altering KAFKA_ADVERTISED_LISTENERS, but none of them worked. Finally, I found out that you overwrite KAFKA_ADVERTISED_LISTENERS in startup script.

Options I tried:

  1. Alter KAFKA_ADVERTISED_LISTENERS
  2. Change network type from bridge to host (it's impossible)
  3. Add new listeners

How to test this PR

I have tested it in my ProofOfConcept repo https://github.com/catinapoke/testcontainers-poc in kafka_test.go file
You can run it go test -v ./tests/integration/kafka_test.go

@catinapoke catinapoke requested a review from a team as a code owner April 19, 2024 11:48
Copy link

netlify bot commented Apr 19, 2024

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 320e54d
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/662259f618bbaa00089866be
😎 Deploy Preview https://deploy-preview-2490--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mdelapenya mdelapenya self-assigned this Apr 22, 2024
@mdelapenya mdelapenya added the bug An issue with the library label Apr 22, 2024
@catinapoke
Copy link
Author

@mdelapenya hi, will you make code review?

@mdelapenya
Copy link
Collaborator

@eddumelendez wdyt about this one? It LGTM from the code point of view, but want to double check with you if you see anything else 🙏

@eddumelendez
Copy link
Member

Hi, I think the approach should be consistent between Redpanda and Kafka regarding adding additional listeners https://golang.testcontainers.org/modules/redpanda/#additional-listener

@catinapoke
Copy link
Author

Okay, I will check this

@mdelapenya
Copy link
Collaborator

I think that, after #1989, we can close this one. @catinapoke could you double check it? 🙏

@mdelapenya
Copy link
Collaborator

BTW I'm going to add support for registering listeners, like in the redpanda implementation.

@catinapoke
Copy link
Author

I think that, after #1989, we can close this one. @catinapoke could you double check it? 🙏

I checked and it is doing different things, so not yet

@mdelapenya
Copy link
Collaborator

The code to register listeners will shadow what the redpanda module is currently doing (see https://github.com/testcontainers/testcontainers-go/blob/main/modules/redpanda/redpanda.go#L295), but instead of using the YAML template to render the listeners, we are going to build the proper environment variables for kafka: KAFKA_ADVERTISED_LISTENERS, KAFKA_LISTENERS, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants