ipn, paths, cmd/tailscaled: remove LegacyConfigPath, relaynode migration

It is time.

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/1677/head
Brad Fitzpatrick 4 years ago committed by Brad Fitzpatrick
parent d581ee2536
commit 950fc28887

@ -295,7 +295,6 @@ func run() error {
Port: 41112, Port: 41112,
StatePath: args.statepath, StatePath: args.statepath,
AutostartStateKey: globalStateKey, AutostartStateKey: globalStateKey,
LegacyConfigPath: paths.LegacyConfigPath(),
SurviveDisconnects: true, SurviveDisconnects: true,
DebugMux: debugMux, DebugMux: debugMux,
} }

@ -113,14 +113,6 @@ type Options struct {
// AuthKey is an optional node auth key used to authorize a // AuthKey is an optional node auth key used to authorize a
// new node key without user interaction. // new node key without user interaction.
AuthKey string AuthKey string
// LegacyConfigPath optionally specifies the old-style relaynode
// relay.conf location. If both LegacyConfigPath and StateKey are
// specified and the requested state doesn't exist in the backend
// store, the backend migrates the config from LegacyConfigPath.
//
// TODO(danderson): remove some time after the transition to
// tailscaled is done.
LegacyConfigPath string
} }
// Backend is the interface between Tailscale frontends // Backend is the interface between Tailscale frontends

@ -595,7 +595,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
b.hostinfo = hostinfo b.hostinfo = hostinfo
b.state = ipn.NoState b.state = ipn.NoState
if err := b.loadStateLocked(opts.StateKey, opts.Prefs, opts.LegacyConfigPath); err != nil { if err := b.loadStateLocked(opts.StateKey, opts.Prefs); err != nil {
b.mu.Unlock() b.mu.Unlock()
return fmt.Errorf("loading requested state: %v", err) return fmt.Errorf("loading requested state: %v", err)
} }
@ -1078,7 +1078,7 @@ func (b *LocalBackend) writeServerModeStartState(userID string, prefs *ipn.Prefs
// loadStateLocked sets b.prefs and b.stateKey based on a complex // loadStateLocked sets b.prefs and b.stateKey based on a complex
// combination of key, prefs, and legacyPath. b.mu must be held when // combination of key, prefs, and legacyPath. b.mu must be held when
// calling. // calling.
func (b *LocalBackend) loadStateLocked(key ipn.StateKey, prefs *ipn.Prefs, legacyPath string) (err error) { func (b *LocalBackend) loadStateLocked(key ipn.StateKey, prefs *ipn.Prefs) (err error) {
if prefs == nil && key == "" { if prefs == nil && key == "" {
panic("state key and prefs are both unset") panic("state key and prefs are both unset")
} }
@ -1118,24 +1118,9 @@ func (b *LocalBackend) loadStateLocked(key ipn.StateKey, prefs *ipn.Prefs, legac
bs, err := b.store.ReadState(key) bs, err := b.store.ReadState(key)
switch { switch {
case errors.Is(err, ipn.ErrStateNotExist): case errors.Is(err, ipn.ErrStateNotExist):
loaded := false b.prefs = ipn.NewPrefs()
if legacyPath != "" { b.prefs.WantRunning = false
b.prefs, err = ipn.LoadPrefs(legacyPath) b.logf("created empty state for %q: %s", key, b.prefs.Pretty())
switch {
case errors.Is(err, os.ErrNotExist):
// Quiet. Normal case.
case err != nil:
b.logf("failed to load legacy prefs: %v", err)
default:
loaded = true
b.logf("imported prefs from relaynode for %q: %v", key, b.prefs.Pretty())
}
}
if !loaded {
b.prefs = ipn.NewPrefs()
b.prefs.WantRunning = false
b.logf("created empty state for %q: %s", key, b.prefs.Pretty())
}
return nil return nil
case err != nil: case err != nil:
return fmt.Errorf("store.ReadState(%q): %v", key, err) return fmt.Errorf("store.ReadState(%q): %v", key, err)

@ -63,16 +63,6 @@ type Options struct {
// waits for a frontend to start it. // waits for a frontend to start it.
AutostartStateKey ipn.StateKey AutostartStateKey ipn.StateKey
// LegacyConfigPath optionally specifies the old-style relaynode
// relay.conf location. If both LegacyConfigPath and
// AutostartStateKey are specified and the requested state doesn't
// exist in the backend store, the backend migrates the config
// from LegacyConfigPath.
//
// TODO(danderson): remove some time after the transition to
// tailscaled is done.
LegacyConfigPath string
// SurviveDisconnects specifies how the server reacts to its // SurviveDisconnects specifies how the server reacts to its
// frontend disconnecting. If true, the server keeps running on // frontend disconnecting. If true, the server keeps running on
// its existing state, and accepts new frontend connections. If // its existing state, and accepts new frontend connections. If
@ -754,10 +744,7 @@ func Run(ctx context.Context, logf logger.Logf, logid string, getEngine func() (
server.bs.GotCommand(context.TODO(), &ipn.Command{ server.bs.GotCommand(context.TODO(), &ipn.Command{
Version: version.Long, Version: version.Long,
Start: &ipn.StartArgs{ Start: &ipn.StartArgs{
Opts: ipn.Options{ Opts: ipn.Options{StateKey: opts.AutostartStateKey},
StateKey: opts.AutostartStateKey,
LegacyConfigPath: opts.LegacyConfigPath,
},
}, },
}) })
} }

@ -17,16 +17,6 @@ import (
// containing a directory we can read/write in. // containing a directory we can read/write in.
var IOSSharedDir atomic.Value var IOSSharedDir atomic.Value
// LegacyConfigPath returns the path used by the pre-tailscaled
// "relaynode" daemon's config file. It returns the empty string for
// platforms where relaynode never ran.
func LegacyConfigPath() string {
if runtime.GOOS == "windows" {
return ""
}
return "/var/lib/tailscale/relay.conf"
}
// DefaultTailscaledSocket returns the path to the tailscaled Unix socket // DefaultTailscaledSocket returns the path to the tailscaled Unix socket
// or the empty string if there's no reasonable default. // or the empty string if there's no reasonable default.
func DefaultTailscaledSocket() string { func DefaultTailscaledSocket() string {

Loading…
Cancel
Save