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

Only publish exposed ports #4122

Merged
merged 11 commits into from
May 26, 2021
Merged

Only publish exposed ports #4122

merged 11 commits into from
May 26, 2021

Conversation

rnorth
Copy link
Member

@rnorth rnorth commented May 24, 2021

Fixes #4119

@rnorth rnorth force-pushed the only-publish-exposed-ports branch from 0b15097 to 0e0e8c8 Compare May 24, 2021 16:25
@@ -1,8 +1,5 @@
package org.testcontainers.containers;
Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding imports, there are some changes in ordering, but AFAICT these only match the IntelliJ defaults (with our .editorconfig tweaks layered on top for star imports).

TBH I'd prefer to go with the changed (hopefully stable) import order in this PR, rather than continue to constantly have the burden of maintaining the order (I don't know why the current order is as it is).

I think if we find ourselves continuing to run up against this then we should introduce a code formatter to our build (e.g. spotless gradle plugin + google formatter with AOSP style (4 space indent)).

Comment on lines 740 to 745
// Next, ExposedPorts must be set up to publish all of the above ports, randomized and fixed.
// Collect all of the exposed ports for publication
final List<ExposedPort> exposedPorts = allPortBindings.stream()
.map(PortBinding::getExposedPort)
.distinct()
.collect(Collectors.toList());
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the thing that is substantially different from the previous implementation; changes above are mainly to support this change and to make it clearer what we're doing.

Of course, createCommand.withPublishAllPorts(true); on line 801 is also nuked.

@@ -54,8 +56,8 @@ public ClickHouseContainer(final DockerImageName dockerImageName) {
}

@Override
protected Integer getLivenessCheckPort() {
return getMappedPort(HTTP_PORT);
public Set<Integer> getLivenessCheckPortNumbers() {
Copy link
Member Author

@rnorth rnorth May 25, 2021

Choose a reason for hiding this comment

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

Not strictly required for this PR, but during experimenting with approaches I found that a handful of our modules are using the getLivenessCheckPort method, which has been deprecated for 4 years. I'd like to take this chance to clean up.

@@ -166,6 +166,19 @@ public String getConnectionString() {
protected void configure() {
super.configure();

addExposedPorts(
Copy link
Member Author

Choose a reason for hiding this comment

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

Interestingly the Couchbase module seems to have always relied on an EXPOSE statement + all-ports publication.

@rnorth rnorth marked this pull request as ready for review May 25, 2021 07:07
@rnorth rnorth requested a review from kiview as a code owner May 25, 2021 07:07
@bsideup bsideup added this to the next milestone May 25, 2021
Copy link
Member

@bsideup bsideup left a comment

Choose a reason for hiding this comment

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

💯

@rnorth rnorth merged commit 96b2065 into master May 26, 2021
@delete-merged-branch delete-merged-branch bot deleted the only-publish-exposed-ports branch May 26, 2021 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish only explicitly exposed ports
2 participants