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

[Fix][Master] Fix Potential danger in the event of a worker failover #15689

Merged
merged 15 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,20 @@ public void removeMasterNodePath(String path, RegistryNodeType nodeType, boolean
public void removeWorkerNodePath(String path, RegistryNodeType nodeType, boolean failover) {
log.info("{} node deleted : {}", nodeType, path);
try {
String serverHost = null;
if (!StringUtils.isEmpty(path)) {
serverHost = registryClient.getHostByEventDataPath(path);
if (StringUtils.isEmpty(serverHost)) {
log.error("server down error: unknown path: {}", path);
return;
}
if (!registryClient.exists(path)) {
log.info("path: {} not exists", path);
}
if (StringUtils.isEmpty(path)) {
log.error("server down error: node empty path: {}, nodeType:{}", path, nodeType);
return;
}

String serverHost = registryClient.getHostByEventDataPath(path);
if (StringUtils.isEmpty(serverHost)) {
log.error("server down error: unknown path: {}", path);
return;
}
if (!registryClient.exists(path)) {
log.info("path: {} not exists", path);
}

// failover server
if (failover) {
failoverService.failoverServerWhenDown(serverHost, nodeType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,10 @@ public void removeNodePathTest() {
// Cannot mock static methods
masterRegistryClient.removeWorkerNodePath("/path", RegistryNodeType.WORKER, true);
}

@Test
public void removeWorkNodePathTest() {
masterRegistryClient.removeWorkerNodePath("", RegistryNodeType.WORKER, true);
masterRegistryClient.removeWorkerNodePath(null, RegistryNodeType.WORKER, true);
}
}
Loading