diff --git a/bubble-server/src/main/java/bubble/resources/account/MeResource.java b/bubble-server/src/main/java/bubble/resources/account/MeResource.java index b612f907..74110400 100644 --- a/bubble-server/src/main/java/bubble/resources/account/MeResource.java +++ b/bubble-server/src/main/java/bubble/resources/account/MeResource.java @@ -72,6 +72,7 @@ import static org.cobbzilla.util.daemon.ZillaRuntime.*; import static org.cobbzilla.util.http.HttpContentTypes.*; import static org.cobbzilla.util.json.JsonUtil.json; import static org.cobbzilla.wizard.resources.ResourceUtil.*; +import static org.cobbzilla.wizard.server.RestServerBase.reportError; @Consumes(APPLICATION_JSON) @Produces(APPLICATION_JSON) @@ -91,7 +92,12 @@ public class MeResource { public Response me(@Context ContainerRequest ctx) { try { final Account account = userPrincipal(ctx); - return ok(account.setPolicy(policyDAO.findSingleByAccount(account.getUuid()))); + final Account acct = accountDAO.findByUuid(account.getUuid()); + if (acct == null) { + reportError("MeResource.me: account in session but not in DB: "+account.getName()+"/"+account.getUuid()); + return unauthorized(); + } + return ok(acct.setPolicy(policyDAO.findSingleByAccount(account.getUuid()))); } catch (Exception e) { return notFound(); } diff --git a/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java b/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java index 2c18c34c..585bc5b2 100644 --- a/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java +++ b/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java @@ -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; } } diff --git a/bubble-server/src/main/resources/META-INF/bubble/bubble.properties b/bubble-server/src/main/resources/META-INF/bubble/bubble.properties index a7d9f4db..0bf1da28 100644 --- a/bubble-server/src/main/resources/META-INF/bubble/bubble.properties +++ b/bubble-server/src/main/resources/META-INF/bubble/bubble.properties @@ -1 +1 @@ -bubble.version=Adventure 0.15.5 +bubble.version=Adventure 0.15.6 diff --git a/utils/cobbzilla-utils b/utils/cobbzilla-utils index 51d700f6..b6e60fe9 160000 --- a/utils/cobbzilla-utils +++ b/utils/cobbzilla-utils @@ -1 +1 @@ -Subproject commit 51d700f6fe634d092adb3f238caf429a2d4c4dc7 +Subproject commit b6e60fe9771478a7210c018332395284fae0dd4b