diff --git a/commands/create.go b/commands/create.go index 3b1a18a6..2704f6b6 100644 --- a/commands/create.go +++ b/commands/create.go @@ -12,10 +12,13 @@ import ( "errors" + "time" + "github.com/codegangsta/cli" "github.com/docker/machine/commands/mcndirs" "github.com/docker/machine/libmachine" "github.com/docker/machine/libmachine/auth" + "github.com/docker/machine/libmachine/crashreport" "github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/drivers/rpc" "github.com/docker/machine/libmachine/engine" @@ -211,7 +214,21 @@ func cmdCreateInner(c CommandLine, api libmachine.API) error { } if err := api.Create(h); err != nil { - return fmt.Errorf("Error creating machine: %s", err) + // Wait for all the logs to reach the client + time.Sleep(2 * time.Second) + + vBoxLog := "" + if h.DriverName == "virtualbox" { + vBoxLog = filepath.Join(api.GetMachinesDir(), h.Name, h.Name, "Logs", "VBox.log") + } + + return crashreport.CrashError{ + Cause: err, + Command: "Create", + Context: "api.performCreate", + DriverName: h.DriverName, + LogFilePath: vBoxLog, + } } if err := api.Save(h); err != nil { diff --git a/libmachine/host/host.go b/libmachine/host/host.go index 9824e2eb..d894e175 100644 --- a/libmachine/host/host.go +++ b/libmachine/host/host.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/docker/machine/libmachine/auth" - "github.com/docker/machine/libmachine/crashreport" "github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/engine" "github.com/docker/machine/libmachine/log" @@ -163,22 +162,12 @@ func (h *Host) Upgrade() error { provisioner, err := provision.DetectProvisioner(h.Driver) if err != nil { - return crashreport.CrashError{ - Cause: err, - Command: "Upgrade", - Context: "provision.DetectProvisioner", - DriverName: h.Driver.DriverName(), - } + return err } log.Info("Upgrading docker...") if err := provisioner.Package("docker", pkgaction.Upgrade); err != nil { - return crashreport.CrashError{ - Cause: err, - Command: "Upgrade", - Context: "provisioner.Package", - DriverName: h.Driver.DriverName(), - } + return err } log.Info("Restarting docker...") diff --git a/libmachine/libmachine.go b/libmachine/libmachine.go index 9b82c721..83306743 100644 --- a/libmachine/libmachine.go +++ b/libmachine/libmachine.go @@ -6,13 +6,10 @@ import ( "io" - "time" - "github.com/docker/machine/drivers/errdriver" "github.com/docker/machine/libmachine/auth" "github.com/docker/machine/libmachine/cert" "github.com/docker/machine/libmachine/check" - "github.com/docker/machine/libmachine/crashreport" "github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/drivers/plugin/localbinary" "github.com/docker/machine/libmachine/drivers/rpc" @@ -34,6 +31,7 @@ type API interface { NewHost(driverName string, rawDriver []byte) (*host.Host, error) Create(h *host.Host) error persist.Store + GetMachinesDir() string } type Client struct { @@ -135,21 +133,7 @@ func (api *Client) Create(h *host.Host) error { log.Info("Creating machine...") if err := api.performCreate(h); err != nil { - // Wait for all the logs to reach the client - time.Sleep(2 * time.Second) - - vBoxLog := "" - if h.DriverName == "virtualbox" { - vBoxLog = filepath.Join(api.GetMachinesDir(), h.Name, h.Name, "Logs", "VBox.log") - } - - return crashreport.CrashError{ - Cause: err, - Command: "Create", - Context: "api.performCreate", - DriverName: h.DriverName, - LogFilePath: vBoxLog, - } + return fmt.Errorf("Error creating machine: %s", err) } log.Debug("Reticulating splines...") diff --git a/libmachine/libmachinetest/fake_api.go b/libmachine/libmachinetest/fake_api.go index 7a6a47fa..4566257a 100644 --- a/libmachine/libmachinetest/fake_api.go +++ b/libmachine/libmachinetest/fake_api.go @@ -72,6 +72,10 @@ func (api *FakeAPI) Save(host *host.Host) error { return nil } +func (api FakeAPI) GetMachinesDir() string { + return "" +} + func State(api libmachine.API, name string) state.State { host, _ := api.Load(name) machineState, _ := host.Driver.GetState()