cli/web: don't block startup on status req

If the status request to check for the preview node cap fails,
continue with starting up the legacy client.

Updates tailscale/corp#14335

Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
pull/10143/head
Sonia Appasamy 1 year ago committed by Sonia Appasamy
parent 7df2c5d6b1
commit 942d720a16

@ -13,6 +13,7 @@ import (
"net" "net"
"net/http" "net/http"
"net/http/cgi" "net/http/cgi"
"net/netip"
"os" "os"
"os/signal" "os/signal"
"strings" "strings"
@ -84,11 +85,13 @@ func runWeb(ctx context.Context, args []string) error {
return fmt.Errorf("too many non-flag arguments: %q", args) return fmt.Errorf("too many non-flag arguments: %q", args)
} }
var hasPreviewCap bool
var selfIP netip.Addr
st, err := localClient.StatusWithoutPeers(ctx) st, err := localClient.StatusWithoutPeers(ctx)
if err != nil { if err == nil && st.Self != nil && len(st.Self.TailscaleIPs) > 0 {
return fmt.Errorf("getting client status: %w", err) hasPreviewCap = st.Self.HasCap(tailcfg.CapabilityPreviewWebClient)
selfIP = st.Self.TailscaleIPs[0]
} }
hasPreviewCap := st.Self.HasCap(tailcfg.CapabilityPreviewWebClient)
cliServerMode := web.LegacyServerMode cliServerMode := web.LegacyServerMode
var existingWebClient bool var existingWebClient bool
@ -99,7 +102,7 @@ func runWeb(ctx context.Context, args []string) error {
cliServerMode = web.LoginServerMode cliServerMode = web.LoginServerMode
if !existingWebClient { if !existingWebClient {
// Also start full client in tailscaled. // Also start full client in tailscaled.
log.Printf("starting tailscaled web client at %s:5252\n", st.Self.TailscaleIPs[0]) log.Printf("starting tailscaled web client at %s:%d\n", selfIP.String(), web.ListenPort)
if err := setRunWebClient(ctx, true); err != nil { if err := setRunWebClient(ctx, true); err != nil {
return fmt.Errorf("starting web client in tailscaled: %w", err) return fmt.Errorf("starting web client in tailscaled: %w", err)
} }

Loading…
Cancel
Save