diff --git a/management/server/account.go b/management/server/account.go index c7848db9d..5a945968a 100644 --- a/management/server/account.go +++ b/management/server/account.go @@ -1495,19 +1495,8 @@ func (am *DefaultAccountManager) SyncUserJWTGroups(ctx context.Context, userAuth } if removedGroupAffectsPeers || newGroupsAffectsPeers { - - if am.expNewNetworkMap { - account, err := am.Store.GetAccount(ctx, userAuth.AccountId) - if err != nil { - return err - } - - validatedPeers, err := am.integratedPeerValidator.GetValidatedPeers(ctx, account.Id, maps.Values(account.Groups), maps.Values(account.Peers), account.Settings.Extra) - if err != nil { - return err - } - - am.recalculateNetworkMapCache(account, validatedPeers) + if err := am.RecalculateNetworkMapCache(ctx, userAuth.AccountId); err != nil { + return err } log.WithContext(ctx).Tracef("user %s: JWT group membership changed, updating account peers", userAuth.UserId) diff --git a/management/server/holder.go b/management/server/holder.go index 517f6cc47..783ea2cde 100644 --- a/management/server/holder.go +++ b/management/server/holder.go @@ -25,7 +25,7 @@ func (am *DefaultAccountManager) getAccountFromHolder(accountID string) *types.A if a != nil { return a } - account, err := am.Store.GetAccount(context.Background(), accountID) + account, err := am.requestBuffer.GetAccountWithBackpressure(context.Background(), accountID) if err != nil { return nil } diff --git a/management/server/peer.go b/management/server/peer.go index 333dca05a..da4371f55 100644 --- a/management/server/peer.go +++ b/management/server/peer.go @@ -395,7 +395,7 @@ func (am *DefaultAccountManager) DeletePeer(ctx context.Context, accountID, peer } if updateAccountPeers && am.expNewNetworkMap { - account, err := am.Store.GetAccount(ctx, accountID) + account, err := am.requestBuffer.GetAccountWithBackpressure(ctx, accountID) if err != nil { return err } @@ -727,7 +727,7 @@ func (am *DefaultAccountManager) AddPeer(ctx context.Context, accountID, setupKe am.StoreEvent(ctx, opEvent.InitiatorID, opEvent.TargetID, opEvent.AccountID, opEvent.Activity, opEvent.Meta) if am.expNewNetworkMap { - account, err := am.Store.GetAccount(ctx, accountID) + account, err := am.requestBuffer.GetAccountWithBackpressure(ctx, accountID) if err != nil { return nil, nil, nil, err } @@ -1228,11 +1228,18 @@ func (am *DefaultAccountManager) checkIfUserOwnsPeer(ctx context.Context, accoun // Should be called when changes have to be synced to peers. func (am *DefaultAccountManager) UpdateAccountPeers(ctx context.Context, accountID string) { log.WithContext(ctx).Tracef("updating peers for account %s from %s", accountID, util.GetCallerName()) - - account, err := am.requestBuffer.GetAccountWithBackpressure(ctx, accountID) - if err != nil { - log.WithContext(ctx).Errorf("failed to send out updates to peers. failed to get account: %v", err) - return + var ( + account *types.Account + err error + ) + if am.expNewNetworkMap { + account = am.getAccountFromHolder(accountID) + } else { + account, err = am.requestBuffer.GetAccountWithBackpressure(ctx, accountID) + if err != nil { + log.WithContext(ctx).Errorf("failed to send out updates to peers. failed to get account: %v", err) + return + } } globalStart := time.Now()