Skip to content

ts_control*, ts_runtime, etc: handle PeerChange, OnlineStatus, PeerSeen messages#185

Open
dylan-tailscale wants to merge 1 commit into
mainfrom
dylan/peer-patch
Open

ts_control*, ts_runtime, etc: handle PeerChange, OnlineStatus, PeerSeen messages#185
dylan-tailscale wants to merge 1 commit into
mainfrom
dylan/peer-patch

Conversation

@dylan-tailscale
Copy link
Copy Markdown
Collaborator

Applies peer updates from MapResponse::{peers_changed_patch, peer_seen_change, online_change} to the peer tracker's Node state. Introduces a number of types to ease handling of patch/delta updates, especially concerning online and last-seen timestamps. Updates order that delta changes are applied to match the Golang codebase.

Closes #41.

@dylan-tailscale dylan-tailscale self-assigned this May 19, 2026
@dylan-tailscale dylan-tailscale marked this pull request as ready for review May 20, 2026 22:24
Copy link
Copy Markdown
Collaborator

@npry npry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nits and questions, nonblocking — lgtm!

Comment thread ts_runtime/src/peer_tracker.rs Outdated
Comment thread ts_control/src/node.rs Outdated
Comment thread ts_control/src/node.rs
/// do not take into account differences between the control plane clock and local device clock. See
/// each variant for more information.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum NodeLastSeen {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nonblocking: why an enum rather than a struct? Mightn't we want to know both pieces of info?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm not sure I follow; I view NodeLastSeen::Control as definitive/correct, and NodeLastSeen::Estimated as a fallback for when the control plane doesn't tell us when it last saw the node (because it's using MapResponse::peer_seen_change to report it). In other words, I only see NodeLastSeen::Estimated as a rare last resort to give us something, albeit probably pretty inaccurate compared to Nodes with a populated NodeLastSeen::Control variant.

I can see us always calculating/storing an estimated timestamp when we receive an online/offline update for a Node just so we have a rough timestamp that's synced with the local device clock, although that timestamp won't take into account clock skew between the control plane/local device, nor transit delay for the message. This would at least give callers the ability to always compare NodeLastSeen values between Nodes using estimated timestamps...I guess it depends on the use case whether or not that's acceptable?

Lmk if I misunderstood - happy to change this to a struct if it's useful! Just want to make sure I understand the use case so I can properly document any caveats.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see it the other way, since NodeLastSeen::Control is intentionally obfuscated, so if I'm a user trying to implement some logic around when another peer was last reported online, it's kind of useless — I want to know the local point-in-time when we last saw control change the node's online status. Unless the point is that control delays those updates to 10m boundaries also? I assumed not but if so then this makes sense

Comment thread ts_control/src/node.rs Outdated
…ndle PeerChange, OnlineStatus, PeerSeen messages

Applies peer updates from MapResponse::{peers_changed_patch, peer_seen_change,
online_change} to the peer tracker's `Node` state. Introduces a number of
types to ease handling of patch/delta updates, especially concerning online
and last-seen timestamps. Updates order that delta updates are applied to match
the Golang codebase.

Signed-off-by: Dylan Bargatze <dylan@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ts_control: handle PeersChangedPatch, PeerSeenChange, and OnlineChange fields in netmap

2 participants