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

feat: expose Redpanda's listener in the docker network #1994

Conversation

sago2k8
Copy link
Contributor

@sago2k8 sago2k8 commented Dec 15, 2023

Add a new WithListener function to allow adding new listeners to the advertised listeners so connection within the docker networks is possible

What does this PR do?

  • Added a method to add new listener to the containers
  • Validate the listener
  • Iterate over the networks and add the new listeners as alias so it can be easily accessible.

Why is it important?

Currently there is no way to access the Kafka Api from another container in the same docker network, at least not an obvious one, so as Redpanda docs suggests adding an extra advertise listener allows access to the Kafka endpoint from within the docker network so it can be consume from another test-container.

Related issues

@sago2k8 sago2k8 requested a review from a team as a code owner December 15, 2023 01:01
Copy link

netlify bot commented Dec 15, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 9525546
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/65a016a801ef6d000841a74e
😎 Deploy Preview https://deploy-preview-1994--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.

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I've left a suggestion regarding the implementation and how to test it.

modules/redpanda/mounts/redpanda.yaml.tpl Outdated Show resolved Hide resolved
@sago2k8 sago2k8 force-pushed the feat/expose-kafka-listener-in-docker-net branch 2 times, most recently from 7d4e8d6 to d37251b Compare December 19, 2023 10:23
@sago2k8 sago2k8 force-pushed the feat/expose-kafka-listener-in-docker-net branch 5 times, most recently from 7c11390 to dc92721 Compare December 21, 2023 17:01
@sago2k8 sago2k8 force-pushed the feat/expose-kafka-listener-in-docker-net branch 2 times, most recently from 6d23f44 to 19e5e9c Compare January 8, 2024 16:05
Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sago2k8, thanks for submitting this feature. It LGTM, although I've added a few comments regarding format (errors and its evaluation) and comments (not blockers).

Regarding documentation, I'd like to see this new functional option added to the docs here: docs/modules/redpanda.md. Please take a look at the codeinclude blocks in order to embed existing code snippets into the docs.

Once this is added, I think we can merge.

Cheers!

modules/redpanda/options.go Outdated Show resolved Hide resolved
modules/redpanda/options.go Outdated Show resolved Hide resolved
modules/redpanda/redpanda.go Outdated Show resolved Hide resolved
modules/redpanda/options.go Outdated Show resolved Hide resolved
modules/redpanda/redpanda.go Outdated Show resolved Hide resolved
modules/redpanda/redpanda.go Outdated Show resolved Hide resolved
@sago2k8 sago2k8 force-pushed the feat/expose-kafka-listener-in-docker-net branch 2 times, most recently from a3ff346 to 7baad87 Compare January 10, 2024 18:23
@sago2k8
Copy link
Contributor Author

sago2k8 commented Jan 10, 2024

Hi @sago2k8, thanks for submitting this feature. It LGTM, although I've added a few comments regarding format (errors and its evaluation) and comments (not blockers).

Regarding documentation, I'd like to see this new functional option added to the docs here: docs/modules/redpanda.md. Please take a look at the codeinclude blocks in order to embed existing code snippets into the docs.

Once this is added, I think we can merge.

Cheers!

Thanks for the review @mdelapenya, I think I addressed all your comments and added the documentation. could you give it another look please :)

Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are almost there, please check my comments 🙏

modules/redpanda/redpanda_test.go Outdated Show resolved Hide resolved
modules/redpanda/redpanda_test.go Show resolved Hide resolved
modules/redpanda/redpanda_test.go Outdated Show resolved Hide resolved
modules/redpanda/redpanda.go Outdated Show resolved Hide resolved
New function WithListener lets you add a new listener to the redpanda
container that can be used within any of the docker networks of the
container

Signed-off-by: Santiago Jimenez Giraldo <sago2k8@gmail.com>
@sago2k8 sago2k8 force-pushed the feat/expose-kafka-listener-in-docker-net branch from 41d7932 to 5064d3b Compare January 11, 2024 10:55
@sago2k8
Copy link
Contributor Author

sago2k8 commented Jan 11, 2024

I think I addressed all your comments @mdelapenya, thanks for the review !!

@sago2k8 sago2k8 force-pushed the feat/expose-kafka-listener-in-docker-net branch from 02bfd01 to bfa5b8c Compare January 11, 2024 15:18
@sago2k8
Copy link
Contributor Author

sago2k8 commented Jan 11, 2024

Just noticed there was a merge conflict in one of my commits, addressed now :)

Add test for new WithListener function, validate connectivity and couple
of asserts in the construction of the listener

Signed-off-by: Santiago Jimenez Giraldo <sago2k8@gmail.com>
@mdelapenya mdelapenya self-assigned this Jan 11, 2024
Add documentation for the additional listener option (WithListener) for the
Redpanda module

Signed-off-by: Santiago Jimenez Giraldo <sago2k8@gmail.com>
@mdelapenya mdelapenya added the enhancement New feature or request label Jan 11, 2024
@sago2k8 sago2k8 force-pushed the feat/expose-kafka-listener-in-docker-net branch from bfa5b8c to 9b9fd50 Compare January 11, 2024 15:26
Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, thanks for your time!

@eddumelendez if you see anything weird, please let's do it in a follow up PR 🙏

@mdelapenya mdelapenya merged commit 2309c4e into testcontainers:main Jan 12, 2024
116 checks passed
Comment on lines +279 to +281
for _, network := range req.Networks {
req.NetworkAliases[network] = append(req.NetworkAliases[network], listener.Address)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one issue with this approach that Java implementation still have is that when adding Toxiproxy upfront Kafka container and using 0.0.0.0:<random-toxiproxy-port> as a listener the registration will fail because will try to add 0.0.0.0 as an alias. I forgot to mention that when suggesting the approach initially.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sago2k8 @eddumelendez would you like to collaborate in a follow-up PR for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for your comments, yes I could work on it, do you happen to have a suggestion of a expected behaviour for that specific case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants