diff --git a/libcontainerd/client_daemon.go b/libcontainerd/client_daemon.go index 2c914469a1..8ed8091bd6 100644 --- a/libcontainerd/client_daemon.go +++ b/libcontainerd/client_daemon.go @@ -114,6 +114,13 @@ type client struct { containers map[string]*container } +func (c *client) reconnect() error { + c.Lock() + err := c.remote.Reconnect() + c.Unlock() + return err +} + func (c *client) setRemote(remote *containerd.Client) { c.Lock() c.remote = remote diff --git a/libcontainerd/remote_daemon.go b/libcontainerd/remote_daemon.go index 35ccc0e4a9..4e8d420f3b 100644 --- a/libcontainerd/remote_daemon.go +++ b/libcontainerd/remote_daemon.go @@ -309,20 +309,17 @@ func (r *remote) monitorConnection(monitor *containerd.Client) { } <-r.daemonWaitCh - monitor.Close() os.Remove(r.GRPC.Address) if err := r.startContainerd(); err != nil { r.logger.WithError(err).Error("failed restarting containerd") continue } - newMonitor, err := containerd.New(r.GRPC.Address) - if err != nil { + if err := monitor.Reconnect(); err != nil { r.logger.WithError(err).Error("failed connect to containerd") continue } - monitor = newMonitor var wg sync.WaitGroup for _, c := range r.clients { @@ -331,18 +328,12 @@ func (r *remote) monitorConnection(monitor *containerd.Client) { go func(c *client) { defer wg.Done() c.logger.WithField("namespace", c.namespace).Debug("creating new containerd remote client") - c.remote.Close() - - remote, err := containerd.New(r.GRPC.Address, containerd.WithDefaultNamespace(c.namespace)) - if err != nil { + if err := c.reconnect(); err != nil { r.logger.WithError(err).Error("failed to connect to containerd") // TODO: Better way to handle this? // This *shouldn't* happen, but this could wind up where the daemon // is not able to communicate with an eventually up containerd - return } - - c.setRemote(remote) }(c) wg.Wait() diff --git a/libcontainerd/remote_daemon_options_linux.go b/libcontainerd/remote_daemon_options_linux.go index 24ef5a5a4b..a820fb3894 100644 --- a/libcontainerd/remote_daemon_options_linux.go +++ b/libcontainerd/remote_daemon_options_linux.go @@ -16,19 +16,3 @@ func (o oomScore) Apply(r Remote) error { } return fmt.Errorf("WithOOMScore option not supported for this remote") } - -// WithSubreaper sets whether containerd should register itself as a -// subreaper -func WithSubreaper(reap bool) RemoteOption { - return subreaper(reap) -} - -type subreaper bool - -func (s subreaper) Apply(r Remote) error { - if remote, ok := r.(*remote); ok { - remote.NoSubreaper = !bool(s) - return nil - } - return fmt.Errorf("WithSubreaper option not supported for this remote") -}