Merge pull request #966 from nathanleclaire/stability_fixes

Add a few improvements to stability
This commit is contained in:
Evan Hazlett 2015-04-07 11:31:15 -04:00
commit cbbf0ec0eb
2 changed files with 24 additions and 2 deletions

View File

@ -5,10 +5,12 @@ import (
"fmt"
"os/exec"
log "github.com/Sirupsen/logrus"
"github.com/docker/machine/drivers"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/provision/pkgaction"
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/utils"
)
func init() {
@ -80,6 +82,21 @@ func (provisioner *UbuntuProvisioner) Package(name string, action pkgaction.Pack
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 {
if err := provisioner.SetHostname(provisioner.Driver.GetMachineName()); err != nil {
return err
@ -95,6 +112,10 @@ func (provisioner *UbuntuProvisioner) Provision(swarmOptions swarm.SwarmOptions,
return err
}
if err := utils.WaitFor(provisioner.dockerDaemonResponding); err != nil {
return err
}
if err := ConfigureAuth(provisioner, authOptions); err != nil {
return err
}

View File

@ -13,8 +13,9 @@ import (
func GetSSHCommand(host string, port int, user string, sshKey string, args ...string) *exec.Cmd {
defaultSSHArgs := []string{
"-o", "IdentitiesOnly=yes",
"-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no", // don't bother checking in ~/.ssh/known_hosts
"-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."
"-p", fmt.Sprintf("%d", port),
"-i", sshKey,