From a23813061308fc076ef8f35731a5cd5bc44ea7af Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Wed, 20 Jan 2016 15:33:56 +0000 Subject: [PATCH] Give more explanation if we can't find weave to talk to --- plugin/ipam/driver.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugin/ipam/driver.go b/plugin/ipam/driver.go index 8cd6142f..59273d73 100644 --- a/plugin/ipam/driver.go +++ b/plugin/ipam/driver.go @@ -1,10 +1,12 @@ package ipamplugin import ( + "fmt" "net" "github.com/docker/libnetwork/ipamapi" "github.com/docker/libnetwork/netlabel" + godocker "github.com/fsouza/go-dockerclient" "github.com/weaveworks/weave/api" . "github.com/weaveworks/weave/common" "github.com/weaveworks/weave/common/docker" @@ -20,7 +22,13 @@ type ipam struct { } func NewIpam(client *docker.Client, version string) (ipamapi.Ipam, error) { - resolver := func() (string, error) { return client.GetContainerIP(WeaveContainer) } + resolver := func() (string, error) { + addr, err := client.GetContainerIP(WeaveContainer) + if _, ok := err.(*godocker.NoSuchContainer); ok { + return "", fmt.Errorf("%s container is not present. Have you launched it?", WeaveContainer) + } + return addr, err + } return &ipam{client: client, weave: api.NewClientWithResolver(resolver)}, nil }