Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a message to help make failed docker network creates more clear #378

Merged
merged 1 commit into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions util/display/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,16 @@ func LoginComplete() {
%s You've successfully logged in
`, TaskComplete))
}

func NetworkCreateError() {
os.Stderr.WriteString(`
Nanobox is trying to create a native docker network, and it
looks like we have a conflict. An existing docker network is
already using the DEFAULT_NETWORK address space.
You will need to either remove the conflicting network, or set
an alternative address space with the following:
nanobox COMMAND TO SET NEW ADDRESS SPACE
`)
}
10 changes: 7 additions & 3 deletions util/provider/native.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"

"github.com/jcelliott/lumber"
"github.com/nanobox-io/nanobox-golang-stylish"

"github.com/nanobox-io/nanobox/models"
"github.com/nanobox-io/nanobox/util/config"
Expand Down Expand Up @@ -99,16 +98,18 @@ func (native Native) Destroy() error {
// TODO: remove nanobox images

if native.hasNetwork() {
fmt.Print(stylish.Bullet("Removing custom docker network..."))
display.StartTask("Removing custom docker network...")

cmd := exec.Command("docker", "network", "rm", "nanobox")

cmd.Stdout = display.NewStreamer(" ")
cmd.Stderr = display.NewStreamer(" ")

if err := cmd.Run(); err != nil {
display.ErrorTask()
return err
}
display.StopTask()
}

return nil
Expand All @@ -119,7 +120,7 @@ func (native Native) Start() error {

// TODO: some networking maybe???
if !native.hasNetwork() {
fmt.Print(stylish.Bullet("Setting up custom docker network..."))
display.StartTask("Setting up custom docker network...")

config, _ := models.LoadConfig()
ip, ipNet, err := net.ParseCIDR(config.NativeNetworkSpace)
Expand All @@ -133,8 +134,11 @@ func (native Native) Start() error {
cmd.Stderr = display.NewStreamer(" ")

if err := cmd.Run(); err != nil {
display.ErrorTask()
display.NetworkCreateError()
return err
}
display.StopTask()
}

return nil
Expand Down