-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add http server port in the worker net address #18499
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f1ef54d
Add http server port in the worker net address
ChunxuTang cb0ab35
Overwrite etcd worker registration without http ports
ChunxuTang 77f67a3
Resolve review comments
ChunxuTang 07c139e
Fix review comment
ChunxuTang ff94a20
Use customized equality to compare etcd worker identifiers
ChunxuTang da942d7
Move customized equality comparison to WorkerServiceEntity
ChunxuTang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,19 +200,19 @@ public void testEtcdMembership(MembershipManager membershipManager) throws Excep | |
.setAddress(new WorkerNetAddress() | ||
.setHost("worker1").setContainerHost("containerhostname1") | ||
.setRpcPort(1000).setDataPort(1001).setWebPort(1011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(1021)); | ||
WorkerInfo wkr2 = new WorkerInfo() | ||
.setIdentity(WorkerIdentityTestUtils.randomUuidBasedId()) | ||
.setAddress(new WorkerNetAddress() | ||
.setHost("worker2").setContainerHost("containerhostname2") | ||
.setRpcPort(2000).setDataPort(2001).setWebPort(2011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(2021)); | ||
WorkerInfo wkr3 = new WorkerInfo() | ||
.setIdentity(WorkerIdentityTestUtils.randomUuidBasedId()) | ||
.setAddress(new WorkerNetAddress() | ||
.setHost("worker3").setContainerHost("containerhostname3") | ||
.setRpcPort(3000).setDataPort(3001).setWebPort(3011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(3031)); | ||
membershipManager.join(wkr1); | ||
membershipManager.join(wkr2); | ||
membershipManager.join(wkr3); | ||
|
@@ -260,13 +260,13 @@ public void testFlakyNetwork() throws Exception { | |
.setAddress(new WorkerNetAddress() | ||
.setHost("worker-1").setContainerHost("containerhostname1") | ||
.setRpcPort(29999).setDataPort(29997).setWebPort(30000) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(30001)); | ||
WorkerInfo wkr2 = new WorkerInfo() | ||
.setIdentity(WorkerIdentityTestUtils.randomUuidBasedId()) | ||
.setAddress(new WorkerNetAddress() | ||
.setHost("worker-2").setContainerHost("containerhostname2") | ||
.setRpcPort(29999).setDataPort(29997).setWebPort(30000) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(30001)); | ||
membershipManager.join(wkr1); | ||
membershipManager.join(wkr2); | ||
CommonUtils.waitFor("Workers joined", | ||
|
@@ -326,19 +326,19 @@ public void testStaticMembership() throws Exception { | |
.setAddress(new WorkerNetAddress() | ||
.setHost("worker1").setContainerHost("containerhostname1") | ||
.setRpcPort(1000).setDataPort(1001).setWebPort(1011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(1021)); | ||
WorkerInfo wkr2 = new WorkerInfo() | ||
.setIdentity(WorkerIdentityTestUtils.randomUuidBasedId()) | ||
.setAddress(new WorkerNetAddress() | ||
.setHost("worker2").setContainerHost("containerhostname2") | ||
.setRpcPort(2000).setDataPort(2001).setWebPort(2011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(2021)); | ||
WorkerInfo wkr3 = new WorkerInfo() | ||
.setIdentity(WorkerIdentityTestUtils.randomUuidBasedId()) | ||
.setAddress(new WorkerNetAddress() | ||
.setHost("worker3").setContainerHost("containerhostname3") | ||
.setRpcPort(3000).setDataPort(3001).setWebPort(3011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(3021)); | ||
membershipManager.join(wkr1); | ||
membershipManager.join(wkr2); | ||
membershipManager.join(wkr3); | ||
|
@@ -367,13 +367,13 @@ public void testSameWorkerIdentityConflict() throws Exception { | |
.setAddress(new WorkerNetAddress() | ||
.setHost("worker1").setContainerHost("containerhostname1") | ||
.setRpcPort(1000).setDataPort(1001).setWebPort(1011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(1021)); | ||
WorkerInfo wkr2 = new WorkerInfo() | ||
.setIdentity(workerIdentity1) | ||
.setAddress(new WorkerNetAddress() | ||
.setHost("worker2").setContainerHost("containerhostname2") | ||
.setRpcPort(2000).setDataPort(2001).setWebPort(2011) | ||
.setDomainSocketPath("/var/lib/domain.sock")); | ||
.setDomainSocketPath("/var/lib/domain.sock").setHttpServerPort(2021)); | ||
membershipManager.join(wkr1); | ||
// bring wrk1 down and join wrk2 with a same worker identity. | ||
membershipManager.stopHeartBeat(wkr1); | ||
|
@@ -401,4 +401,44 @@ public void testSameWorkerIdentityConflict() throws Exception { | |
Assert.assertTrue(curWorkerInfo.isPresent()); | ||
Assert.assertEquals(wkr2.getAddress(), curWorkerInfo.get().getAddress()); | ||
} | ||
|
||
@Test | ||
public void testOptionalHttpPortChangeInWorkerAddress() throws Exception { | ||
final MembershipManager membershipManager = getHealthyEtcdMemberMgr(); | ||
Assert.assertTrue(membershipManager instanceof EtcdMembershipManager); | ||
// join without http server ports | ||
WorkerIdentity workerIdentity = WorkerIdentityTestUtils.randomUuidBasedId(); | ||
WorkerNetAddress workerNetAddress = new WorkerNetAddress() | ||
.setHost("worker1").setContainerHost("containerhostname1") | ||
.setRpcPort(1000).setDataPort(1001).setWebPort(1011) | ||
.setDomainSocketPath("/var/lib/domain.sock"); | ||
WorkerInfo wkr = new WorkerInfo() | ||
.setIdentity(workerIdentity) | ||
.setAddress(workerNetAddress); | ||
membershipManager.join(wkr); | ||
Optional<WorkerInfo> curWorkerInfo = membershipManager.getLiveMembers() | ||
.getWorkerById(workerIdentity); | ||
Assert.assertTrue(curWorkerInfo.isPresent()); | ||
membershipManager.stopHeartBeat(wkr); | ||
CommonUtils.waitFor("wkr is not alive.", () -> { | ||
try { | ||
return membershipManager.getFailedMembers().getWorkerById(workerIdentity).isPresent(); | ||
} catch (IOException e) { | ||
// IGNORE | ||
return false; | ||
} | ||
}, WaitForOptions.defaults().setTimeoutMs(5000)); | ||
|
||
// set the http server port and rejoin | ||
workerNetAddress.setHttpServerPort(1021); | ||
membershipManager.join(wkr); | ||
// check if the worker is rejoined and information updated | ||
WorkerClusterView allMembers = membershipManager.getAllMembers(); | ||
Assert.assertEquals(1, allMembers.size()); | ||
curWorkerInfo = membershipManager.getLiveMembers().getWorkerById(workerIdentity); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you also assert the getallmembers only have one worker -> meaning that we are not creating two entries There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point! I added that assertion. |
||
Assert.assertTrue(curWorkerInfo.isPresent()); | ||
Assert.assertEquals(wkr.getAddress(), curWorkerInfo.get().getAddress()); | ||
Assert.assertEquals(wkr.getAddress().getHttpServerPort(), | ||
curWorkerInfo.get().getAddress().getHttpServerPort()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can u add a test to have a worker join without http port set and afterwards join with http port set , it should be allowed to join and the list of workers should be unchanged.
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.
Added a test
testWorkerHttpServerPorts
. Could you take a review?