Merge pull request #25890 from cpuguy83/fix_swarm_control_sock_path

Use daemon exec root for swarm control socket
This commit is contained in:
Brian Goff 2016-08-30 08:51:52 -04:00 committed by GitHub
commit edafc642b2
6 changed files with 34 additions and 2 deletions

View File

@ -256,6 +256,7 @@ func (cli *DaemonCli) start(opts daemonOptions) (err error) {
Backend: d,
NetworkSubnetsProvider: d,
DefaultAdvertiseAddr: cli.Config.SwarmDefaultAdvertiseAddr,
RuntimeRoot: cli.getSwarmRunRoot(),
})
if err != nil {
logrus.Fatalf("Error creating cluster component: %v", err)

View File

@ -61,6 +61,12 @@ func (cli *DaemonCli) getLibcontainerdRoot() string {
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 {
return nil
}

View File

@ -85,6 +85,12 @@ func (cli *DaemonCli) getLibcontainerdRoot() string {
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
// that try to use any port allocated for the docker server.
func allocateDaemonPort(addr string) error {

View File

@ -73,6 +73,12 @@ func (cli *DaemonCli) getLibcontainerdRoot() string {
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 {
return nil
}

View File

@ -103,6 +103,9 @@ type Config struct {
// DefaultAdvertiseAddr is the default host/IP or network interface to use
// if no AdvertiseAddr value is specified.
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
@ -111,6 +114,7 @@ type Cluster struct {
sync.RWMutex
*node
root string
runtimeRoot string
config Config
configEvent chan struct{} // todo: make this array and goroutine safe
localAddr string
@ -138,10 +142,17 @@ func New(config Config) (*Cluster, error) {
if err := os.MkdirAll(root, 0700); err != nil {
return nil, err
}
if config.RuntimeRoot == "" {
config.RuntimeRoot = root
}
if err := os.MkdirAll(config.RuntimeRoot, 0700); err != nil {
return nil, err
}
c := &Cluster{
root: root,
config: config,
configEvent: make(chan struct{}, 10),
runtimeRoot: config.RuntimeRoot,
}
st, err := c.loadState()
@ -275,7 +286,7 @@ func (c *Cluster) startNewNode(forceNewCluster bool, localAddr, remoteAddr, list
n, err := swarmagent.NewNode(&swarmagent.NodeConfig{
Hostname: c.config.Name,
ForceNewCluster: forceNewCluster,
ListenControlAPI: filepath.Join(c.root, controlSocket),
ListenControlAPI: filepath.Join(c.runtimeRoot, controlSocket),
ListenRemoteAPI: listenAddr,
AdvertiseRemoteAPI: advertiseAddr,
JoinAddr: joinAddr,

View File

@ -42,6 +42,7 @@ type Daemon struct {
userlandProxy bool
useDefaultHost bool
useDefaultTLSHost bool
execRoot string
}
type clientConfig struct {
@ -82,6 +83,7 @@ func NewDaemon(c *check.C) *Daemon {
root: daemonRoot,
storageDriver: os.Getenv("DOCKER_GRAPHDRIVER"),
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,
"--containerd", "/var/run/docker/libcontainerd/docker-containerd.sock",
"--graph", d.root,
"--exec-root", filepath.Join(d.folder, "exec-root"),
"--exec-root", d.execRoot,
"--pidfile", fmt.Sprintf("%s/docker.pid", d.folder),
fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
)