From c915f834f8a35e1d5e567f5440e0a5d87fc2b185 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Thu, 23 Jun 2016 17:21:26 +0100 Subject: [PATCH 1/3] Add dry run flag to scope, so when launched we can check the args are valid. --- docker/entrypoint.sh | 5 ----- prog/main.go | 6 ++++++ scope | 11 +++++++++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 0e459ea61d..ea4356e83f 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -2,11 +2,6 @@ mkdir -p /var/run/weave -if [ "$1" = "version" -o "$1" = "help" ]; then - exec -a scope /home/weave/scope --mode $1 - exit 0 -fi - for arg in $@; do case "$arg" in --no-app|--probe-only|--service-token*|--probe.token*) diff --git a/prog/main.go b/prog/main.go index 41859f0095..f1c6601973 100644 --- a/prog/main.go +++ b/prog/main.go @@ -116,11 +116,13 @@ func main() { mode string debug bool weaveHostname string + dryRun bool ) // Flags that apply to both probe and app flag.StringVar(&mode, "mode", "help", "For internal use.") flag.BoolVar(&debug, "debug", false, "Force debug logging.") + flag.BoolVar(&dryRun, "dry-run", false, "Don't start scope, just parse the arguments.") flag.StringVar(&weaveHostname, "weave.hostname", "", "Hostname to advertise/lookup in WeaveDNS") // We need to know how to parse them, but they are mainly interpreted by the entrypoint script. @@ -202,6 +204,10 @@ func main() { } flags.probe.noApp = *noApp || *probeOnly + if dryRun { + return + } + switch mode { case "app": appMain(flags.app) diff --git a/scope b/scope index 0b58cf6327..d42969ad1c 100755 --- a/scope +++ b/scope @@ -127,7 +127,8 @@ case "$COMMAND" in ;; version) - docker run --rm -e CHECKPOINT_DISABLE $SCOPE_IMAGE version + docker run --rm -e CHECKPOINT_DISABLE --entrypoint=/home/weave/scope \ + $WEAVESCOPE_DOCKER_ARGS $SCOPE_IMAGE --mode=version ;; help) @@ -138,7 +139,8 @@ scope help - Print this scope launch - Launch Scope EOF - docker run --rm -e CHECKPOINT_DISABLE $SCOPE_IMAGE help + docker run --rm -e CHECKPOINT_DISABLE --entrypoint=/home/weave/scope \ + $WEAVESCOPE_DOCKER_ARGS $SCOPE_IMAGE -h cat >&2 </dev/null 2>&1 || true From 90273ab797010e6c824ff0a760555ace1d32be6d Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Fri, 24 Jun 2016 08:57:34 +0100 Subject: [PATCH 2/3] Try and parse listen address and error early. --- prog/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/prog/main.go b/prog/main.go index f1c6601973..56c4db7fb5 100644 --- a/prog/main.go +++ b/prog/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "net" "os" "strconv" "strings" @@ -204,6 +205,18 @@ func main() { } flags.probe.noApp = *noApp || *probeOnly + // Special case for #1191, check listen address is well formed + _, _, err := net.SplitHostPort(flags.app.listen) + if err != nil { + log.Errorf("Invalid value for -app.http.address: %v", err) + } + if flags.probe.httpListen != "" { + _, _, err := net.SplitHostPort(flags.probe.httpListen) + if err != nil { + log.Errorf("Invalid value for -app.http.address: %v", err) + } + } + if dryRun { return } From 735ef624197cb6147c8057b2c89a7a03f459dc92 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Fri, 24 Jun 2016 12:21:15 +0100 Subject: [PATCH 3/3] Specify that -dry-run is for internal use only. --- prog/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prog/main.go b/prog/main.go index 56c4db7fb5..8e6c0bd6b7 100644 --- a/prog/main.go +++ b/prog/main.go @@ -123,7 +123,7 @@ func main() { // Flags that apply to both probe and app flag.StringVar(&mode, "mode", "help", "For internal use.") flag.BoolVar(&debug, "debug", false, "Force debug logging.") - flag.BoolVar(&dryRun, "dry-run", false, "Don't start scope, just parse the arguments.") + flag.BoolVar(&dryRun, "dry-run", false, "Don't start scope, just parse the arguments. For internal use only.") flag.StringVar(&weaveHostname, "weave.hostname", "", "Hostname to advertise/lookup in WeaveDNS") // We need to know how to parse them, but they are mainly interpreted by the entrypoint script.