Browse Source

info: report cgroup driver as "none" when running rootless

Previously `docker info` had reported "cgroupfs" as the cgroup driver
but the driver wasn't actually used at all.

This PR reports "none" as the cgroup driver so as to avoid confusion.
e.g. kubeadm/kubelet will detect cgroupless-ness by checking this docker
info field. https://github.com/rootless-containers/usernetes/pull/97

Note that user still cannot specify `native.cgroupdriver=none` manually.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
(cherry picked from commit 153466ba0ac21d6971ca05cdaef19c33bae4204c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Akihiro Suda 6 years ago
parent
commit
57b59f876e
1 changed files with 7 additions and 0 deletions
  1. 7 0
      daemon/daemon_unix.go

+ 7 - 0
daemon/daemon_unix.go

@@ -73,6 +73,7 @@ const (
 	// constant for cgroup drivers
 	// constant for cgroup drivers
 	cgroupFsDriver      = "cgroupfs"
 	cgroupFsDriver      = "cgroupfs"
 	cgroupSystemdDriver = "systemd"
 	cgroupSystemdDriver = "systemd"
+	cgroupNoneDriver    = "none"
 
 
 	// DefaultRuntimeName is the default runtime to be used by
 	// DefaultRuntimeName is the default runtime to be used by
 	// containerd if none is specified
 	// containerd if none is specified
@@ -575,6 +576,9 @@ func verifyPlatformContainerResources(resources *containertypes.Resources, sysIn
 }
 }
 
 
 func (daemon *Daemon) getCgroupDriver() string {
 func (daemon *Daemon) getCgroupDriver() string {
+	if daemon.Rootless() {
+		return cgroupNoneDriver
+	}
 	cgroupDriver := cgroupFsDriver
 	cgroupDriver := cgroupFsDriver
 
 
 	if UsingSystemd(daemon.configStore) {
 	if UsingSystemd(daemon.configStore) {
@@ -601,6 +605,9 @@ func VerifyCgroupDriver(config *config.Config) error {
 	if cd == "" || cd == cgroupFsDriver || cd == cgroupSystemdDriver {
 	if cd == "" || cd == cgroupFsDriver || cd == cgroupSystemdDriver {
 		return nil
 		return nil
 	}
 	}
+	if cd == cgroupNoneDriver {
+		return fmt.Errorf("native.cgroupdriver option %s is internally used and cannot be specified manually", cd)
+	}
 	return fmt.Errorf("native.cgroupdriver option %s not supported", cd)
 	return fmt.Errorf("native.cgroupdriver option %s not supported", cd)
 }
 }