From 4d4f4bd9a56fc94e7c29914f00386c5983b4a2bd Mon Sep 17 00:00:00 2001 From: Pascal Fischer Date: Tue, 3 Dec 2024 16:19:34 +0100 Subject: [PATCH] include posture check existence --- management/server/peer.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/management/server/peer.go b/management/server/peer.go index c27687d73c9..474c2d6652e 100644 --- a/management/server/peer.go +++ b/management/server/peer.go @@ -685,17 +685,20 @@ func (am *DefaultAccountManager) SyncPeer(ctx context.Context, sync PeerSync, ac return nil, nil, nil, fmt.Errorf("failed to validate peer: %w", err) } - if isStatusChanged || sync.UpdateAccountPeers || updated { - am.updateAccountPeers(ctx, account.Id) + postureChecks, err := am.getPeerPostureChecks(account, peer.ID) + if err != nil { + return nil, nil, nil, err } - var postureChecks []*posture.Checks + if isStatusChanged || sync.UpdateAccountPeers || (updated && len(postureChecks) > 0) { + am.updateAccountPeers(ctx, account.Id) + } if peerNotValid { emptyMap := &NetworkMap{ Network: account.Network.Copy(), } - return peer, emptyMap, postureChecks, nil + return peer, emptyMap, []*posture.Checks{}, nil } validPeersMap, err := am.GetValidatedPeers(account) @@ -703,11 +706,6 @@ func (am *DefaultAccountManager) SyncPeer(ctx context.Context, sync PeerSync, ac return nil, nil, nil, fmt.Errorf("failed to get validated peers: %w", err) } - postureChecks, err = am.getPeerPostureChecks(account, peer.ID) - if err != nil { - return nil, nil, nil, err - } - customZone := account.GetPeersCustomZone(ctx, am.dnsDomain) return peer, account.GetPeerNetworkMap(ctx, peer.ID, customZone, validPeersMap, am.metrics.AccountManagerMetrics()), postureChecks, nil }