mirror of https://github.com/docker/docs.git
Merge pull request #234 from ehazlett/graceful-cleanup-on-create-fail
add cleanup for create failure
This commit is contained in:
commit
9c3624b170
10
commands.go
10
commands.go
|
@ -190,7 +190,17 @@ func cmdCreate(c *cli.Context) {
|
|||
|
||||
host, err := store.Create(name, driver, c)
|
||||
if err != nil {
|
||||
log.Errorf("Error creating host: %s", err)
|
||||
if c.GlobalBool("debug") {
|
||||
log.Fatal(err)
|
||||
} else {
|
||||
log.Warnf("Removing created machine. You can run machine with the --debug flag to avoid this.")
|
||||
// we know there was an error so do not check for the error on removal
|
||||
// instead we will Fatal with a message to prevent spamming with error messages
|
||||
_ = store.Remove(name, true)
|
||||
log.Warn("You will want to check the provider to make sure the machine and associated resources were properly removed.")
|
||||
log.Fatal("Error creating machine")
|
||||
}
|
||||
}
|
||||
if err := store.SetActive(host); err != nil {
|
||||
log.Fatalf("error setting active host: %v", err)
|
||||
|
|
Loading…
Reference in New Issue