feature/featuretags: make CLI connection error diagnostics modular
Updates #12614 Change-Id: I09b8944166ee00910b402bcd5725cd7969e2c82c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
11b770fbc9
commit
7bcab4ab28
@@ -87,7 +87,7 @@ tailscale.com/cmd/derper dependencies: (generated by github.com/tailscale/depawa
|
||||
tailscale.com/disco from tailscale.com/derp/derpserver
|
||||
tailscale.com/drive from tailscale.com/client/local+
|
||||
tailscale.com/envknob from tailscale.com/client/local+
|
||||
tailscale.com/feature from tailscale.com/tsweb
|
||||
tailscale.com/feature from tailscale.com/tsweb+
|
||||
tailscale.com/health from tailscale.com/net/tlsdial+
|
||||
tailscale.com/hostinfo from tailscale.com/net/netmon+
|
||||
tailscale.com/ipn from tailscale.com/client/local
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"tailscale.com/client/local"
|
||||
"tailscale.com/cmd/tailscale/cli/ffcomplete"
|
||||
"tailscale.com/envknob"
|
||||
"tailscale.com/feature"
|
||||
"tailscale.com/paths"
|
||||
"tailscale.com/util/slicesx"
|
||||
"tailscale.com/version/distro"
|
||||
@@ -555,3 +556,12 @@ func lastSeenFmt(t time.Time) string {
|
||||
return fmt.Sprintf(", last seen %dd ago", int(d.Hours()/24))
|
||||
}
|
||||
}
|
||||
|
||||
var hookFixTailscaledConnectError feature.Hook[func(error) error] // for cliconndiag
|
||||
|
||||
func fixTailscaledConnectError(origErr error) error {
|
||||
if f, ok := hookFixTailscaledConnectError.GetOk(); ok {
|
||||
return f(origErr)
|
||||
}
|
||||
return origErr
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build linux || windows || darwin
|
||||
//go:build (linux || windows || darwin) && !ts_omit_cliconndiag
|
||||
|
||||
package cli
|
||||
|
||||
@@ -16,11 +16,15 @@ import (
|
||||
"tailscale.com/version/distro"
|
||||
)
|
||||
|
||||
// fixTailscaledConnectError is called when the local tailscaled has
|
||||
func init() {
|
||||
hookFixTailscaledConnectError.Set(fixTailscaledConnectErrorImpl)
|
||||
}
|
||||
|
||||
// fixTailscaledConnectErrorImpl is called when the local tailscaled has
|
||||
// been determined unreachable due to the provided origErr value. It
|
||||
// returns either the same error or a better one to help the user
|
||||
// understand why tailscaled isn't running for their platform.
|
||||
func fixTailscaledConnectError(origErr error) error {
|
||||
func fixTailscaledConnectErrorImpl(origErr error) error {
|
||||
procs, err := ps.Processes()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect to local Tailscaled process and failed to enumerate processes while looking for it")
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !linux && !windows && !darwin
|
||||
|
||||
package cli
|
||||
|
||||
import "fmt"
|
||||
|
||||
// The github.com/mitchellh/go-ps package doesn't work on all platforms,
|
||||
// so just don't diagnose connect failures.
|
||||
|
||||
func fixTailscaledConnectError(origErr error) error {
|
||||
return fmt.Errorf("failed to connect to local tailscaled process (is it running?); got: %w", origErr)
|
||||
}
|
||||
@@ -35,7 +35,6 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
github.com/mdlayher/netlink/nltest from github.com/google/nftables
|
||||
github.com/mdlayher/sdnotify from tailscale.com/util/systemd
|
||||
💣 github.com/mdlayher/socket from github.com/mdlayher/netlink+
|
||||
github.com/mitchellh/go-ps from tailscale.com/safesocket
|
||||
💣 github.com/safchain/ethtool from tailscale.com/net/netkernelconf
|
||||
github.com/tailscale/hujson from tailscale.com/ipn/conffile
|
||||
💣 github.com/tailscale/netlink from tailscale.com/util/linuxfw+
|
||||
|
||||
Reference in New Issue
Block a user