Skip to content

Commit

Permalink
include posture check existence
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fischer committed Dec 3, 2024
1 parent d459582 commit 4d4f4bd
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions management/server/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,29 +685,27 @@ 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)
if err != nil {
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
}
Expand Down

0 comments on commit 4d4f4bd

Please sign in to comment.