Merge pull request #25890 from cpuguy83/fix_swarm_control_sock_path
Use daemon exec root for swarm control socket
This commit is contained in:
commit
edafc642b2
|
@ -256,6 +256,7 @@ func (cli *DaemonCli) start(opts daemonOptions) (err error) {
|
||||||
Backend: d,
|
Backend: d,
|
||||||
NetworkSubnetsProvider: d,
|
NetworkSubnetsProvider: d,
|
||||||
DefaultAdvertiseAddr: cli.Config.SwarmDefaultAdvertiseAddr,
|
DefaultAdvertiseAddr: cli.Config.SwarmDefaultAdvertiseAddr,
|
||||||
|
RuntimeRoot: cli.getSwarmRunRoot(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("Error creating cluster component: %v", err)
|
logrus.Fatalf("Error creating cluster component: %v", err)
|
||||||
|
|
|
@ -61,6 +61,12 @@ func (cli *DaemonCli) getLibcontainerdRoot() string {
|
||||||
return filepath.Join(cli.Config.ExecRoot, "libcontainerd")
|
return filepath.Join(cli.Config.ExecRoot, "libcontainerd")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getSwarmRunRoot gets the root directory for swarm to store runtime state
|
||||||
|
// For example, the control socket
|
||||||
|
func (cli *DaemonCli) getSwarmRunRoot() string {
|
||||||
|
return filepath.Join(cli.Config.ExecRoot, "swarm")
|
||||||
|
}
|
||||||
|
|
||||||
func allocateDaemonPort(addr string) error {
|
func allocateDaemonPort(addr string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,12 @@ func (cli *DaemonCli) getLibcontainerdRoot() string {
|
||||||
return filepath.Join(cli.Config.ExecRoot, "libcontainerd")
|
return filepath.Join(cli.Config.ExecRoot, "libcontainerd")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getSwarmRunRoot gets the root directory for swarm to store runtime state
|
||||||
|
// For example, the control socket
|
||||||
|
func (cli *DaemonCli) getSwarmRunRoot() string {
|
||||||
|
return filepath.Join(cli.Config.ExecRoot, "swarm")
|
||||||
|
}
|
||||||
|
|
||||||
// allocateDaemonPort ensures that there are no containers
|
// allocateDaemonPort ensures that there are no containers
|
||||||
// that try to use any port allocated for the docker server.
|
// that try to use any port allocated for the docker server.
|
||||||
func allocateDaemonPort(addr string) error {
|
func allocateDaemonPort(addr string) error {
|
||||||
|
|
|
@ -73,6 +73,12 @@ func (cli *DaemonCli) getLibcontainerdRoot() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getSwarmRunRoot gets the root directory for swarm to store runtime state
|
||||||
|
// For example, the control socket
|
||||||
|
func (cli *DaemonCli) getSwarmRunRoot() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func allocateDaemonPort(addr string) error {
|
func allocateDaemonPort(addr string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,6 +103,9 @@ type Config struct {
|
||||||
// DefaultAdvertiseAddr is the default host/IP or network interface to use
|
// DefaultAdvertiseAddr is the default host/IP or network interface to use
|
||||||
// if no AdvertiseAddr value is specified.
|
// if no AdvertiseAddr value is specified.
|
||||||
DefaultAdvertiseAddr string
|
DefaultAdvertiseAddr string
|
||||||
|
|
||||||
|
// path to store runtime state, such as the swarm control socket
|
||||||
|
RuntimeRoot string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cluster provides capabilities to participate in a cluster as a worker or a
|
// Cluster provides capabilities to participate in a cluster as a worker or a
|
||||||
|
@ -111,6 +114,7 @@ type Cluster struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
*node
|
*node
|
||||||
root string
|
root string
|
||||||
|
runtimeRoot string
|
||||||
config Config
|
config Config
|
||||||
configEvent chan struct{} // todo: make this array and goroutine safe
|
configEvent chan struct{} // todo: make this array and goroutine safe
|
||||||
localAddr string
|
localAddr string
|
||||||
|
@ -138,10 +142,17 @@ func New(config Config) (*Cluster, error) {
|
||||||
if err := os.MkdirAll(root, 0700); err != nil {
|
if err := os.MkdirAll(root, 0700); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if config.RuntimeRoot == "" {
|
||||||
|
config.RuntimeRoot = root
|
||||||
|
}
|
||||||
|
if err := os.MkdirAll(config.RuntimeRoot, 0700); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
c := &Cluster{
|
c := &Cluster{
|
||||||
root: root,
|
root: root,
|
||||||
config: config,
|
config: config,
|
||||||
configEvent: make(chan struct{}, 10),
|
configEvent: make(chan struct{}, 10),
|
||||||
|
runtimeRoot: config.RuntimeRoot,
|
||||||
}
|
}
|
||||||
|
|
||||||
st, err := c.loadState()
|
st, err := c.loadState()
|
||||||
|
@ -275,7 +286,7 @@ func (c *Cluster) startNewNode(forceNewCluster bool, localAddr, remoteAddr, list
|
||||||
n, err := swarmagent.NewNode(&swarmagent.NodeConfig{
|
n, err := swarmagent.NewNode(&swarmagent.NodeConfig{
|
||||||
Hostname: c.config.Name,
|
Hostname: c.config.Name,
|
||||||
ForceNewCluster: forceNewCluster,
|
ForceNewCluster: forceNewCluster,
|
||||||
ListenControlAPI: filepath.Join(c.root, controlSocket),
|
ListenControlAPI: filepath.Join(c.runtimeRoot, controlSocket),
|
||||||
ListenRemoteAPI: listenAddr,
|
ListenRemoteAPI: listenAddr,
|
||||||
AdvertiseRemoteAPI: advertiseAddr,
|
AdvertiseRemoteAPI: advertiseAddr,
|
||||||
JoinAddr: joinAddr,
|
JoinAddr: joinAddr,
|
||||||
|
|
|
@ -42,6 +42,7 @@ type Daemon struct {
|
||||||
userlandProxy bool
|
userlandProxy bool
|
||||||
useDefaultHost bool
|
useDefaultHost bool
|
||||||
useDefaultTLSHost bool
|
useDefaultTLSHost bool
|
||||||
|
execRoot string
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientConfig struct {
|
type clientConfig struct {
|
||||||
|
@ -82,6 +83,7 @@ func NewDaemon(c *check.C) *Daemon {
|
||||||
root: daemonRoot,
|
root: daemonRoot,
|
||||||
storageDriver: os.Getenv("DOCKER_GRAPHDRIVER"),
|
storageDriver: os.Getenv("DOCKER_GRAPHDRIVER"),
|
||||||
userlandProxy: userlandProxy,
|
userlandProxy: userlandProxy,
|
||||||
|
execRoot: filepath.Join(os.TempDir(), "docker-execroot", id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +148,7 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
||||||
args := append(d.GlobalFlags,
|
args := append(d.GlobalFlags,
|
||||||
"--containerd", "/var/run/docker/libcontainerd/docker-containerd.sock",
|
"--containerd", "/var/run/docker/libcontainerd/docker-containerd.sock",
|
||||||
"--graph", d.root,
|
"--graph", d.root,
|
||||||
"--exec-root", filepath.Join(d.folder, "exec-root"),
|
"--exec-root", d.execRoot,
|
||||||
"--pidfile", fmt.Sprintf("%s/docker.pid", d.folder),
|
"--pidfile", fmt.Sprintf("%s/docker.pid", d.folder),
|
||||||
fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
|
fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue