From 37188154c9aa98e1af3852b26d7fcd592d1e3c53 Mon Sep 17 00:00:00 2001 From: Lyon Hill Date: Wed, 15 Feb 2017 11:44:00 -0700 Subject: [PATCH] Provider setup needed to clean a errored vm with docker-machine --- processors/implode.go | 2 +- processors/provider/bridge/setup.go | 2 +- util/provider/dockermachine.go | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/processors/implode.go b/processors/implode.go index c6431a25..33045cc1 100644 --- a/processors/implode.go +++ b/processors/implode.go @@ -55,7 +55,7 @@ func purgeConfiguration() error { // implode the global dir if err := os.RemoveAll(config.GlobalDir()); err != nil { - return util.ErrorAppend(err, "failed to purge the data directory") + return util.ErrorAppend(util.ErrorQuiet(err), "failed to purge the data directory") } return nil diff --git a/processors/provider/bridge/setup.go b/processors/provider/bridge/setup.go index b502134f..5e5b54b7 100644 --- a/processors/provider/bridge/setup.go +++ b/processors/provider/bridge/setup.go @@ -80,7 +80,7 @@ func setupContainer() error { } display.StopTask() - display.StartTask("Configuring") + display.StartTask("Setting up container") // run the configure hook if _, err := hookit.DebugExec(container.ID, "configure", "{\"platform\":\"local\",\"config\":{}}", "info"); err != nil { return util.ErrorAppend(err, "failed to run configure hook") diff --git a/util/provider/dockermachine.go b/util/provider/dockermachine.go index 126b7240..d99b2662 100644 --- a/util/provider/dockermachine.go +++ b/util/provider/dockermachine.go @@ -13,6 +13,7 @@ import ( "strings" "github.com/nanobox-io/nanobox/models" + "github.com/nanobox-io/nanobox/util" "github.com/nanobox-io/nanobox/util/display" // "github.com/nanobox-io/nanobox/util/fileutil" "github.com/nanobox-io/nanobox/util/vbox" @@ -97,6 +98,9 @@ func (machine DockerMachine) Create() error { return nil } + // make sure dockermachine is clean + exec.Command(dockerMachineCmd, "rm", "-f", "nanobox").Run() + display.ProviderSetup() // load the configuration for docker-machine @@ -139,14 +143,14 @@ func (machine DockerMachine) Create() error { process := exec.Command(cmd[0], cmd[1:]...) - process.Stdout = display.NewStreamer("info") - process.Stderr = display.NewStreamer("info") + // process.Stdout = display.NewStreamer("info") + // process.Stderr = display.NewStreamer("info") display.StartTask("Launching VM") - if err := process.Run(); err != nil { + if out, err := process.CombinedOutput(); err != nil { display.ErrorTask() - return err + return util.Errorf("%s: %s", err, out) } display.StopTask() @@ -737,7 +741,8 @@ func (machine DockerMachine) isCreated() bool { return false } - if bytes.Contains(output, []byte("Host does not exist: \"nanobox\"")) { + if bytes.Contains(output, []byte("Host does not exist: \"nanobox\"")) || + bytes.Contains(output, []byte("error")) { return false }