Skip to content

Commit

Permalink
cmd/tailscale/cli,ipn: mention available update in "tailscale status"
Browse files Browse the repository at this point in the history
Cache the last `ClientVersion` value that was received from coordination
server and pass it in the localapi `/status` response.
When running `tailscale status`, print a message if `RunningAsLatest` is
`false`.

Updates #6907

Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
  • Loading branch information
awly committed Sep 1, 2023
1 parent f7b7ccf commit 0d25ea1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/tailscale/cli/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ func runStatus(ctx context.Context, args []string) error {
printHealth()
}
printFunnelStatus(ctx)
if cv := st.ClientVersion; cv != nil && !cv.RunningLatest && cv.LatestVersion != "" {
printf("# New Tailscale version is available: %q, run `tailscale update` to update.\n", cv.LatestVersion)
}
return nil
}

Expand Down
7 changes: 7 additions & 0 deletions ipn/ipnlocal/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ type LocalBackend struct {
// at the moment that tkaSyncLock is taken).
tkaSyncLock sync.Mutex
clock tstime.Clock

// Last ClientVersion received in MapResponse, guarded by mu.
lastClientVersion *tailcfg.ClientVersion
}

// clientGen is a func that creates a control plane client.
Expand Down Expand Up @@ -664,6 +667,7 @@ func (b *LocalBackend) updateStatus(sb *ipnstate.StatusBuilder, extraLocked func
s.TUN = !b.sys.IsNetstack()
s.BackendState = b.state.String()
s.AuthURL = b.authURLSticky
s.ClientVersion = b.lastClientVersion
if err := health.OverallError(); err != nil {
switch e := err.(type) {
case multierr.Error:
Expand Down Expand Up @@ -2150,6 +2154,9 @@ func (b *LocalBackend) tellClientToBrowseToURL(url string) {
// onClientVersion is called on MapResponse updates when a MapResponse contains
// a non-nil ClientVersion message.
func (b *LocalBackend) onClientVersion(v *tailcfg.ClientVersion) {
b.mu.Lock()
b.lastClientVersion = v
b.mu.Unlock()
switch runtime.GOOS {
case "darwin", "ios":
// These auto-update well enough, and we haven't converted the
Expand Down
2 changes: 2 additions & 0 deletions ipn/ipnstate/ipnstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type Status struct {

Peer map[key.NodePublic]*PeerStatus
User map[tailcfg.UserID]tailcfg.UserProfile

ClientVersion *tailcfg.ClientVersion
}

// TKAKey describes a key trusted by network lock.
Expand Down

0 comments on commit 0d25ea1

Please sign in to comment.