Kaynağa Gözat

Fix isReachable check (#39)

Merge branch 'master' into kris/fix_reachable

Fix isReachable check

Co-authored-by: jonathan <jonathan@noreply.git.bubblev.org>
Co-authored-by: Kristijan Mitrovic <kmitrovic@itekako.com>
Reviewed-on: #39
tags/v0.15.6^0
Kristijan Mitrovic 4 yıl önce
committed by jonathan
ebeveyn
işleme
67c6d81c10
1 değiştirilmiş dosya ile 27 ekleme ve 20 silme
  1. +27
    -20
      bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java

+ 27
- 20
bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java Dosyayı Görüntüle

@@ -640,30 +640,37 @@ public class StandardNetworkService implements NetworkService {
public boolean isReachable(BubbleNode node) {
final String prefix = "isReachable(" + node.id() + "): ";
try {
log.info(prefix+"starting");
log.info(prefix + "starting");

final NotificationReceipt receipt = notificationService.notify(node, NotificationType.health_check, null);
BubbleNodeState state = null;
if (receipt == null) {
log.info(prefix+"health_check failed, checking via cloud");
final CloudService cloud = cloudDAO.findByUuid(node.getCloud());
if (cloud == null) {
log.warn(prefix+"cloud not found: "+node.getCloud());
return false;
}
final BubbleNode status = cloud.getComputeDriver(configuration).status(node);
if (status != null) {
state = status.getState();
if (state != null && state.active()) {
log.info(prefix + "cloud status was: " + state + ", returning true");
return true;
}
}
if (receipt != null) {
log.debug(prefix + "receiving regular health_check receipt - all ok");
return true;
}
log.warn(prefix+"no way of reaching node "+node.id()+" (state="+state+"), returning false");
return false;

log.info(prefix+"health_check failed, checking via cloud");
final CloudService cloud = cloudDAO.findByUuid(node.getCloud());
if (cloud == null) {
log.warn(prefix + "cloud not found: " + node.getCloud());
return false;
}

final BubbleNode status = cloud.getComputeDriver(configuration).status(node);
if (status == null) {
log.warn(prefix + "node's status not found on the cloud: " + node.getCloud());
return false;
}

final BubbleNodeState state = status.getState();
if (state != null && state.active()) {
log.info(prefix + "node's state on cloud was ok: " + state);
return true;
} else {
log.warn(prefix + "bad node's state on cloud: " + state);
return false;
}
} catch (Exception e) {
log.warn(prefix+e);
log.warn(prefix + e, e);
return false;
}
}


Yükleniyor…
İptal
Kaydet