mirror of https://github.com/docker/docs.git
Merge pull request #966 from nathanleclaire/stability_fixes
Add a few improvements to stability
This commit is contained in:
commit
cbbf0ec0eb
|
|
@ -5,10 +5,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/machine/drivers"
|
"github.com/docker/machine/drivers"
|
||||||
"github.com/docker/machine/libmachine/auth"
|
"github.com/docker/machine/libmachine/auth"
|
||||||
"github.com/docker/machine/libmachine/provision/pkgaction"
|
"github.com/docker/machine/libmachine/provision/pkgaction"
|
||||||
"github.com/docker/machine/libmachine/swarm"
|
"github.com/docker/machine/libmachine/swarm"
|
||||||
|
"github.com/docker/machine/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -80,6 +82,21 @@ func (provisioner *UbuntuProvisioner) Package(name string, action pkgaction.Pack
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (provisioner *UbuntuProvisioner) dockerDaemonResponding() bool {
|
||||||
|
cmd, err := provisioner.SSHCommand("sudo docker version")
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("Error getting SSH command to check if the daemon is up: %s", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
log.Debug("Error checking for daemon up: %s", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// The daemon is up if the command worked. Carry on.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions) error {
|
func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.SwarmOptions, authOptions auth.AuthOptions) error {
|
||||||
if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil {
|
if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -95,6 +112,10 @@ func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.SwarmOptions,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := utils.WaitFor(provisioner.dockerDaemonResponding); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := ConfigureAuth(provisioner, authOptions); err != nil {
|
if err := ConfigureAuth(provisioner, authOptions); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,9 @@ import (
|
||||||
func GetSSHCommand(host string, port int, user string, sshKey string, args ...string) *exec.Cmd {
|
func GetSSHCommand(host string, port int, user string, sshKey string, args ...string) *exec.Cmd {
|
||||||
defaultSSHArgs := []string{
|
defaultSSHArgs := []string{
|
||||||
"-o", "IdentitiesOnly=yes",
|
"-o", "IdentitiesOnly=yes",
|
||||||
"-o", "StrictHostKeyChecking=no",
|
"-o", "StrictHostKeyChecking=no", // don't bother checking in ~/.ssh/known_hosts
|
||||||
"-o", "UserKnownHostsFile=/dev/null",
|
"-o", "UserKnownHostsFile=/dev/null", // don't write anything to ~/.ssh/known_hosts
|
||||||
|
"-o", "ConnectionAttempts=30", // retry 30 times if SSH connection fails
|
||||||
"-o", "LogLevel=quiet", // suppress "Warning: Permanently added '[localhost]:2022' (ECDSA) to the list of known hosts."
|
"-o", "LogLevel=quiet", // suppress "Warning: Permanently added '[localhost]:2022' (ECDSA) to the list of known hosts."
|
||||||
"-p", fmt.Sprintf("%d", port),
|
"-p", fmt.Sprintf("%d", port),
|
||||||
"-i", sshKey,
|
"-i", sshKey,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue