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

ZOOKEEPER-4303: Allow configuring client port to 0 #1868

Closed
wants to merge 1 commit into from

Conversation

madrob
Copy link
Contributor

@madrob madrob commented Apr 25, 2022

https://issues.apache.org/jira/browse/ZOOKEEPER-4303

Allows specifying an explicit port 0 for the client port or secure client port, which will default to operating system behavior of finding an unbound port. Modified ZKServerEmbedded to report the actual port instead of the configured port.

@madrob
Copy link
Contributor Author

madrob commented May 2, 2022

I'm not able to reproduce the failure seen by the GitHub actions, can somebody help me figure out if this is caused by my changes or an existing issue?

@madrob
Copy link
Contributor Author

madrob commented May 31, 2022

Force pushed rebase to development branch.

Copy link
Member

@kezhuw kezhuw left a comment

Choose a reason for hiding this comment

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

Nice change. LGTM.

@eolivelli PTAL

@@ -427,7 +427,7 @@ public void parseProperties(Properties zkProp) throws IOException, ConfigExcepti
dataLogDir = dataDir;
}

if (clientPort == 0) {
if (clientPort == null) {
Copy link
Member

Choose a reason for hiding this comment

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

This is a behavior change but I think it make sense. Prior to this, "clientPortAddress" and "clientPort": 0 is not allowed. It is better to allow bind to 0 with specified local address.

Copy link
Member

Choose a reason for hiding this comment

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

The implicit logic here is that: use serverId to lookup if not address configured. Prior to this, 0 was used as "not configured", so explicit "127.0.0.1:0" is denied.

assertThat(zkServer.getConnectionString(), not(endsWith(":0")));
assertTrue(ClientBase.waitForServerUp(zkServer.getConnectionString(), 60000));
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind add one more case to assert explicit "127.0.0.1:0" ? As I said above, I think it is a noticeable change.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

return prettifyConnectionString(config.getSecureClientPortAddress(), boundSecureClientPort);
}

private String prettifyConnectionString(InetSocketAddress confAddress, int boundPort) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: static ?

@eolivelli
Copy link
Contributor

I have restarted CI

@kezhuw
Copy link
Member

kezhuw commented Sep 5, 2022

@maoling @symat Could you please take a look at this ? It is valuable in testing/embedded environments to avoid port conflict. It is ZooKeeper's CURATOR-535.

Copy link
Contributor

@symat symat left a comment

Choose a reason for hiding this comment

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

Looks good to me!
thanks!

@kezhuw
Copy link
Member

kezhuw commented Oct 10, 2022

@eolivelli @symat Shall we merge this ?

@symat
Copy link
Contributor

symat commented Oct 11, 2022

sorry for the delay, I kind of forgot about this one, I can merge it :(
@eolivelli - can I merge this or do we need an other test run here? (is there any way to re-trigger the failing pr-merge jenkins job? - I don't even remember which one is that or if it is important)

@eolivelli
Copy link
Contributor

I think that we can merge it.
you could restart the job by logging into jenkins using your ASF credentials.

I believe it is useless now that we have GH actions, I already started a discussion on dev@

@symat
Copy link
Contributor

symat commented Oct 11, 2022

yes, I agree to eliminate some of these CI jobs. I'll merge this PR now.

@asfgit asfgit closed this in 90f813e Oct 11, 2022
@symat
Copy link
Contributor

symat commented Oct 11, 2022

merge is done, thank you @madrob for your contribution!
and for your patience ;)

anuragmadnawat1 pushed a commit to anuragmadnawat1/zookeeper that referenced this pull request Nov 2, 2022
https://issues.apache.org/jira/browse/ZOOKEEPER-4303

Allows specifying an explicit port 0 for the client port or secure client port, which will default to operating system behavior of finding an unbound port. Modified ZKServerEmbedded to report the actual port instead of the configured port.

Author: Mike Drob <mdrob@apple.com>

Reviewers: Kezhu Wang <kezhuw@gmail.com>, Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1868 from madrob/zookeeper-4303
anuragmadnawat1 added a commit to anuragmadnawat1/zookeeper that referenced this pull request Nov 2, 2022
https://issues.apache.org/jira/browse/ZOOKEEPER-4303

Allows specifying an explicit port 0 for the client port or secure client port, which will default to operating system behavior of finding an unbound port. Modified ZKServerEmbedded to report the actual port instead of the configured port.

Author: Mike Drob <mdrob@apple.com>

Reviewers: Kezhu Wang <kezhuw@gmail.com>, Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>

Closes apache#1868 from madrob/zookeeper-4303

Co-authored-by: Mike Drob <mdrob@apple.com>
@kezhuw
Copy link
Member

kezhuw commented Feb 5, 2023

@eolivelli @symat Would you mind merging this to 3.7 and 3.8 ? apache/curator#421 needs this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants