mirror of
https://github.com/tailscale/tailscale.git
synced 2025-06-10 17:58:38 +00:00
tsnet: remove an expired configuration-path migration step (#16120)
As note in the comment, it now being more than six months since this was deprecated and there being no (further) uses of the old pattern in our internal services, let's drop the migrator. Updates #cleanup Change-Id: Ie4fb9518b2ca04a9b361e09c51cbbacf1e2633a8 Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
This commit is contained in:
parent
5e54819cee
commit
36df320e6a
@ -536,10 +536,7 @@ func (s *Server) start() (reterr error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.rootPath, err = getTSNetDir(s.logf, confDir, prog)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.rootPath = filepath.Join(confDir, "tsnet-"+prog)
|
||||
}
|
||||
if err := os.MkdirAll(s.rootPath, 0700); err != nil {
|
||||
return err
|
||||
@ -897,49 +894,6 @@ func (s *Server) getUDPHandlerForFlow(src, dst netip.AddrPort) (handler func(net
|
||||
return func(c nettype.ConnPacketConn) { ln.handle(c) }, true
|
||||
}
|
||||
|
||||
// getTSNetDir usually just returns filepath.Join(confDir, "tsnet-"+prog)
|
||||
// with no error.
|
||||
//
|
||||
// One special case is that it renames old "tslib-" directories to
|
||||
// "tsnet-", and that rename might return an error.
|
||||
//
|
||||
// TODO(bradfitz): remove this maybe 6 months after 2022-03-17,
|
||||
// once people (notably Tailscale corp services) have updated.
|
||||
func getTSNetDir(logf logger.Logf, confDir, prog string) (string, error) {
|
||||
oldPath := filepath.Join(confDir, "tslib-"+prog)
|
||||
newPath := filepath.Join(confDir, "tsnet-"+prog)
|
||||
|
||||
fi, err := os.Lstat(oldPath)
|
||||
if os.IsNotExist(err) {
|
||||
// Common path.
|
||||
return newPath, nil
|
||||
}
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if !fi.IsDir() {
|
||||
return "", fmt.Errorf("expected old tslib path %q to be a directory; got %v", oldPath, fi.Mode())
|
||||
}
|
||||
|
||||
// At this point, oldPath exists and is a directory. But does
|
||||
// the new path exist?
|
||||
|
||||
fi, err = os.Lstat(newPath)
|
||||
if err == nil && fi.IsDir() {
|
||||
// New path already exists somehow. Ignore the old one and
|
||||
// don't try to migrate it.
|
||||
return newPath, nil
|
||||
}
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return "", err
|
||||
}
|
||||
if err := os.Rename(oldPath, newPath); err != nil {
|
||||
return "", err
|
||||
}
|
||||
logf("renamed old tsnet state storage directory %q to %q", oldPath, newPath)
|
||||
return newPath, nil
|
||||
}
|
||||
|
||||
// APIClient returns a tailscale.Client that can be used to make authenticated
|
||||
// requests to the Tailscale control server.
|
||||
// It requires the user to set tailscale.I_Acknowledge_This_API_Is_Unstable.
|
||||
|
Loading…
x
Reference in New Issue
Block a user