From 375af0a7b9d47f7faba90dc1a6a78b34a21fa144 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 17 Aug 2015 09:43:55 +0100 Subject: [PATCH] Improve log messages for when the proxy ignores a container - 'ignoring' could be misread as 'dropped request', so change that to 'leaving container alone' - more elaborate reasons --- proxy/create_container_interceptor.go | 2 +- proxy/create_exec_interceptor.go | 2 +- proxy/proxy.go | 6 +++--- proxy/start_container_interceptor.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/proxy/create_container_interceptor.go b/proxy/create_container_interceptor.go index 2bac7efc..bff9bdc3 100644 --- a/proxy/create_container_interceptor.go +++ b/proxy/create_container_interceptor.go @@ -54,7 +54,7 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error { } if cidrs, err := i.proxy.weaveCIDRsFromConfig(container.Config, container.HostConfig); err != nil { - Log.Infof("Ignoring container due to %s", err) + Log.Infof("Leaving container alone because %s", err) } else { Log.Infof("Creating container with WEAVE_CIDR \"%s\"", strings.Join(cidrs, " ")) if container.HostConfig == nil { diff --git a/proxy/create_exec_interceptor.go b/proxy/create_exec_interceptor.go index 8b89a53a..9e7ea475 100644 --- a/proxy/create_exec_interceptor.go +++ b/proxy/create_exec_interceptor.go @@ -32,7 +32,7 @@ func (i *createExecInterceptor) InterceptRequest(r *http.Request) error { _, hasWeaveWait := container.Volumes["/w"] cidrs, err := i.proxy.weaveCIDRsFromConfig(container.Config, container.HostConfig) if err != nil { - Log.Infof("Ignoring container %s due to %s", container.ID, err) + Log.Infof("Leaving container %s alone because %s", container.ID, err) } else if hasWeaveWait { Log.Infof("Exec in container %s with WEAVE_CIDR \"%s\"", container.ID, strings.Join(cidrs, " ")) cmd := append(weaveWaitEntrypoint, "-s") diff --git a/proxy/proxy.go b/proxy/proxy.go index 0baadeab..beb34915 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -28,8 +28,8 @@ var ( containerStartRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/[^/]*/(re)?start$") execCreateRegexp = regexp.MustCompile("^(/v[0-9\\.]*)?/containers/[^/]*/exec$") - ErrWeaveCIDRNone = errors.New("WEAVE_CIDR=none") - ErrNoDefaultIPAM = errors.New("--no-default-ipalloc option") + ErrWeaveCIDRNone = errors.New("the container was created with the '-e WEAVE_CIDR=none' option") + ErrNoDefaultIPAM = errors.New("the container was created without specifying an IP address with '-e WEAVE_CIDR=...' and the proxy was started with the '--no-default-ipalloc' option") ) type Config struct { @@ -230,7 +230,7 @@ func (proxy *Proxy) weaveCIDRsFromConfig(config *docker.Config, hostConfig *dock netMode = hostConfig.NetworkMode } if netMode == "host" || strings.HasPrefix(netMode, "container:") { - return nil, fmt.Errorf("--net option: %q", netMode) + return nil, fmt.Errorf("the container was created with the '--net=%s'", netMode) } for _, e := range config.Env { if strings.HasPrefix(e, "WEAVE_CIDR=") { diff --git a/proxy/start_container_interceptor.go b/proxy/start_container_interceptor.go index 1c5f1754..e17e3647 100644 --- a/proxy/start_container_interceptor.go +++ b/proxy/start_container_interceptor.go @@ -34,7 +34,7 @@ func (i *startContainerInterceptor) InterceptResponse(r *http.Response) error { cidrs, err := i.proxy.weaveCIDRsFromConfig(container.Config, container.HostConfig) if err != nil { - Log.Infof("Ignoring container %s due to %s", container.ID, err) + Log.Infof("Leaving container %s alone because %s", container.ID, err) return nil } Log.Infof("Attaching container %s with WEAVE_CIDR \"%s\" to weave network", container.ID, strings.Join(cidrs, " "))