Merge pull request #2856 from dgageot/fix-bugsnag

Fix bugsnag
This commit is contained in:
Jean-Laurent de Morlhon 2016-01-18 12:36:46 +01:00
commit f289123574
4 changed files with 26 additions and 32 deletions

View File

@ -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 {

View File

@ -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...")

View File

@ -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...")

View File

@ -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()