From 950fc28887b639ff5056582fc72d074a64ff9bde Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 7 Apr 2021 09:33:14 -0700 Subject: [PATCH] ipn, paths, cmd/tailscaled: remove LegacyConfigPath, relaynode migration It is time. Signed-off-by: Brad Fitzpatrick --- cmd/tailscaled/tailscaled.go | 1 - ipn/backend.go | 8 -------- ipn/ipnlocal/local.go | 25 +++++-------------------- ipn/ipnserver/server.go | 15 +-------------- paths/paths.go | 10 ---------- 5 files changed, 6 insertions(+), 53 deletions(-) diff --git a/cmd/tailscaled/tailscaled.go b/cmd/tailscaled/tailscaled.go index 13c4fa309..91edab654 100644 --- a/cmd/tailscaled/tailscaled.go +++ b/cmd/tailscaled/tailscaled.go @@ -295,7 +295,6 @@ func run() error { Port: 41112, StatePath: args.statepath, AutostartStateKey: globalStateKey, - LegacyConfigPath: paths.LegacyConfigPath(), SurviveDisconnects: true, DebugMux: debugMux, } diff --git a/ipn/backend.go b/ipn/backend.go index d86756501..ae5f9dc12 100644 --- a/ipn/backend.go +++ b/ipn/backend.go @@ -113,14 +113,6 @@ type Options struct { // AuthKey is an optional node auth key used to authorize a // new node key without user interaction. 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 diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 250ba8d90..3e05c155f 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -595,7 +595,7 @@ func (b *LocalBackend) Start(opts ipn.Options) error { b.hostinfo = hostinfo 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() 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 // combination of key, prefs, and legacyPath. b.mu must be held when // 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 == "" { 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) switch { case errors.Is(err, ipn.ErrStateNotExist): - loaded := false - if legacyPath != "" { - b.prefs, err = ipn.LoadPrefs(legacyPath) - 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()) - } + b.prefs = ipn.NewPrefs() + b.prefs.WantRunning = false + b.logf("created empty state for %q: %s", key, b.prefs.Pretty()) return nil case err != nil: return fmt.Errorf("store.ReadState(%q): %v", key, err) diff --git a/ipn/ipnserver/server.go b/ipn/ipnserver/server.go index 54e094806..c1faeb141 100644 --- a/ipn/ipnserver/server.go +++ b/ipn/ipnserver/server.go @@ -63,16 +63,6 @@ type Options struct { // waits for a frontend to start it. 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 // frontend disconnecting. If true, the server keeps running on // 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{ Version: version.Long, Start: &ipn.StartArgs{ - Opts: ipn.Options{ - StateKey: opts.AutostartStateKey, - LegacyConfigPath: opts.LegacyConfigPath, - }, + Opts: ipn.Options{StateKey: opts.AutostartStateKey}, }, }) } diff --git a/paths/paths.go b/paths/paths.go index 32ed6c22e..2f0ea7c93 100644 --- a/paths/paths.go +++ b/paths/paths.go @@ -17,16 +17,6 @@ // containing a directory we can read/write in. 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 // or the empty string if there's no reasonable default. func DefaultTailscaledSocket() string {