Skip to content

Commit

Permalink
Merge pull request #43901 from thaJeztah/libcontainerd_cleanup_superv…
Browse files Browse the repository at this point in the history
…isor

libcontainerd/supervisor: clean up (dead) code
  • Loading branch information
cpuguy83 committed Aug 9, 2022
2 parents ad8d255 + 051e604 commit c8fc989
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 51 deletions.
14 changes: 13 additions & 1 deletion cmd/dockerd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,19 @@ func (cli *DaemonCli) getContainerdDaemonOpts() ([]supervisor.DaemonOpt, error)
}

if !cli.Config.CriContainerd {
opts = append(opts, supervisor.WithPlugin("io.containerd.grpc.v1.cri", nil))
// CRI support in the managed daemon is currently opt-in.
//
// It's disabled by default, originally because it was listening on
// a TCP connection at 0.0.0.0:10010, which was considered a security
// risk, and could conflict with user's container ports.
//
// Current versions of containerd started now listen on localhost on
// an ephemeral port instead, but could still conflict with container
// ports, and running kubernetes using the static binaries is not a
// common scenario, so we (for now) continue disabling it by default.
//
// Also see https://github.com/containerd/containerd/issues/2483#issuecomment-407530608
opts = append(opts, supervisor.WithCRIDisabled())
}

return opts, nil
Expand Down
3 changes: 0 additions & 3 deletions libcontainerd/supervisor/remote_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const (
type remote struct {
sync.RWMutex
config.Config
// Plugins overrides `Plugins map[string]toml.Tree` in config config.
Plugins map[string]interface{} `toml:"plugins"`

daemonPid int
logger *logrus.Entry
Expand Down Expand Up @@ -66,7 +64,6 @@ func Start(ctx context.Context, rootDir, stateDir string, opts ...DaemonOpt) (Da
Root: filepath.Join(rootDir, "daemon"),
State: filepath.Join(stateDir, "daemon"),
},
Plugins: make(map[string]interface{}),
daemonPid: -1,
logger: logrus.WithField("module", "libcontainerd"),
daemonStartCh: make(chan error, 1),
Expand Down
7 changes: 0 additions & 7 deletions libcontainerd/supervisor/remote_daemon_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ func (r *remote) setDefaults() {
if r.Debug.Address == "" {
r.Debug.Address = filepath.Join(r.stateDir, debugSockFile)
}

for key, conf := range r.Plugins {
if conf == nil {
r.DisabledPlugins = append(r.DisabledPlugins, key)
delete(r.Plugins, key)
}
}
}

func (r *remote) stopDaemon() {
Expand Down
43 changes: 3 additions & 40 deletions libcontainerd/supervisor/remote_daemon_options.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"

// WithRemoteAddr sets the external containerd socket to connect to.
func WithRemoteAddr(addr string) DaemonOpt {
return func(r *remote) error {
r.GRPC.Address = addr
return nil
}
}

// WithRemoteAddrUser sets the uid and gid to create the RPC address with
func WithRemoteAddrUser(uid, gid int) DaemonOpt {
return func(r *remote) error {
r.GRPC.UID = uid
r.GRPC.GID = gid
return nil
}
}

// WithLogLevel defines which log level to starts containerd with.
// This only makes sense if WithStartDaemon() was set to true.
func WithLogLevel(lvl string) DaemonOpt {
Expand All @@ -26,30 +9,10 @@ func WithLogLevel(lvl string) DaemonOpt {
}
}

// WithDebugAddress defines at which location the debug GRPC connection
// should be made
func WithDebugAddress(addr string) DaemonOpt {
return func(r *remote) error {
r.Debug.Address = addr
return nil
}
}

// WithMetricsAddress defines at which location the debug GRPC connection
// should be made
func WithMetricsAddress(addr string) DaemonOpt {
return func(r *remote) error {
r.Metrics.Address = addr
return nil
}
}

// WithPlugin allow configuring a containerd plugin
// configuration values passed needs to be quoted if quotes are needed in
// the toml format.
func WithPlugin(name string, conf interface{}) DaemonOpt {
// WithCRIDisabled disables the CRI plugin.
func WithCRIDisabled() DaemonOpt {
return func(r *remote) error {
r.Plugins[name] = conf
r.DisabledPlugins = append(r.DisabledPlugins, "io.containerd.grpc.v1.cri")
return nil
}
}

0 comments on commit c8fc989

Please sign in to comment.