Browse Source

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

* clean unused import

* fix style check

* fix when path is null or empty, it will cause serverhost is null,

* fix UT test (#15684)

* [Fix-15639] parameterPassing is null case NPE (#15678)

Co-authored-by: caishunfeng <caishunfeng2021@gmail.com>

* fix  when path is null or empty, it will cause serverhost is null,
dev_wenjun_refactorMaster
ZhongJinHacker 9 months ago committed by GitHub
parent
commit
738da1cda3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
  2. 6
      dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java

11
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java

@ -131,9 +131,12 @@ public class MasterRegistryClient implements AutoCloseable {
public void removeWorkerNodePath(String path, RegistryNodeType nodeType, boolean failover) { public void removeWorkerNodePath(String path, RegistryNodeType nodeType, boolean failover) {
log.info("{} node deleted : {}", nodeType, path); log.info("{} node deleted : {}", nodeType, path);
try { try {
String serverHost = null; if (StringUtils.isEmpty(path)) {
if (!StringUtils.isEmpty(path)) { log.error("server down error: node empty path: {}, nodeType:{}", path, nodeType);
serverHost = registryClient.getHostByEventDataPath(path); return;
}
String serverHost = registryClient.getHostByEventDataPath(path);
if (StringUtils.isEmpty(serverHost)) { if (StringUtils.isEmpty(serverHost)) {
log.error("server down error: unknown path: {}", path); log.error("server down error: unknown path: {}", path);
return; return;
@ -141,7 +144,7 @@ public class MasterRegistryClient implements AutoCloseable {
if (!registryClient.exists(path)) { if (!registryClient.exists(path)) {
log.info("path: {} not exists", path); log.info("path: {} not exists", path);
} }
}
// failover server // failover server
if (failover) { if (failover) {
failoverService.failoverServerWhenDown(serverHost, nodeType); failoverService.failoverServerWhenDown(serverHost, nodeType);

6
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClientTest.java

@ -103,4 +103,10 @@ public class MasterRegistryClientTest {
// Cannot mock static methods // Cannot mock static methods
masterRegistryClient.removeWorkerNodePath("/path", RegistryNodeType.WORKER, true); masterRegistryClient.removeWorkerNodePath("/path", RegistryNodeType.WORKER, true);
} }
@Test
public void removeWorkNodePathTest() {
masterRegistryClient.removeWorkerNodePath("", RegistryNodeType.WORKER, true);
masterRegistryClient.removeWorkerNodePath(null, RegistryNodeType.WORKER, true);
}
} }

Loading…
Cancel
Save