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-4276. Serving only with secureClientPort fails #2117

Merged
merged 3 commits into from Mar 9, 2024

Conversation

abhilash1in
Copy link
Contributor

@abhilash1in abhilash1in commented Jan 29, 2024

This PR addresses ZOOKEEPER-4276, which enables a cluster to run as a TLS-only cluster on the secureClientPort.

Previously, this was not possible due to reasons mentioned in ZOOKEEPER-4276.

In this change, we introduce a new section to sever.X entries of dynamic config to indicate secureClientPort. We also make clientPort section of the dynamic config as optional (previously, this was mandatory).

For example:

server.5 = 125.23.63.23:1234:1235;;1237

does not have a clientPort and has 1237 as the secureClientPort.

Dev mailing list thread - https://lists.apache.org/thread/1lmqj2wonldxmk3wxbc5lvj3vsz05l7c

@abhilash1in abhilash1in force-pushed the tls-only-cluster branch 4 times, most recently from e863a9c to 81c5b52 Compare January 29, 2024 23:06
@abhilash1in abhilash1in force-pushed the tls-only-cluster branch 2 times, most recently from 69e70b2 to d0846b2 Compare February 20, 2024 03:07
@abhilash1in abhilash1in marked this pull request as ready for review February 20, 2024 21:29
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

Great work

@tisonkun tisonkun self-requested a review February 22, 2024 00:45
Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

Thank you!

I wonder if we'd back port this feature to 3.9.2. Others LGTM.

I'll anyway merge this patch in days if there is no more objection.

becomes as follows:

server.<positive id> = <address1>:<port1>:<port2>[:role];[<client port address>:]<client port>**
server.<positive id> = <address1>:<port1>:<port2>[:role];[[<client port address>:]<client port>][;[<secure client port address>:]<secure client port>]
Copy link
Member

Choose a reason for hiding this comment

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

OT - maybe describe what "port1" and "port2" for. Not a blocker for this patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Starting with 3.5.0 the
_clientPort_ and _clientPortAddress_ configuration parameters should no longer be used in zoo.cfg.

Starting with 3.9.2 the
Copy link
Member

Choose a reason for hiding this comment

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

3.10.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@anmolnar anmolnar changed the title Support TLS-only ZK server ZOOKEEPER-4276. Serving only with secureClientPort fails Mar 8, 2024
Copy link
Contributor

@anmolnar anmolnar left a comment

Choose a reason for hiding this comment

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

lgtm.

Comment on lines +127 to +129
try (X509Util x509Util = new ClientX509Util()) {
sslContext = x509Util.getDefaultSSLContext();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of this try block without catch clause?
It's a bit strange to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "try-with-resources" construct ensures that each resource declared in the try is closed at the end of the statement, which can help prevent resource leaks. In this case, it's ensuring that the X509Util instance is properly closed after use (X509Util implements a Closeable interface). It doesn't necessarily need a catch clause because it's about managing resources rather than catching and handling exceptions.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. It's for closing the resource X509Util.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, sure of course.
thanks

@tisonkun
Copy link
Member

tisonkun commented Mar 9, 2024

Merging...

Thanks for your contribution @abhilash1in!

@tisonkun tisonkun merged commit bc1fc6d into apache:master Mar 9, 2024
13 checks passed
}
}

if (serverClientParts.length == 3 && !serverClientParts[2].isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we make this forward compatible to tolerate possible new section from future and backport it to old releases ?

I guess it might be safe in cluster upgrade as we probably don't allow downgrade. But at least, I would expect Curator, which use QuorumMaj(Properties props) to parse ensemble config, will fail here. Not sure other downstream third-party projects.

https://github.com/apache/curator/blob/972fffac7cf76fd5e6aadf586e6d2959b3750c76/curator-framework/src/main/java/org/apache/curator/framework/imps/EnsembleTracker.java#L190

org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: 10.1.2.3:2888:3888:participant;10.2.3.4:2181;10.2.3.4:2188 does not have the form server_config or server_config;client_config where server_config is the pipe separated list of host:port:port or host:port:port:type and client_config is port or host:port

	at org.apache.zookeeper.server.quorum.QuorumPeer$QuorumServer.initializeWithAddressString(QuorumPeer.java:340)
	at org.apache.zookeeper.server.quorum.QuorumPeer$QuorumServer.<init>(QuorumPeer.java:279)
	at org.apache.zookeeper.server.quorum.QuorumPeer$QuorumServer.<init>(QuorumPeer.java:274)
	at org.apache.zookeeper.server.quorum.flexible.QuorumMaj.<init>(QuorumMaj.java:92)

Or it is third-party libraries' responsibility to accommodate this ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is only available from 3.10.0 which is a major upgrade and as far as I know the code is able to read the old config, so backward compatibility is ok. I guess Curator will support ZK 3.10.0 from a certain release where they'll add the new config.

Copy link
Member

Choose a reason for hiding this comment

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

Yeh. I think, at the very least, users of Curator could pin their ZooKeeper to 3.10.0 before a Curator release.

AlphaCanisMajoris pushed a commit to AlphaCanisMajoris/zookeeper that referenced this pull request Mar 28, 2024
* Support TLS-only ZK server

* Cleanup

* Update documentation according to review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants