Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
deardeng committed Sep 13, 2024
1 parent 6fb7c29 commit 2c035bb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,13 @@ private void checkDiffNode(Map<String, ClusterPB> remoteClusterIdToPB,
LOG.debug("current cluster status {} {}", currentClusterStatus, newClusterStatus);
}
boolean needChange = false;
Set<String> clusterStatusInMem = cloudSystemInfoService.getClusterStatus(currentBes);
// ATTN: found bug, In the same cluster, the cluster status in the tags of BE nodes is inconsistent.
// Using a set to collect the cluster statuses from the BE nodes.
Set<String> clusterStatusInMem = new HashSet<>();
for (Backend backend : currentBes) {
String beClusterStatus = backend.getTagMap().get(Tag.CLOUD_CLUSTER_STATUS);
clusterStatusInMem.add(beClusterStatus == null ? "NOT_SET" : beClusterStatus);
}
if (clusterStatusInMem.size() != 1) {
LOG.warn("cluster {}, multi be nodes cluster status inconsistent, fix it {}", cid, clusterStatusInMem);
needChange = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public String getCloudStatusByIdNoLock(final String clusterId) {
Optional<String> hasNormal = bes.stream().map(Backend::getCloudClusterStatus)
.filter(status -> status.equals(String.valueOf(Cloud.ClusterStatus.NORMAL))).findAny();
return hasNormal.orElseGet(() -> bes.stream().map(Backend::getCloudClusterStatus).findFirst()
.orElse(String.valueOf(Cloud.ClusterStatus.UNKNOWN)));
.orElse(String.valueOf(Cloud.ClusterStatus.NORMAL)));
}

public void updateClusterNameToId(final String newName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public Backend(long id, String host, int heartbeatPort) {
}

public String getCloudClusterStatus() {
return tagMap.getOrDefault(Tag.CLOUD_CLUSTER_STATUS, String.valueOf(Cloud.ClusterStatus.UNKNOWN));
return tagMap.getOrDefault(Tag.CLOUD_CLUSTER_STATUS, String.valueOf(Cloud.ClusterStatus.NORMAL));
}

public void setCloudClusterStatus(final String clusterStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ suite('test_auto_start_in_cloud', 'multi_cluster, docker') {
// add 1 nodes, check it status NORMAL
cluster.addBackend(1, null)
dockerAwaitUntil(5) {
def result = sql """SHOW BACKENDS"""
result = sql """SHOW BACKENDS"""
result.size() == 4
}

Expand All @@ -189,7 +189,7 @@ suite('test_auto_start_in_cloud', 'multi_cluster, docker') {
return
}
jsonObject = jsonSlurper.parseText(tag)
String cluster_status = jsonObject.cloud_cluster_status
cluster_status = jsonObject.cloud_cluster_status
assertEquals("NORMAL", cluster_status)
}
}
Expand Down

0 comments on commit 2c035bb

Please sign in to comment.