File: reload_unix.go

package info (click to toggle)
docker.io 27.5.1%2Bdfsg4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 67,384 kB
  • sloc: sh: 5,847; makefile: 1,146; ansic: 664; python: 162; asm: 133
file content (54 lines) | stat: -rw-r--r-- 1,428 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//go:build linux || freebsd

package daemon // import "github.com/docker/docker/daemon"

import (
	"bytes"
	"strconv"

	"github.com/docker/docker/daemon/config"
)

// reloadPlatform updates configuration with platform specific options
// and updates the passed attributes
func (daemon *Daemon) reloadPlatform(txn *reloadTxn, newCfg *configStore, conf *config.Config, attributes map[string]string) error {
	if conf.DefaultRuntime != "" {
		newCfg.DefaultRuntime = conf.DefaultRuntime
	}
	if conf.IsValueSet("runtimes") {
		newCfg.Config.Runtimes = conf.Runtimes
	}
	var err error
	newCfg.Runtimes, err = setupRuntimes(&newCfg.Config)
	if err != nil {
		return err
	}

	if conf.IsValueSet("default-shm-size") {
		newCfg.ShmSize = conf.ShmSize
	}

	if conf.CgroupNamespaceMode != "" {
		newCfg.CgroupNamespaceMode = conf.CgroupNamespaceMode
	}

	if conf.IpcMode != "" {
		newCfg.IpcMode = conf.IpcMode
	}

	// Update attributes
	var runtimeList bytes.Buffer
	for name, rt := range newCfg.Config.Runtimes {
		if runtimeList.Len() > 0 {
			runtimeList.WriteRune(' ')
		}
		runtimeList.WriteString(name + ":" + rt.Path)
	}

	attributes["runtimes"] = runtimeList.String()
	attributes["default-runtime"] = newCfg.DefaultRuntime
	attributes["default-shm-size"] = strconv.FormatInt(int64(newCfg.ShmSize), 10)
	attributes["default-ipc-mode"] = newCfg.IpcMode
	attributes["default-cgroupns-mode"] = newCfg.CgroupNamespaceMode
	return nil
}