mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-01 13:11:01 +00:00
Revert "control/controlclient: delete unreferenced mapSession UserProfiles"
This reverts commit 413fb5b93311972e3a8d724bb696607ef3afe6f2. See long story in #14992 Updates #14992 Updates tailscale/corp#26058 Change-Id: I3de7d080443efe47cbf281ea20887a3caf202488 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
01efddea01
commit
b7f508fccf
@ -195,10 +195,6 @@ func (ms *mapSession) HandleNonKeepAliveMapResponse(ctx context.Context, resp *t
|
|||||||
|
|
||||||
ms.updateStateFromResponse(resp)
|
ms.updateStateFromResponse(resp)
|
||||||
|
|
||||||
// Occasionally clean up old userprofile if it grows too much
|
|
||||||
// from e.g. ephemeral tagged nodes.
|
|
||||||
ms.cleanLastUserProfile()
|
|
||||||
|
|
||||||
if ms.tryHandleIncrementally(resp) {
|
if ms.tryHandleIncrementally(resp) {
|
||||||
ms.occasionallyPrintSummary(ms.lastNetmapSummary)
|
ms.occasionallyPrintSummary(ms.lastNetmapSummary)
|
||||||
return nil
|
return nil
|
||||||
@ -296,6 +292,7 @@ func (ms *mapSession) updateStateFromResponse(resp *tailcfg.MapResponse) {
|
|||||||
for _, up := range resp.UserProfiles {
|
for _, up := range resp.UserProfiles {
|
||||||
ms.lastUserProfile[up.ID] = up.View()
|
ms.lastUserProfile[up.ID] = up.View()
|
||||||
}
|
}
|
||||||
|
// TODO(bradfitz): clean up old user profiles? maybe not worth it.
|
||||||
|
|
||||||
if dm := resp.DERPMap; dm != nil {
|
if dm := resp.DERPMap; dm != nil {
|
||||||
ms.vlogf("netmap: new map contains DERP map")
|
ms.vlogf("netmap: new map contains DERP map")
|
||||||
@ -544,32 +541,6 @@ func (ms *mapSession) addUserProfile(nm *netmap.NetworkMap, userID tailcfg.UserI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanLastUserProfile deletes any entries from lastUserProfile
|
|
||||||
// that are not referenced by any peer or the self node.
|
|
||||||
//
|
|
||||||
// This is expensive enough that we don't do this on every message
|
|
||||||
// from the server, but only when it's grown enough to matter.
|
|
||||||
func (ms *mapSession) cleanLastUserProfile() {
|
|
||||||
if len(ms.lastUserProfile) < len(ms.peers)*2 {
|
|
||||||
// Hasn't grown enough to be worth cleaning.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
keep := set.Set[tailcfg.UserID]{}
|
|
||||||
if node := ms.lastNode; node.Valid() {
|
|
||||||
keep.Add(node.User())
|
|
||||||
}
|
|
||||||
for _, n := range ms.peers {
|
|
||||||
keep.Add(n.User())
|
|
||||||
keep.Add(n.Sharer())
|
|
||||||
}
|
|
||||||
for userID := range ms.lastUserProfile {
|
|
||||||
if !keep.Contains(userID) {
|
|
||||||
delete(ms.lastUserProfile, userID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var debugPatchifyPeer = envknob.RegisterBool("TS_DEBUG_PATCHIFY_PEER")
|
var debugPatchifyPeer = envknob.RegisterBool("TS_DEBUG_PATCHIFY_PEER")
|
||||||
|
|
||||||
// patchifyPeersChanged mutates resp to promote PeersChanged entries to PeersChangedPatch
|
// patchifyPeersChanged mutates resp to promote PeersChanged entries to PeersChangedPatch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user