drivers: don't let the driver wait for SSH/Docker

Waiting for SSH to start or Docker to be available is a step done
directly in the framework (in libmachine). There is no need for the
driver to do that.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
This commit is contained in:
Vincent Bernat 2015-04-11 08:07:44 +02:00
parent 4047c97679
commit 44be16c49f
5 changed files with 8 additions and 64 deletions

View File

@ -398,12 +398,6 @@ func (d *Driver) Create() error {
d.PrivateIPAddress, d.PrivateIPAddress,
) )
log.Infof("Waiting for SSH on %s:%d", d.IPAddress, 22)
if err := ssh.WaitForTCP(fmt.Sprintf("%s:%d", d.IPAddress, 22)); err != nil {
return err
}
log.Debug("Settings tags for instance") log.Debug("Settings tags for instance")
tags := map[string]string{ tags := map[string]string{
"Name": d.MachineName, "Name": d.MachineName,

View File

@ -3,12 +3,10 @@ package azure
import ( import (
"errors" "errors"
"fmt" "fmt"
"net"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
azure "github.com/MSOpenTech/azure-sdk-for-go" azure "github.com/MSOpenTech/azure-sdk-for-go"
"github.com/MSOpenTech/azure-sdk-for-go/clients/vmClient" "github.com/MSOpenTech/azure-sdk-for-go/clients/vmClient"
@ -257,9 +255,7 @@ func (d *Driver) Create() error {
return err return err
} }
log.Info("Waiting for SSH...") return nil
log.Debugf("Host: %s SSH Port: %d", d.getHostname(), d.SSHPort)
return ssh.WaitForTCP(fmt.Sprintf("%s:%d", d.getHostname(), d.SSHPort))
} }
func (d *Driver) GetURL() (string, error) { func (d *Driver) GetURL() (string, error) {
@ -315,10 +311,8 @@ func (d *Driver) Start() error {
if err := vmClient.StartRole(d.MachineName, d.MachineName, d.MachineName); err != nil { if err := vmClient.StartRole(d.MachineName, d.MachineName, d.MachineName); err != nil {
return err return err
} }
if err := d.waitForSSH(); err != nil {
return err return nil
}
return d.waitForDocker()
} }
func (d *Driver) Stop() error { func (d *Driver) Stop() error {
@ -369,10 +363,8 @@ func (d *Driver) Restart() error {
if err := vmClient.RestartRole(d.MachineName, d.MachineName, d.MachineName); err != nil { if err := vmClient.RestartRole(d.MachineName, d.MachineName, d.MachineName); err != nil {
return err return err
} }
if err := d.waitForSSH(); err != nil {
return err return nil
}
return d.waitForDocker()
} }
func (d *Driver) Kill() error { func (d *Driver) Kill() error {
@ -424,40 +416,6 @@ func (d *Driver) addDockerEndpoint(vmConfig *vmClient.Role) error {
return nil return nil
} }
func (d *Driver) waitForSSH() error {
log.Infof("Waiting for SSH...")
return ssh.WaitForTCP(fmt.Sprintf("%s:%v", d.getHostname(), d.SSHPort))
}
func (d *Driver) waitForDocker() error {
log.Infof("Waiting for docker daemon on host to be available...")
maxRepeats := 48
url := fmt.Sprintf("%s:%v", d.getHostname(), d.DockerPort)
success := waitForDockerEndpoint(url, maxRepeats)
if !success {
return errors.New("Can not run docker daemon on remote machine. Please try again.")
}
return nil
}
func waitForDockerEndpoint(url string, maxRepeats int) bool {
counter := 0
for {
conn, err := net.Dial("tcp", url)
if err != nil {
time.Sleep(10 * time.Second)
counter++
if counter == maxRepeats {
return false
}
continue
}
defer conn.Close()
break
}
return true
}
func (d *Driver) generateCertForAzure() error { func (d *Driver) generateCertForAzure() error {
if err := ssh.GenerateSSHKey(d.sshKeyPath()); err != nil { if err := ssh.GenerateSSHKey(d.sshKeyPath()); err != nil {
return err return err

View File

@ -323,12 +323,7 @@ func (d *Driver) wait() error {
} }
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
} }
log.Infof("Got IP, waiting for SSH") return nil
ip, err := d.GetIP()
if err != nil {
return err
}
return ssh.WaitForTCP(fmt.Sprintf("%s:22", ip))
} }
func (d *Driver) Start() error { func (d *Driver) Start() error {

View File

@ -369,9 +369,6 @@ func (d *Driver) Create() error {
if err := d.lookForIpAddress(); err != nil { if err := d.lookForIpAddress(); err != nil {
return err return err
} }
if err := d.waitForSSHServer(); err != nil {
return err
}
return nil return nil
} }

View File

@ -343,7 +343,7 @@ func (d *Driver) Start() error {
if err := vbm("startvm", d.MachineName, "--type", "headless"); err != nil { if err := vbm("startvm", d.MachineName, "--type", "headless"); err != nil {
return err return err
} }
log.Infof("Waiting for VM to start...") log.Infof("Starting VM...")
case state.Paused: case state.Paused:
if err := vbm("controlvm", d.MachineName, "resume", "--type", "headless"); err != nil { if err := vbm("controlvm", d.MachineName, "resume", "--type", "headless"); err != nil {
return err return err
@ -353,7 +353,7 @@ func (d *Driver) Start() error {
log.Infof("VM not in restartable state") log.Infof("VM not in restartable state")
} }
return ssh.WaitForTCP(fmt.Sprintf("localhost:%d", d.SSHPort)) return nil
} }
func (d *Driver) Stop() error { func (d *Driver) Stop() error {