Browse code

Add CgroupDriver to docker info

Fixes: #19539

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>

Qiang Huang authored on 2016/02/18 19:10:31
Showing 8 changed files
... ...
@@ -50,6 +50,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
50 50
 	}
51 51
 	ioutils.FprintfIfNotEmpty(cli.out, "Execution Driver: %s\n", info.ExecutionDriver)
52 52
 	ioutils.FprintfIfNotEmpty(cli.out, "Logging Driver: %s\n", info.LoggingDriver)
53
+	ioutils.FprintfIfNotEmpty(cli.out, "Cgroup Driver: %s\n", info.CgroupDriver)
53 54
 
54 55
 	fmt.Fprintf(cli.out, "Plugins: \n")
55 56
 	fmt.Fprintf(cli.out, " Volume:")
... ...
@@ -362,6 +362,14 @@ func verifyContainerResources(resources *containertypes.Resources, sysInfo *sysi
362 362
 	return warnings, nil
363 363
 }
364 364
 
365
+func (daemon *Daemon) getCgroupDriver() string {
366
+	cgroupDriver := "cgroupfs"
367
+	if daemon.usingSystemd() {
368
+		cgroupDriver = "systemd"
369
+	}
370
+	return cgroupDriver
371
+}
372
+
365 373
 func usingSystemd(config *Config) bool {
366 374
 	for _, option := range config.ExecOptions {
367 375
 		key, val, err := parsers.ParseKeyValueOpt(option)
... ...
@@ -65,6 +65,10 @@ func checkKernel() error {
65 65
 	return nil
66 66
 }
67 67
 
68
+func (daemon *Daemon) getCgroupDriver() string {
69
+	return ""
70
+}
71
+
68 72
 // adaptContainerSettings is called during container creation to modify any
69 73
 // settings necessary in the HostConfig structure.
70 74
 func (daemon *Daemon) adaptContainerSettings(hostConfig *containertypes.HostConfig, adjustCPUShares bool) error {
... ...
@@ -83,6 +83,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
83 83
 		SystemTime:         time.Now().Format(time.RFC3339Nano),
84 84
 		ExecutionDriver:    daemon.ExecutionDriver().Name(),
85 85
 		LoggingDriver:      daemon.defaultLogConfig.Type,
86
+		CgroupDriver:       daemon.getCgroupDriver(),
86 87
 		NEventsListener:    daemon.EventsService.SubscribersCount(),
87 88
 		KernelVersion:      kernelVersion,
88 89
 		OperatingSystem:    operatingSystem,
... ...
@@ -121,6 +121,7 @@ This section lists each version from latest to oldest.  Each listing includes a
121 121
 * `GET /networks/(name)` now returns an `EnableIPv6` field showing whether the network has ipv6 enabled or not.
122 122
 * `POST /containers/(name)/update` now supports updating container's restart policy.
123 123
 * `POST /networks/create` now supports enabling ipv6 on the network by setting the `EnableIPv6` field (doing this with a label will no longer work).
124
+* `GET /info` now returns `CgroupDriver` field showing what cgroup driver the daemon is using; `cgroupfs` or `systemd`.
124 125
 
125 126
 ### v1.22 API changes
126 127
 
... ...
@@ -2128,6 +2128,7 @@ Display system-wide information
2128 2128
 
2129 2129
     {
2130 2130
         "Architecture": "x86_64",
2131
+        "CgroupDriver": "cgroupfs",
2131 2132
         "Containers": 11,
2132 2133
         "ContainersRunning": 7,
2133 2134
         "ContainersStopped": 3,
... ...
@@ -33,6 +33,7 @@ For example:
33 33
      Dirperm1 Supported: true
34 34
     Execution Driver: native-0.2
35 35
     Logging Driver: json-file
36
+    Cgroup Driver: cgroupfs
36 37
     Plugins:
37 38
      Volume: local
38 39
      Network: bridge null host
... ...
@@ -42,6 +42,7 @@ Here is a sample output:
42 42
      Dirs: 80
43 43
     Execution Driver: native-0.2
44 44
     Logging Driver: json-file
45
+    Cgroup Driver: cgroupfs
45 46
     Plugins:
46 47
      Volume: local
47 48
      Network: bridge null host