Skip to content

Commit ed1224b

Browse files
authored
Merge pull request #378 from nanobox-io/refactor/netwrk-error
Add a message to help make failed docker network creates more clear
2 parents d6af5fa + 4f002f6 commit ed1224b

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

util/display/messages.go

+13
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,16 @@ func LoginComplete() {
199199
%s You've successfully logged in
200200
`, TaskComplete))
201201
}
202+
203+
func NetworkCreateError() {
204+
os.Stderr.WriteString(`
205+
Nanobox is trying to create a native docker network, and it
206+
looks like we have a conflict. An existing docker network is
207+
already using the DEFAULT_NETWORK address space.
208+
209+
You will need to either remove the conflicting network, or set
210+
an alternative address space with the following:
211+
212+
nanobox COMMAND TO SET NEW ADDRESS SPACE
213+
`)
214+
}

util/provider/native.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"strings"
1111

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

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

101100
if native.hasNetwork() {
102-
fmt.Print(stylish.Bullet("Removing custom docker network..."))
101+
display.StartTask("Removing custom docker network...")
103102

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

106105
cmd.Stdout = display.NewStreamer(" ")
107106
cmd.Stderr = display.NewStreamer(" ")
108107

109108
if err := cmd.Run(); err != nil {
109+
display.ErrorTask()
110110
return err
111111
}
112+
display.StopTask()
112113
}
113114

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

120121
// TODO: some networking maybe???
121122
if !native.hasNetwork() {
122-
fmt.Print(stylish.Bullet("Setting up custom docker network..."))
123+
display.StartTask("Setting up custom docker network...")
123124

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

135136
if err := cmd.Run(); err != nil {
137+
display.ErrorTask()
138+
display.NetworkCreateError()
136139
return err
137140
}
141+
display.StopTask()
138142
}
139143

140144
return nil

0 commit comments

Comments
 (0)