From f19ab9e9465f8411377871ae7812ecddb840fc57 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Tue, 8 Sep 2020 15:43:15 +0200 Subject: [PATCH] Fix account sync preconditions --- .../account/StandardSyncAccountService.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bubble-server/src/main/java/bubble/service/account/StandardSyncAccountService.java b/bubble-server/src/main/java/bubble/service/account/StandardSyncAccountService.java index 5af6369c..e196d05f 100644 --- a/bubble-server/src/main/java/bubble/service/account/StandardSyncAccountService.java +++ b/bubble-server/src/main/java/bubble/service/account/StandardSyncAccountService.java @@ -46,14 +46,12 @@ public class StandardSyncAccountService implements SyncAccountService { log.warn("sync: thisNetwork was null, sync_account is impossible"); return; } - if (!account.admin()) { - log.info("sync: not syncing non-admin account"); - return; - } + if (!account.sync()) { log.info("sync: account sync disabled for account: "+account.getName()); return; } + final AnsibleInstallType installType = thisNetwork.getInstallType(); if (installType == AnsibleInstallType.sage) { // changing account on sage, notify all bubbles launched by user that have syncAccount == true @@ -62,7 +60,7 @@ public class StandardSyncAccountService implements SyncAccountService { if (network.getState() != BubbleNetworkState.running) continue; if (!network.syncAccount()) continue; for (BubbleNode node : nodeDAO.findByNetwork(network.getUuid())) { - if (node.getUuid().equals(configuration.getThisNode().getUuid())) { + if (node.getUuid().equals(thisNetwork.getUuid())) { log.info("sync: not notifying self"); continue; } @@ -72,10 +70,16 @@ public class StandardSyncAccountService implements SyncAccountService { } } else if (installType == AnsibleInstallType.node) { + if (account.getUuid().equals(thisNetwork.getAccount())) { + log.info("sync: not syncing non-owner account from node to sage"); + return; + } + if (!thisNetwork.syncAccount()) { log.info("sync: disabled for node, not sending sync_account notification"); return; } + // changing account on node, notify sage, which will then notify all bubbles launched by user that have // syncAccount == true log.info("sync: sending sync_account notification from node to sage: "+configuration.getSageNode());