mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-12 09:50:47 +01:00
[management] merge update account peers in sync call (#2978)
This commit is contained in:
parent
e5d42bc963
commit
d063fbb8b9
@ -678,10 +678,6 @@ func (am *DefaultAccountManager) SyncPeer(ctx context.Context, sync PeerSync, ac
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, fmt.Errorf("failed to save peer: %w", err)
|
return nil, nil, nil, fmt.Errorf("failed to save peer: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if sync.UpdateAccountPeers {
|
|
||||||
am.updateAccountPeers(ctx, account.Id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
peerNotValid, isStatusChanged, err := am.integratedPeerValidator.IsNotValidPeer(ctx, account.Id, peer, account.GetPeerGroupsList(peer.ID), account.Settings.Extra)
|
peerNotValid, isStatusChanged, err := am.integratedPeerValidator.IsNotValidPeer(ctx, account.Id, peer, account.GetPeerGroupsList(peer.ID), account.Settings.Extra)
|
||||||
@ -689,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)
|
return nil, nil, nil, fmt.Errorf("failed to validate peer: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var postureChecks []*posture.Checks
|
postureChecks, err := am.getPeerPostureChecks(account, peer.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if isStatusChanged || sync.UpdateAccountPeers || (updated && len(postureChecks) > 0) {
|
||||||
|
am.updateAccountPeers(ctx, account.Id)
|
||||||
|
}
|
||||||
|
|
||||||
if peerNotValid {
|
if peerNotValid {
|
||||||
emptyMap := &NetworkMap{
|
emptyMap := &NetworkMap{
|
||||||
Network: account.Network.Copy(),
|
Network: account.Network.Copy(),
|
||||||
}
|
}
|
||||||
return peer, emptyMap, postureChecks, nil
|
return peer, emptyMap, []*posture.Checks{}, nil
|
||||||
}
|
|
||||||
|
|
||||||
if isStatusChanged {
|
|
||||||
am.updateAccountPeers(ctx, account.Id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validPeersMap, err := am.GetValidatedPeers(account)
|
validPeersMap, err := am.GetValidatedPeers(account)
|
||||||
@ -707,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)
|
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)
|
customZone := account.GetPeersCustomZone(ctx, am.dnsDomain)
|
||||||
return peer, account.GetPeerNetworkMap(ctx, peer.ID, customZone, validPeersMap, am.metrics.AccountManagerMetrics()), postureChecks, nil
|
return peer, account.GetPeerNetworkMap(ctx, peer.ID, customZone, validPeersMap, am.metrics.AccountManagerMetrics()), postureChecks, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user