Skip to content

Commit fefb04b

Browse files
committed
Revert "control/controlclient: delete unreferenced mapSession UserProfiles"
This reverts commit 413fb5b. See long story in tailscale#14992 Updates tailscale#14992 Updates tailscale/corp#26058 Change-Id: I3de7d080443efe47cbf281ea20887a3caf202488 Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent ce31002 commit fefb04b

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

control/controlclient/map.go

+1-30
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,6 @@ func (ms *mapSession) HandleNonKeepAliveMapResponse(ctx context.Context, resp *t
195195

196196
ms.updateStateFromResponse(resp)
197197

198-
// Occasionally clean up old userprofile if it grows too much
199-
// from e.g. ephemeral tagged nodes.
200-
ms.cleanLastUserProfile()
201-
202198
if ms.tryHandleIncrementally(resp) {
203199
ms.occasionallyPrintSummary(ms.lastNetmapSummary)
204200
return nil
@@ -296,6 +292,7 @@ func (ms *mapSession) updateStateFromResponse(resp *tailcfg.MapResponse) {
296292
for _, up := range resp.UserProfiles {
297293
ms.lastUserProfile[up.ID] = up
298294
}
295+
// TODO(bradfitz): clean up old user profiles? maybe not worth it.
299296

300297
if dm := resp.DERPMap; dm != nil {
301298
ms.vlogf("netmap: new map contains DERP map")
@@ -544,32 +541,6 @@ func (ms *mapSession) addUserProfile(nm *netmap.NetworkMap, userID tailcfg.UserI
544541
}
545542
}
546543

547-
// cleanLastUserProfile deletes any entries from lastUserProfile
548-
// that are not referenced by any peer or the self node.
549-
//
550-
// This is expensive enough that we don't do this on every message
551-
// from the server, but only when it's grown enough to matter.
552-
func (ms *mapSession) cleanLastUserProfile() {
553-
if len(ms.lastUserProfile) < len(ms.peers)*2 {
554-
// Hasn't grown enough to be worth cleaning.
555-
return
556-
}
557-
558-
keep := set.Set[tailcfg.UserID]{}
559-
if node := ms.lastNode; node.Valid() {
560-
keep.Add(node.User())
561-
}
562-
for _, n := range ms.peers {
563-
keep.Add(n.User())
564-
keep.Add(n.Sharer())
565-
}
566-
for userID := range ms.lastUserProfile {
567-
if !keep.Contains(userID) {
568-
delete(ms.lastUserProfile, userID)
569-
}
570-
}
571-
}
572-
573544
var debugPatchifyPeer = envknob.RegisterBool("TS_DEBUG_PATCHIFY_PEER")
574545

575546
// patchifyPeersChanged mutates resp to promote PeersChanged entries to PeersChangedPatch

0 commit comments

Comments
 (0)