From d518e171b947999774be59767605375df2ed0cb5 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Mon, 18 Jan 2016 11:42:21 +0100 Subject: [PATCH 1/2] Fix bugsnag reports for create Signed-off-by: David Gageot --- commands/create.go | 19 ++++++++++++++++++- libmachine/libmachine.go | 20 ++------------------ libmachine/libmachinetest/fake_api.go | 4 ++++ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/commands/create.go b/commands/create.go index 3b1a18a603..2704f6b606 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/libmachine.go b/libmachine/libmachine.go index 9b82c721fa..83306743e2 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 7a6a47fa6c..4566257aeb 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() From b5e6e20a8f75abb0e132efabee1e59119758e9c1 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Mon, 18 Jan 2016 11:56:20 +0100 Subject: [PATCH 2/2] Disable bugsnag report for upgrades for now Signed-off-by: David Gageot --- libmachine/host/host.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/libmachine/host/host.go b/libmachine/host/host.go index 9824e2eb29..d894e175e9 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...")