weaveworks / weave

Simple, resilient multi-host containers networking and more.
https://www.weave.works
Apache License 2.0
6.62k stars 670 forks source link

weave report -f returns misleading error message with net-plugin v2 #3102

Open dtshepherd opened 7 years ago

dtshepherd commented 7 years ago

What you expected to happen?

weave report should return helpful error message when invalid format string is passed to -f option.

What happened?

weave report -f '{{ .Router.Target }}' returned an error message stating "weave container is not present. Have you launched it?". The weave container was running as a net-plugin, so the reason for the error was wrong. The error was caused by an invalid format string .Router.Target does not exist, it needed to be .Router.Targets.

How to reproduce it?

  1. Launch weave as net-plugin v2
  2. Run weave report -f '{{ .Bad.Key }}'

Anything else we need to know?

Nope

Versions:

$ weave version
weave script 2.0.1
weave 2.0.1
$ docker version
Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:23:31 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.0-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:19:04 2017
 OS/Arch:      linux/amd64
 Experimental: false
$ uname -a
Linux NUC 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Logs:

NA

Network:

NA

dtshepherd commented 7 years ago

I just updated the ticket above. This only affects the net-plugin. Normally launched weave reports a helpful message "error during template execution".

brb commented 7 years ago

Thanks for the report.

The problem is that call_weave (called by weave report) calls check_running (https://github.com/weaveworks/weave/blob/v2.0.4/weave#L653) in the case of /report returning an error. The latter function expects the weave container to be running which is not the case for net-plugin.

dtshepherd commented 7 years ago

Yeah, I figured that out. I commented in the community slack, but I'm working on a PR to make weave script more aware of the net-plugin. I know this may overlap with #2938, but maybe I can help iterate the improvements.