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
CURATOR-535: Fix client port conflict due to untrustworthy random port allocation #421
CURATOR-535: Fix client port conflict due to untrustworthy random port allocation #421
Conversation
c82a8de
to
16fd81a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@kezhuw sorry for the late review. I'm going to merge this patch if the conflict gets resolved. Would you continue this patch? |
16fd81a
to
643c7b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we need to use reflection to access the ZK server internals, what about sending a path to ZooKeeper in order to allow us to do this stuff without reflection?
Otherwise there is a good chance that we won't be compatible with future ZooKeeper releases if they do some refactoring
@eolivelli I have created ZOOKEEPER-4670 for your point. It would be really nice to code without reflection. But I noticed that CURATOR-587(#434) did not require bumping of zookeeper dependency. If we are going to depend on ZOOKEEPER-4670 then clients will have to sync their zookeeper dependencies with curator. Is it ok for this ? |
643c7b0
to
8eda7d0
Compare
I think I could drop most of reflection usages but with one exception. The reflection in |
8eda7d0
to
c3bb1a9
Compare
@eolivelli I have dropped most reflection usages except Alternative, I think we can wait until possible 3.7.2 with fix for ZOOKEEPER-4303. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This even looks better !
@tisonkun @Randgalt @cammckenzie would you mind taking a look ?
/** | ||
* @deprecated use {@link TestingServer#getConnectString()} or {@link TestingCluster#getConnectString()} instead | ||
*/ | ||
@Deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we already remove public QuorumPeerConfig getConfig() throws Exception {
which breaks compatibility, what if we remove this deprecated mark and change the visibility to default (pacakge)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and why do we remove ZooKeeperMainFace#getConfig
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this pr mixed two things: CURATOR-535 and bring back TestTestingServer#setCustomTickTimeTest
for #383.
ZooKeeperMainFace#getConfig
was introduced in #434, and its sole external usage in TestTestingServer#setCustomTickTimeTest
undermines #383.
Comparing to public InstanceSpec
, I think ZooKeeperMainFace
is more like an internal concept. May be we can restrict visibility of ZooKeeperMainFace
to package ? This should solve all above concerns if make sense to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kezhuw That sounds reasonable. And we can add getTickTime
or something so that we don't have to change hasZooKeeperServerEmbedded
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed public
from ZooKeeperMainFace
. @tisonkun
getTickTime
needs reflection as ZooKeeperServerEmbedded
exposes no such info(ZOOKEEPER-4670). In previous version(8eda7d0), I exposed a get method in ZooKeeperMainFace
to retrieve ServerCnxnFactory
where both getTickTime
and getClientPort
could be easily constructed . But that approach depends heavily on reflection as QuorumPeerMain
and ZooKeeperServerEmbedded
exposes no such info.
The rest looks good. Comments above. |
…t allocation This commit tries to solve port conflict for `TestingServer` if port is unspecified(aka. `port <= 0`): * Set `InstanceSpec.port` to 0 if port is unspecified. * Save OS chosen bind port after started to maintain same port across restart. Ideally, it should be possible to bootstrap `TestingCluster`(with unspecified ports) too with help from `reconfig`. But there are difficulties since election port, quorum port were not designed to be bound to `0` in ZooKeeper. `TestingServer` should be enough for most cases. Users should resort to other solutions(eg. container) if they got bored by port conflict due to usages of `TestingCluster` and `TestingServer.restart`.
c3bb1a9
to
6348215
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Further improvement can be investigated later.
@kezhuw I can't assign the JIRA issue to you, but I have committed the patch |
This commit tries to solve port conflict for
TestingServer
if port is unspecified(aka.port <= 0
):InstanceSpec.port
to 0 if port is unspecified.Ideally, it should be possible to bootstrap
TestingCluster
(with unspecified ports) too with help fromreconfig
. But there are difficulties since election port, quorum port were not designed to be bound to0
in ZooKeeper.TestingServer
should be enough for most cases.Users should resort to other solutions(eg. container) if they got bored by port conflict due to usages of
TestingCluster
andTestingServer.restart
.