Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-2386] Report the correct tcp port in PING packets when it differs from the UDP port #1019

Merged
merged 8 commits into from
Mar 4, 2019

Conversation

ajsutton
Copy link
Contributor

@ajsutton ajsutton commented Mar 1, 2019

PR description

When Pantheon is started with --p2p-port=0 an available port is selected for the UDP peer discovery and TCP peer connections but there is no guarantee this port will be the same. Previously Pantheon would assume the UDP and TCP ports were the same so send the UDP port in place of the TCP port in PING messages, making it impossible for other peers to connect to it as they would use the wrong port.

@@ -145,7 +145,7 @@ public MockPeerDiscoveryAgent startDiscoveryAgent(

public MockPeerDiscoveryAgent startDiscoveryAgent(final AgentBuilder agentBuilder) {
final MockPeerDiscoveryAgent agent = createDiscoveryAgent(agentBuilder);
agent.start();
agent.start(65500).join();
Copy link
Contributor

Choose a reason for hiding this comment

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

You could use PeerDiscoveryTestHelper.nextAvailablePort here. Or you could try grabbing the discovery port from the agent's config and reusing that for the tcp port. Would be nice if we don't have to start scattering random numbers throughout the tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to clean up the rest of the magic numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have a look. They are just arbitrary numbers since we don't assert on them and don't open a port for them anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've pulled them out as constants - one of the tests already had a constant it had used for this previously.

@ajsutton ajsutton merged commit 7c68ae3 into PegaSysEng:master Mar 4, 2019
@ajsutton ajsutton deleted the report-correct-tcp-port branch March 4, 2019 20:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants