diff --git a/Makefile b/Makefile index 65fde9f0..95c6f0d0 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,6 @@ WEAVE_VERSION?=git-$(shell git rev-parse --short=12 HEAD) # Paths to all relevant binaries that should be compiled WEAVER_EXE=prog/weaver/weaver -WEAVEPROXY_EXE=prog/weaveproxy/weaveproxy SIGPROXY_EXE=prog/sigproxy/sigproxy KUBEPEERS_EXE=prog/kube-peers/kube-peers WEAVENPC_EXE=prog/weave-npc/weave-npc @@ -99,7 +98,7 @@ MANIFEST_TOOL_EXE=$(MANIFEST_TOOL_DIR)/manifest-tool TEST_TLS_EXE=test/tls/tls # All binaries together in a list -EXES=$(WEAVER_EXE) $(SIGPROXY_EXE) $(KUBEPEERS_EXE) $(WEAVENPC_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVEUTIL_EXE) $(RUNNER_EXE) $(TEST_TLS_EXE) $(MANIFEST_TOOL_EXE) +EXES=$(WEAVER_EXE) $(SIGPROXY_EXE) $(KUBEPEERS_EXE) $(WEAVENPC_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVEUTIL_EXE) $(RUNNER_EXE) $(TEST_TLS_EXE) $(MANIFEST_TOOL_EXE) # These stamp files are used to mark the current state of the build; whether an image has been built or not BUILD_UPTODATE=.build.uptodate @@ -152,10 +151,10 @@ PACKAGE_BASE=$(shell go list -e ./) all: $(WEAVE_EXPORT) testrunner: $(RUNNER_EXE) $(TEST_TLS_EXE) -$(WEAVER_EXE) $(WEAVEPROXY_EXE) $(WEAVEUTIL_EXE): common/*.go common/*/*.go net/*.go net/*/*.go +$(WEAVER_EXE) $(WEAVEUTIL_EXE): common/*.go common/*/*.go net/*.go net/*/*.go $(WEAVER_EXE): router/*.go ipam/*.go ipam/*/*.go db/*.go nameserver/*.go prog/weaver/*.go $(WEAVER_EXE): api/*.go plugin/*.go plugin/*/* -$(WEAVEPROXY_EXE): proxy/*.go prog/weaveproxy/*.go +$(WEAVER_EXE): proxy/*.go $(WEAVEUTIL_EXE): prog/weaveutil/*.go net/*.go plugin/net/*.go plugin/ipam/*.go db/*.go $(SIGPROXY_EXE): prog/sigproxy/*.go $(KUBEPEERS_EXE): prog/kube-peers/*.go @@ -189,7 +188,7 @@ else exes: $(EXES) -$(WEAVER_EXE) $(WEAVEPROXY_EXE): +$(WEAVER_EXE): ifeq ($(COVERAGE),true) $(eval COVERAGE_MODULES := $(shell (go list ./$(@D); go list -f '{{join .Deps "\n"}}' ./$(@D) | grep "^$(PACKAGE_BASE)/") | grep -v "^$(PACKAGE_BASE)/vendor/" | paste -s -d,)) go test -c -o ./$@ $(BUILD_FLAGS) -v -covermode=atomic -coverpkg $(COVERAGE_MODULES) ./$(@D)/ @@ -253,10 +252,9 @@ $(WEAVER_UPTODATE): prog/weaver/Dockerfile.$(DOCKERHUB_USER) $(WEAVER_EXE) $(WEA $(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker build -f prog/weaver/Dockerfile.$(DOCKERHUB_USER) -t $(WEAVER_IMAGE) prog/weaver touch $@ -$(WEAVEEXEC_UPTODATE): prog/weaveexec/Dockerfile.$(DOCKERHUB_USER) prog/weaveexec/symlink $(DOCKER_DISTRIB) weave $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVEUTIL_EXE) +$(WEAVEEXEC_UPTODATE): prog/weaveexec/Dockerfile.$(DOCKERHUB_USER) prog/weaveexec/symlink $(DOCKER_DISTRIB) weave $(SIGPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEWAIT_NOOP_EXE) $(WEAVEWAIT_NOMCAST_EXE) $(WEAVEUTIL_EXE) cp weave prog/weaveexec/weave cp $(SIGPROXY_EXE) prog/weaveexec/sigproxy - cp $(WEAVEPROXY_EXE) prog/weaveexec/weaveproxy cp $(WEAVEWAIT_EXE) prog/weaveexec/weavewait cp $(WEAVEWAIT_NOOP_EXE) prog/weaveexec/weavewait_noop cp $(WEAVEWAIT_NOMCAST_EXE) prog/weaveexec/weavewait_nomcast @@ -275,7 +273,7 @@ $(PLUGIN_UPTODATE): prog/net-plugin/launch.sh prog/net-plugin/config.json $(WEAV $(SUDO) docker export $(PLUGIN_BUILD_IMG) | tar -x -C $(PLUGIN_WORK_DIR) $(SUDO) docker rm -f $(PLUGIN_BUILD_IMG) # get rid of a few bulky things we don't need in the v2 plugin image - rm $(PLUGIN_WORK_DIR)/home/weave/weaveproxy $(PLUGIN_WORK_DIR)/home/weave/sigproxy $(PLUGIN_WORK_DIR)/usr/bin/docker + rm $(PLUGIN_WORK_DIR)/home/weave/sigproxy $(PLUGIN_WORK_DIR)/usr/bin/docker cp prog/net-plugin/launch.sh $(PLUGIN_WORK_DIR)/home/weave/launch.sh -$(SUDO) docker plugin disable $(PLUGIN_IMAGE):$(WEAVE_VERSION) 2>/dev/null -$(SUDO) docker plugin rm $(PLUGIN_IMAGE):$(WEAVE_VERSION) 2>/dev/null diff --git a/bin/multiweave b/bin/multiweave index 40654b4c..995a5616 100755 --- a/bin/multiweave +++ b/bin/multiweave @@ -41,7 +41,7 @@ case "$1" in for i in $(seq $START $FINISH); do IP=$SUBNET.$i sudo ip addr add $IP/24 dev multiweave - weave $i launch-router --datapath '' --iface '' --no-dns --host $IP \ + weave $i launch --datapath '' --iface '' --no-dns --host $IP \ --name $(random_mac) --nickname weave$i "$@" done echo $(date -R) connecting @@ -57,7 +57,7 @@ case "$1" in for i in $(seq $FINISH -1 $START); do IP=$SUBNET.$i echo Stopping weave$i - weave $i stop-router + weave $i stop sudo ip addr del $IP/24 dev multiweave || true done [ -z "$(ip -4 -o addr show multiweave)" ] && sudo ip link del multiweave diff --git a/prog/weaveexec/Dockerfile.template b/prog/weaveexec/Dockerfile.template index 3e1b41e9..716dda01 100644 --- a/prog/weaveexec/Dockerfile.template +++ b/prog/weaveexec/Dockerfile.template @@ -25,7 +25,7 @@ RUN apk add --update \ bind-tools \ && rm -rf /var/cache/apk/* -ADD ./weave ./sigproxy ./weaveproxy ./symlink /home/weave/ +ADD ./weave ./sigproxy ./symlink /home/weave/ ADD ./weaveutil ./docker /usr/bin/ ADD ./weavewait /w/w ADD ./weavewait_noop /w-noop/w diff --git a/prog/weaveproxy/main.go b/prog/weaveproxy/main.go deleted file mode 100644 index 65c29fdc..00000000 --- a/prog/weaveproxy/main.go +++ /dev/null @@ -1,78 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strings" - - "github.com/weaveworks/common/mflag" - "github.com/weaveworks/common/mflagext" - "github.com/weaveworks/common/signals" - "github.com/weaveworks/weave/common" - "github.com/weaveworks/weave/proxy" -) - -var version = "unreleased" - -var Log = common.Log - -func getenv(key, defaultVal string) string { - if v := os.Getenv(key); v != "" { - return v - } - return defaultVal -} - -func main() { - var ( - justVersion bool - logLevel = "info" - c proxy.Config - ) - - c.Version = version - - mflag.BoolVar(&justVersion, []string{"#version", "-version"}, false, "print version and exit") - mflag.StringVar(&logLevel, []string{"-log-level"}, "info", "logging level (debug, info, warning, error)") - mflagext.ListVar(&c.ListenAddrs, []string{"H"}, nil, "addresses on which to listen") - mflag.StringVar(&c.HostnameFromLabel, []string{"-hostname-from-label"}, "", "Key of container label from which to obtain the container's hostname") - mflag.StringVar(&c.HostnameMatch, []string{"-hostname-match"}, "(.*)", "Regexp pattern to apply on container names (e.g. '^aws-[0-9]+-(.*)$')") - mflag.StringVar(&c.HostnameReplacement, []string{"-hostname-replacement"}, "$1", "Expression to generate hostnames based on matches from --hostname-match (e.g. 'my-app-$1')") - mflag.BoolVar(&c.RewriteInspect, []string{"-rewrite-inspect"}, false, "Rewrite 'inspect' calls to return the weave network settings (if attached)") - mflag.BoolVar(&c.NoDefaultIPAM, []string{"#-no-default-ipam", "-no-default-ipalloc"}, false, "do not automatically allocate addresses for containers without a WEAVE_CIDR") - mflag.BoolVar(&c.NoRewriteHosts, []string{"-no-rewrite-hosts"}, false, "do not automatically rewrite /etc/hosts. Use if you need the docker IP to remain in /etc/hosts") - mflag.StringVar(&c.TLSConfig.CACert, []string{"#tlscacert", "-tlscacert"}, "", "Trust certs signed only by this CA") - mflag.StringVar(&c.TLSConfig.Cert, []string{"#tlscert", "-tlscert"}, "", "Path to TLS certificate file") - mflag.BoolVar(&c.TLSConfig.Enabled, []string{"#tls", "-tls"}, false, "Use TLS; implied by --tlsverify") - mflag.StringVar(&c.TLSConfig.Key, []string{"#tlskey", "-tlskey"}, "", "Path to TLS key file") - mflag.BoolVar(&c.TLSConfig.Verify, []string{"#tlsverify", "-tlsverify"}, false, "Use TLS and verify the remote") - mflag.BoolVar(&c.WithoutDNS, []string{"-without-dns"}, false, "instruct created containers to never use weaveDNS as their nameserver") - mflag.BoolVar(&c.NoMulticastRoute, []string{"-no-multicast-route"}, false, "do not add a multicast route via the weave interface when attaching containers") - mflag.Parse() - - if justVersion { - fmt.Printf("weave proxy %s\n", version) - os.Exit(0) - } - - common.SetLogLevel(logLevel) - - Log.Infoln("weave proxy", version) - Log.Infoln("Command line arguments:", strings.Join(os.Args[1:], " ")) - - c.Image = getenv("EXEC_IMAGE", "weaveworks/weaveexec") - c.DockerBridge = getenv("DOCKER_BRIDGE", "docker0") - c.DockerHost = getenv("DOCKER_HOST", "unix:///var/run/docker.sock") - - p, err := proxy.NewProxy(c) - if err != nil { - Log.Fatalf("Could not start proxy: %s", err) - } - defer p.Stop() - - listeners := p.Listen() - p.AttachExistingContainers() - go p.Serve(listeners) - go p.ListenAndServeStatus("/home/weave/status.sock") - signals.SignalHandlerLoop(common.Log) -} diff --git a/prog/weaveproxy/main_test.go b/prog/weaveproxy/main_test.go deleted file mode 100644 index 1873f4a3..00000000 --- a/prog/weaveproxy/main_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "testing" - - weavetest "github.com/weaveworks/weave/testing" -) - -func TestMain(t *testing.T) { - weavetest.TrimTestArgs() - main() -} diff --git a/prog/weaver/main.go b/prog/weaver/main.go index 9a4898fe..150744e1 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -14,6 +14,7 @@ import ( "github.com/gorilla/mux" "github.com/pkg/profile" "github.com/weaveworks/common/mflag" + "github.com/weaveworks/common/mflagext" "github.com/weaveworks/common/signals" "github.com/weaveworks/mesh" @@ -26,6 +27,7 @@ import ( weavenet "github.com/weaveworks/weave/net" "github.com/weaveworks/weave/net/address" "github.com/weaveworks/weave/plugin" + weaveproxy "github.com/weaveworks/weave/proxy" weave "github.com/weaveworks/weave/router" ) @@ -113,6 +115,13 @@ func (c *ipamConfig) parseMode() error { return nil } +func getenvOrDefault(key, defaultVal string) string { + if v := os.Getenv(key); v != "" { + return v + } + return defaultVal +} + func main() { procs := runtime.NumCPU() // packet sniffing can block an OS thread, so we need one thread @@ -133,7 +142,7 @@ func main() { nickName string password string pktdebug bool - logLevel string + logLevel = "info" prof string bufSzMB int noDiscovery bool @@ -156,14 +165,9 @@ func main() { enablePlugin bool enablePluginV2 bool enablePluginV2Multicast bool - - defaultDockerHost = "unix:///var/run/docker.sock" + defaultDockerHost = getenvOrDefault("DOCKER_HOST", "unix:///var/run/docker.sock") ) - if val := os.Getenv("DOCKER_HOST"); val != "" { - defaultDockerHost = val - } - mflag.BoolVar(&justVersion, []string{"#version", "-version"}, false, "print version and exit") mflag.StringVar(&config.Host, []string{"-host"}, "", "router host") mflag.IntVar(&config.Port, []string{"#port", "-port"}, mesh.Port, "router port") @@ -213,6 +217,11 @@ func main() { mflag.StringVar(&pluginSocket, []string{"-plugin-socket"}, "/run/docker/plugins/weave.sock", "plugin socket on which to listen") mflag.StringVar(&pluginMeshSocket, []string{"-plugin-mesh-socket"}, "/run/docker/plugins/weavemesh.sock", "plugin socket on which to listen in mesh mode") + proxyConfig := configureProxy(version, defaultDockerHost) + if bridgeConfig.AWSVPC { + proxyConfig.NoMulticastRoute = true + } + // crude way of detecting that we probably have been started in a // container, with `weave launch` --> suppress misleading paths in // mflags error messages. @@ -223,19 +232,19 @@ func main() { mflag.Parse() + if justVersion { + fmt.Printf("weave %s\n", version) + os.Exit(0) + } + peers = mflag.Args() if resume && len(peers) > 0 { Log.Fatalf("You must not specify an initial peer list in conjunction with --resume") } common.SetLogLevel(logLevel) - - if justVersion { - fmt.Printf("weave router %s\n", version) - os.Exit(0) - } - Log.Println("Command line options:", options()) + Log.Infoln("weave ", version) if prof != "" { defer profile.Start(profile.CPUProfile, profile.ProfilePath(prof), profile.NoShutdownHook).Stop() @@ -246,6 +255,19 @@ func main() { } config.ProtocolMinVersion = byte(protocolMinVersion) + if proxyConfig.Enabled { + // Start Weave Proxy: + proxy, err := weaveproxy.NewProxy(*proxyConfig) + if err != nil { + Log.Fatalf("Could not start proxy: %s", err) + } + defer proxy.Stop() + listeners := proxy.Listen() + proxy.AttachExistingContainers() + go proxy.Serve(listeners) + go proxy.ListenAndServeStatus("/home/weave/status.sock") + } + if pktdebug { networkConfig.PacketLogging = packetLogging{} } else { @@ -497,6 +519,31 @@ func (nopPacketLogging) LogPacket(string, weave.PacketKey) { func (nopPacketLogging) LogForwardPacket(string, weave.ForwardPacketKey) { } +func configureProxy(version string, defaultDockerHost string) *weaveproxy.Config { + proxyConfig := weaveproxy.Config{ + Version: version, + Image: getenvOrDefault("EXEC_IMAGE", "weaveworks/weaveexec"), + DockerBridge: getenvOrDefault("DOCKER_BRIDGE", "docker0"), + DockerHost: defaultDockerHost, + } + mflag.BoolVar(&proxyConfig.Enabled, []string{"-proxy"}, false, "instruct Weave Net to start its Docker proxy") + mflagext.ListVar(&proxyConfig.ListenAddrs, []string{"H"}, nil, "addresses on which to listen for Docker proxy") + mflag.StringVar(&proxyConfig.HostnameFromLabel, []string{"-hostname-from-label"}, "", "Key of container label from which to obtain the container's hostname") + mflag.StringVar(&proxyConfig.HostnameMatch, []string{"-hostname-match"}, "(.*)", "Regexp pattern to apply on container names (e.g. '^aws-[0-9]+-(.*)$')") + mflag.StringVar(&proxyConfig.HostnameReplacement, []string{"-hostname-replacement"}, "$1", "Expression to generate hostnames based on matches from --hostname-match (e.g. 'my-app-$1')") + mflag.BoolVar(&proxyConfig.RewriteInspect, []string{"-rewrite-inspect"}, false, "Rewrite 'inspect' calls to return the weave network settings (if attached)") + mflag.BoolVar(&proxyConfig.NoDefaultIPAM, []string{"#-no-default-ipam", "-no-default-ipalloc"}, false, "proxy: do not automatically allocate addresses for containers without a WEAVE_CIDR") + mflag.BoolVar(&proxyConfig.NoRewriteHosts, []string{"-no-rewrite-hosts"}, false, "proxy: do not automatically rewrite /etc/hosts. Use if you need the docker IP to remain in /etc/hosts") + mflag.StringVar(&proxyConfig.TLSConfig.CACert, []string{"#tlscacert", "-tlscacert"}, "", "Trust certs signed only by this CA") + mflag.StringVar(&proxyConfig.TLSConfig.Cert, []string{"#tlscert", "-tlscert"}, "", "Path to TLS certificate file") + mflag.BoolVar(&proxyConfig.TLSConfig.Enabled, []string{"#tls", "-tls"}, false, "Use TLS; implied by --tlsverify") + mflag.StringVar(&proxyConfig.TLSConfig.Key, []string{"#tlskey", "-tlskey"}, "", "Path to TLS key file") + mflag.BoolVar(&proxyConfig.TLSConfig.Verify, []string{"#tlsverify", "-tlsverify"}, false, "Use TLS and verify the remote") + mflag.BoolVar(&proxyConfig.WithoutDNS, []string{"-without-dns"}, false, "proxy: instruct created containers to never use weaveDNS as their nameserver") + mflag.BoolVar(&proxyConfig.NoMulticastRoute, []string{"-no-multicast-route"}, false, "proxy: do not add a multicast route via the weave interface when attaching containers") + return &proxyConfig +} + func createOverlay(bridgeType weavenet.Bridge, config weavenet.BridgeConfig, host string, port int, bufSzMB int, enableEncryption bool) (weave.NetworkOverlay, weave.InjectorConsumer) { overlay := weave.NewOverlaySwitch() var injectorConsumer weave.InjectorConsumer diff --git a/proxy/proxy.go b/proxy/proxy.go index 40e00968..53d770ee 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -50,6 +50,7 @@ func dockerAPIEndpoint(endpoint string) *regexp.Regexp { } type Config struct { + Enabled bool HostnameFromLabel string HostnameMatch string HostnameReplacement string @@ -204,7 +205,7 @@ func (proxy *Proxy) findWeaveWaitVolumes() error { } func (proxy *Proxy) findVolume(v string) (string, error) { - container, err := proxy.client.InspectContainer("weaveproxy") + container, err := proxy.client.InspectContainer("weave") if err != nil { return "", fmt.Errorf("Could not find the weavewait volume: %s", err) } diff --git a/test/090_docker_restart_policy_2_test.sh b/test/090_docker_restart_policy_2_test.sh index e1630bc9..938bd834 100755 --- a/test/090_docker_restart_policy_2_test.sh +++ b/test/090_docker_restart_policy_2_test.sh @@ -5,21 +5,15 @@ start_suite "Test docker restart policy" weave_on $HOST1 launch - -assert "docker_on $HOST1 inspect -f '{{.HostConfig.RestartPolicy.Name}}' weave weaveproxy" "always\nalways" - +assert "docker_on $HOST1 inspect -f '{{.HostConfig.RestartPolicy.Name}}' weave" "always" assert_raises "check_restart $HOST1 weave" -assert_raises "check_restart $HOST1 weaveproxy" # stop + launch tests that restart policy changes result # in the old containers being removed and new ones created weave_on $HOST1 stop weave_on $HOST1 launch --no-restart - -assert "docker_on $HOST1 inspect -f '{{.HostConfig.RestartPolicy.Name}}' weave weaveproxy" "no\nno" - +assert "docker_on $HOST1 inspect -f '{{.HostConfig.RestartPolicy.Name}}' weave weaveproxy" "no" assert_raises "! check_restart $HOST1 weave" -assert_raises "! check_restart $HOST1 weaveproxy" # Relaunch to prevent the `weave stop` in `end_suite` # timing out trying to remove the plugin network diff --git a/test/120_discovery_3_test.sh b/test/120_discovery_3_test.sh index 82f2e5d3..e0085ba2 100755 --- a/test/120_discovery_3_test.sh +++ b/test/120_discovery_3_test.sh @@ -6,9 +6,9 @@ C1=10.2.1.41 C3=10.2.1.71 launch_all() { - weave_on $HOST1 launch-router $1 - weave_on $HOST2 launch-router $1 --ipalloc-range="" $HOST1 - weave_on $HOST3 launch-router $1 $HOST2 + weave_on $HOST1 launch $1 + weave_on $HOST2 launch $1 --ipalloc-range="" $HOST1 + weave_on $HOST3 launch $1 $HOST2 } start_suite "Peer discovery, multi-hop routing and gossip forwarding" diff --git a/test/150_connect_forget_2_test.sh b/test/150_connect_forget_2_test.sh index 5c6616ef..40b7922c 100755 --- a/test/150_connect_forget_2_test.sh +++ b/test/150_connect_forget_2_test.sh @@ -16,8 +16,8 @@ assert_peers() { start_suite "Connecting and forgetting routers after launch" -weave_on $HOST1 launch-router -weave_on $HOST2 launch-router +weave_on $HOST1 launch +weave_on $HOST2 launch start_container $HOST1 $C1/24 --name=c1 start_container $HOST2 $C2/24 --name=c2 @@ -35,7 +35,7 @@ assert_raises "exec_on $HOST1 c1 $PING $C2" # Forget everyone and disconnect assert_raises "weave_on $HOST2 forget $HOST1 $HOST2" assert_raises "stop_weave_on $HOST1" -assert_raises "weave_on $HOST1 launch-router" +assert_raises "weave_on $HOST1 launch" assert_peers $HOST2 "" assert_raises "exec_on $HOST1 c1 sh -c '! $PING $C2'" diff --git a/test/195_no_multicast_route_1_test.sh b/test/195_no_multicast_route_1_test.sh index 2b057e1a..b4c1288c 100755 --- a/test/195_no_multicast_route_1_test.sh +++ b/test/195_no_multicast_route_1_test.sh @@ -12,8 +12,7 @@ start_suite "--no-multicast-route operation" $SSH $HOST1 docker network rm testmcasttrue testmcastfalse >/dev/null 2>&1 || true # Ensure containers run either way have no multicast route -weave_on $HOST1 launch-router --plugin -weave_on $HOST1 launch-proxy --no-multicast-route +weave_on $HOST1 launch --no-multicast-route docker_on $HOST1 run --name c1 -dt $SMALL_IMAGE /bin/sh weave_on $HOST1 attach --no-multicast-route c1 @@ -35,8 +34,8 @@ assert "show_multicast_route_on $HOST1 c5" "224.0.0.0/4 dev ethwe0 " # Ensure current proxy options are obeyed on container start docker_on $HOST1 stop -t 1 c2 -weave_on $HOST1 stop-proxy -weave_on $HOST1 launch-proxy +weave_on $HOST1 stop +weave_on $HOST1 launch proxy docker_on $HOST1 start c2 diff --git a/test/215_stale_dns_3_test.sh b/test/215_stale_dns_3_test.sh index d3e97749..bfabb390 100755 --- a/test/215_stale_dns_3_test.sh +++ b/test/215_stale_dns_3_test.sh @@ -4,9 +4,9 @@ start_suite "Check propagation of DNS entries when gossip is delayed" -weave_on $HOST1 launch-router --no-discovery -weave_on $HOST2 launch-router --no-discovery $HOST1 -weave_on $HOST3 launch-router --no-discovery $HOST2 +weave_on $HOST1 launch --no-discovery +weave_on $HOST2 launch --no-discovery $HOST1 +weave_on $HOST3 launch --no-discovery $HOST2 start_container $HOST1 --name=c1 C1=$(container_ip $HOST1 c1) @@ -17,10 +17,10 @@ assert_dns_record $HOST3 c3 c1.weave.local $C1 # Stall the propagation of gossip, stop weave and kill the container run_on $HOST3 "sudo iptables -A INPUT -s $HOST2 -j DROP" -weave_on $HOST1 stop-router +weave_on $HOST1 stop docker_on $HOST1 rm -f c1 -weave_on $HOST1 launch-router --no-discovery $HOST3 +weave_on $HOST1 launch --no-discovery $HOST3 # Now re-enable gossip from host2 to host3 run_on $HOST3 "sudo iptables -D INPUT -s $HOST2 -j DROP" diff --git a/test/280_with_or_without_dns_test.sh b/test/280_with_or_without_dns_test.sh index 206cfd81..7ba86452 100755 --- a/test/280_with_or_without_dns_test.sh +++ b/test/280_with_or_without_dns_test.sh @@ -22,7 +22,7 @@ check_dns() { start_suite "With or without DNS test" # Assert behaviour without weaveDNS running -weave_on $HOST1 launch-router +weave_on $HOST1 launch start_container $HOST1 $TARGET_IP/24 --name c2 -h $TARGET diff --git a/test/290_dns_fallback_test.sh b/test/290_dns_fallback_test.sh index 2161f155..b4730a12 100755 --- a/test/290_dns_fallback_test.sh +++ b/test/290_dns_fallback_test.sh @@ -4,7 +4,7 @@ start_suite "Resolve a non-weave address" -weave_on $HOST1 launch-router +weave_on $HOST1 launch start_container_with_dns $HOST1 10.2.1.5/24 --name=c1 diff --git a/test/310_docker_restart_test.sh b/test/310_docker_restart_test.sh index e2d255a3..25bf44e1 100755 --- a/test/310_docker_restart_test.sh +++ b/test/310_docker_restart_test.sh @@ -4,8 +4,7 @@ start_suite "Containers get same IP address on restart" -weave_on $HOST1 launch-router -weave_on $HOST1 launch-proxy +weave_on $HOST1 launch # Use up first address with throwaway container start_container $HOST1 --name=c1 diff --git a/test/320_claim_3_test.sh b/test/320_claim_3_test.sh index 4c135ab6..f2e5e4d2 100755 --- a/test/320_claim_3_test.sh +++ b/test/320_claim_3_test.sh @@ -15,8 +15,8 @@ delete_persistence() { start_suite "Claiming addresses" -weave_on $HOST1 launch-router --ipalloc-range $UNIVERSE $HOST2 -weave_on $HOST2 launch-router --ipalloc-range $UNIVERSE $HOST1 +weave_on $HOST1 launch --ipalloc-range $UNIVERSE $HOST2 +weave_on $HOST2 launch --ipalloc-range $UNIVERSE $HOST1 start_container $HOST1 $C1/12 --name=c1 start_container $HOST2 --name=c2 @@ -29,8 +29,8 @@ stop_weave_on $HOST2 delete_persistence $HOST1 $HOST2 # Start hosts in reverse order so c1's address has to be claimed from host2 -weave_on $HOST2 launch-router --ipalloc-range $UNIVERSE -weave_on $HOST1 launch-router --ipalloc-range $UNIVERSE $HOST2 +weave_on $HOST2 launch --ipalloc-range $UNIVERSE +weave_on $HOST1 launch --ipalloc-range $UNIVERSE $HOST2 # Start another container on host2, so if it hasn't relinquished c1's # address it would give that out as the first available. @@ -48,13 +48,13 @@ delete_persistence $HOST1 $HOST2 # Now make host1 attempt to claim from host2, when host2 is stopped # the point being to check whether host1 will hang trying to talk to host2 -weave_on $HOST2 launch-router --ipalloc-range $UNIVERSE +weave_on $HOST2 launch --ipalloc-range $UNIVERSE weave_on $HOST2 prime # Introduce host3 to remember the IPAM CRDT when we stop host2 -weave_on $HOST3 launch-router --ipalloc-range $UNIVERSE $HOST2 +weave_on $HOST3 launch --ipalloc-range $UNIVERSE $HOST2 weave_on $HOST3 prime stop_weave_on $HOST2 -weave_on $HOST1 launch-router --ipalloc-range $UNIVERSE $HOST3 +weave_on $HOST1 launch --ipalloc-range $UNIVERSE $HOST3 stop_weave_on $HOST1 stop_weave_on $HOST3 diff --git a/test/330_reset_2_test.sh b/test/330_reset_2_test.sh index 89b8dc34..6b5b95c6 100755 --- a/test/330_reset_2_test.sh +++ b/test/330_reset_2_test.sh @@ -4,17 +4,17 @@ start_suite "Rolling restart with reset" -weave_on $HOST1 launch-router -weave_on $HOST2 launch-router $HOST1 +weave_on $HOST1 launch +weave_on $HOST2 launch $HOST1 start_container $HOST1 --name=c1 start_container $HOST2 --name=c2 # Now reset the routers so they should give their space away, and restart weave_on $HOST1 reset -weave_on $HOST1 launch-router $HOST2 +weave_on $HOST1 launch $HOST2 weave_on $HOST2 reset -weave_on $HOST2 launch-router $HOST1 +weave_on $HOST2 launch $HOST1 # And try to start a container assert_raises "timeout 10 cat <( start_container $HOST1 )" diff --git a/test/360_ipalloc_seed_mismatch_3_test.sh b/test/360_ipalloc_seed_mismatch_3_test.sh index c26a9d41..304aedc8 100755 --- a/test/360_ipalloc_seed_mismatch_3_test.sh +++ b/test/360_ipalloc_seed_mismatch_3_test.sh @@ -4,9 +4,9 @@ start_suite "IPAM ring seed mismatch" -weave_on $HOST1 launch-router --no-discovery -weave_on $HOST2 launch-router --no-discovery -weave_on $HOST3 launch-router --no-discovery +weave_on $HOST1 launch --no-discovery +weave_on $HOST2 launch --no-discovery +weave_on $HOST3 launch --no-discovery # Do some allocations to get the ring initialized on two hosts start_container $HOST1 diff --git a/test/370_persist_ipam_2_test.sh b/test/370_persist_ipam_2_test.sh index 0922bb1a..257665a1 100755 --- a/test/370_persist_ipam_2_test.sh +++ b/test/370_persist_ipam_2_test.sh @@ -7,7 +7,7 @@ start_suite "Checking persistence of IPAM" launch_router_with_db() { host=$1 shift - weave_on $host launch-router "$@" + weave_on $host launch "$@" } launch_router_with_db $HOST1 $HOST2 diff --git a/test/390_peer_name_test.sh b/test/390_peer_name_test.sh index ab97e3d9..5c521d3d 100755 --- a/test/390_peer_name_test.sh +++ b/test/390_peer_name_test.sh @@ -26,7 +26,7 @@ ORIG_MACHINE_ID=$($SSH $HOST1 cat /etc/machine-id) # Blank machine-id to begin, so peername will work the same as pre-1.9 $SSH $HOST1 sudo cp /dev/null /etc/machine-id -weave_on $HOST1 launch-router +weave_on $HOST1 launch weave_on $HOST1 prime PEERNAME1=$(get_peername) @@ -34,21 +34,21 @@ PEERNAME1=$(get_peername) echo $ORIG_MACHINE_ID | $SSH $HOST1 sudo tee /etc/machine-id >/dev/null # Stop and restart; it should take the ID from the bridge -weave_on $HOST1 stop-router -weave_on $HOST1 launch-router +weave_on $HOST1 stop +weave_on $HOST1 launch assert "get_peername" "$PEERNAME1" # Stop and remove the bridge, then restart; it should take the ID from persistence -weave_on $HOST1 stop-router +weave_on $HOST1 stop remove_bridge -weave_on $HOST1 launch-router +weave_on $HOST1 launch assert "get_peername" "$PEERNAME1" # Now remove everything and restart: should get a different peer name weave_on $HOST1 reset -weave_on $HOST1 launch-router +weave_on $HOST1 launch PEERNAME3=$(get_peername) assert_raises "[ $PEERNAME3 != $PEERNAME1 ]" @@ -57,9 +57,9 @@ assert_raises "[ $PEERNAME3 != $PEERNAME1 ]" echo $ORIG_MACHINE_ID | rot8 | $SSH $HOST1 sudo tee /etc/machine-id >/dev/null # Remove bridge and restart; it should get a different ID -weave_on $HOST1 stop-router +weave_on $HOST1 stop remove_bridge -weave_on $HOST1 launch-router +weave_on $HOST1 launch assert_raises "[ $(get_peername) != $PEERNAME3 ]" diff --git a/test/500_weave_multi_cidr_test.sh b/test/500_weave_multi_cidr_test.sh index fede384f..f4b5a02f 100755 --- a/test/500_weave_multi_cidr_test.sh +++ b/test/500_weave_multi_cidr_test.sh @@ -70,7 +70,7 @@ start_suite "Weave attach/detach/expose/hide with multiple cidr arguments" # specific address, i.e. we are assuming that IPAM always returns the # lowest available address in the subnet -weave_on $HOST1 launch-router --ipalloc-range 10.2.3.0/24 +weave_on $HOST1 launch --ipalloc-range 10.2.3.0/24 # Run container with three cidrs CID=$(docker_on $HOST1 run --name=multicidr -h $NAME -dt $SMALL_IMAGE /bin/sh) diff --git a/test/600_proxy_docker_py.sh b/test/600_proxy_docker_py.sh index 8e54f2c1..dee0c2b1 100755 --- a/test/600_proxy_docker_py.sh +++ b/test/600_proxy_docker_py.sh @@ -29,7 +29,7 @@ docker_py_test() { i=$(($i + 1)) done - weave_on $HOST1 launch-proxy --no-default-ipalloc + weave_on $HOST1 launch --no-default-ipalloc DOCKER_BRIDGE_IP=$(weave_on $HOST1 docker-bridge-ip) diff --git a/test/605_proxy_inspect_test.sh b/test/605_proxy_inspect_test.sh index 919a502a..0c7d44f9 100755 --- a/test/605_proxy_inspect_test.sh +++ b/test/605_proxy_inspect_test.sh @@ -4,8 +4,7 @@ start_suite "Check that docker inspect returns the weave IP" -weave_on $HOST1 launch-router -weave_on $HOST1 launch-proxy --rewrite-inspect +weave_on $HOST1 launch --rewrite-inspect proxy docker_on $HOST1 run -dt --name c1 $SMALL_IMAGE /bin/sh inspect_format="{{.Name}} {{.NetworkSettings.MacAddress}} {{.NetworkSettings.IPAddress}}/{{.NetworkSettings.IPPrefixLen}}" diff --git a/test/610_proxy_wait_for_weave_test.sh b/test/610_proxy_wait_for_weave_test.sh index d372474d..8a57f941 100755 --- a/test/610_proxy_wait_for_weave_test.sh +++ b/test/610_proxy_wait_for_weave_test.sh @@ -18,10 +18,10 @@ BASE_IMAGE=busybox ! docker_on $HOST1 inspect --format=" " $BASE_IMAGE >/dev/null 2>&1 || docker_on $HOST1 rmi $BASE_IMAGE # check that interface is ready, with and without --no-multicast-route -weave_on $HOST1 launch-proxy --no-multicast-route +weave_on $HOST1 launch --no-multicast-route check_iface_ready 10.2.1.1/24 -weave_on $HOST1 stop-proxy -weave_on $HOST1 launch-proxy +weave_on $HOST1 stop +weave_on $HOST1 launch check_iface_ready 10.2.1.1/24 # Check committed containers only have one weavewait prepended diff --git a/test/615_proxy_rewrite_hosts_test.sh b/test/615_proxy_rewrite_hosts_test.sh index a8629aab..eefd1ba2 100755 --- a/test/615_proxy_rewrite_hosts_test.sh +++ b/test/615_proxy_rewrite_hosts_test.sh @@ -11,7 +11,7 @@ image_ip() { start_suite "Proxy rewrites hosts file" # Default rewrites the host file -weave_on $HOST1 launch-proxy +weave_on $HOST1 launch assert "image_ip $SMALL_IMAGE" $expected_ip # When container user is non-root @@ -25,8 +25,8 @@ EOF assert "image_ip non-root" $expected_ip # When rewrite hosts is disabled -weave_on $HOST1 stop-proxy -weave_on $HOST1 launch-proxy --no-rewrite-hosts +weave_on $HOST1 stop +weave_on $HOST1 launch --no-rewrite-hosts assert_raises "image_ip $SMALL_IMAGE | grep -v $expected_ip" end_suite diff --git a/test/620_proxy_entrypoint_command_test.sh b/test/620_proxy_entrypoint_command_test.sh index 748c415a..3187257f 100755 --- a/test/620_proxy_entrypoint_command_test.sh +++ b/test/620_proxy_entrypoint_command_test.sh @@ -15,7 +15,7 @@ run_container() { } start_suite "Proxy uses correct entrypoint and command with weavewait" -weave_on $HOST1 launch-proxy --no-restart +weave_on $HOST1 launch --no-restart build_image check-ethwe-up '["grep"]' '["^1$", "/sys/class/net/ethwe/carrier"]' run_container "check-ethwe-up" @@ -26,13 +26,8 @@ run_container "grep ^1$ /sys/class/net/ethwe/carrier" build_image false '["/bin/false"]' '' run_container "--entrypoint='grep' false ^1$ /sys/class/net/ethwe/carrier" -weave_on $HOST1 launch-router --ipalloc-range 10.2.2.0/24 -# NOTE: docker-kill hangs (https://github.com/docker/docker/issues/31447), so we -# kill directly the weaveproxy process instead. -WEAVEPROXY_PID=$(container_pid $HOST1 weaveproxy) -$SSH $HOST1 "ps aux | grep weaveproxy" -run_on $HOST1 "sudo kill -9 $WEAVEPROXY_PID" -weave_on $HOST1 launch-proxy +weave_on $HOST1 stop +weave_on $HOST1 launch --ipalloc-range 10.2.2.0/24 assert_raises "proxy docker_on $HOST1 run check-ethwe-up" diff --git a/test/630_proxy_dns_test.sh b/test/630_proxy_dns_test.sh index a9031afb..472c3dd7 100755 --- a/test/630_proxy_dns_test.sh +++ b/test/630_proxy_dns_test.sh @@ -23,17 +23,13 @@ start_suite "Proxy registers containers with dns" bridge_ip=$(weave_on $HOST1 docker-bridge-ip) -# Assert behaviour without weaveDNS -weave_on $HOST1 launch-proxy -do_assert_resolution assert_no_dns_record - # Assert behaviour with weaveDNS running -weave_on $HOST1 launch-router +weave_on $HOST1 launch do_assert_resolution assert_dns_record -weave_on $HOST1 stop-proxy +weave_on $HOST1 stop # Assert behaviour with weaveDNS running, but dns forced off -weave_on $HOST1 launch-proxy --without-dns +weave_on $HOST1 launch --without-dns do_assert_resolution assert_no_dns_record end_suite diff --git a/test/640_proxy_restart_reattaches_test.sh b/test/640_proxy_restart_reattaches_test.sh index 9c99a082..22c30929 100755 --- a/test/640_proxy_restart_reattaches_test.sh +++ b/test/640_proxy_restart_reattaches_test.sh @@ -49,14 +49,9 @@ assert_raises "timeout 90 cat <( run_many )" # Start a container that needs IPAM, then restart it when the router is stopped proxy_start_container $HOST1 -di --name=c3 --restart=always wait_for_attached $HOST1 c3 -weave_on $HOST1 stop-router -docker_on $HOST1 restart c3 -weave_on $HOST1 launch-router -wait_for_attached $HOST1 c3 - -# Restarting proxy shouldn't kill unattachable containers weave_on $HOST1 stop -weave_on $HOST1 launch-proxy +docker_on $HOST1 restart c3 +weave_on $HOST1 launch wait_for_attached $HOST1 c3 end_suite diff --git a/test/650_proxy_env_test.sh b/test/650_proxy_env_test.sh index 53969180..00a01e73 100755 --- a/test/650_proxy_env_test.sh +++ b/test/650_proxy_env_test.sh @@ -15,22 +15,21 @@ start_suite "Configure the docker daemon for the proxy" assert "weave_on $HOST1 env" "" assert "weave_on $HOST1 config" "" -weave_on $HOST1 launch-proxy +weave_on $HOST1 launch check # Check we can use the weave script through the proxy assert_raises "eval '$(weave_on $HOST1 env)' ; $WEAVE version" assert_raises "eval '$(weave_on $HOST1 env)' ; $WEAVE ps" -assert_raises "eval '$(weave_on $HOST1 env)' ; $WEAVE launch-router" # Check we can use weave env/config with multiple -Hs specified weave_on $HOST1 stop -weave_on $HOST1 launch-proxy -H tcp://0.0.0.0:12375 -H unix:///var/run/weave/weave.sock +weave_on $HOST1 launch -H tcp://0.0.0.0:12375 -H unix:///var/run/weave/weave.sock check # Check we can use weave env/config with unix -Hs specified weave_on $HOST1 stop -weave_on $HOST1 launch-proxy -H unix:///var/run/weave/weave.sock +weave_on $HOST1 launch -H unix:///var/run/weave/weave.sock assert_raises "run_on $HOST1 'eval \$(weave env) ; docker $CMD'" assert_raises "run_on $HOST1 'docker \$(weave config) $CMD'" diff --git a/test/655_proxy_large_http_chunks_test.sh b/test/655_proxy_large_http_chunks_test.sh index ca540acb..a51006ae 100755 --- a/test/655_proxy_large_http_chunks_test.sh +++ b/test/655_proxy_large_http_chunks_test.sh @@ -17,7 +17,7 @@ done # Sanity-check that it's big enough to cause issues. assert_raises "test $(curl -s http://$HOST1:$DOCKER_PORT/v1.19/images/json?all=true | wc -c) -gt 65536" -weave_on $HOST1 launch-proxy +weave_on $HOST1 launch assert_raises "proxy docker_on $HOST1 images -a" diff --git a/test/660_proxy_ipam_2_test.sh b/test/660_proxy_ipam_2_test.sh index 5d80871d..1d2a6849 100755 --- a/test/660_proxy_ipam_2_test.sh +++ b/test/660_proxy_ipam_2_test.sh @@ -11,10 +11,8 @@ assert_no_ethwe() { start_suite "Ping proxied containers over cross-host weave network (with IPAM)" -weave_on $HOST1 launch-router --ipalloc-range $UNIVERSE -weave_on $HOST2 launch-router --ipalloc-range $UNIVERSE $HOST1 -weave_on $HOST1 launch-proxy -weave_on $HOST2 launch-proxy --no-default-ipalloc +weave_on $HOST1 launch --ipalloc-range $UNIVERSE +weave_on $HOST2 launch --ipalloc-range $UNIVERSE --no-default-ipalloc $HOST1 proxy_start_container $HOST1 --name=auto proxy_start_container $HOST1 --name=none -e WEAVE_CIDR=none diff --git a/test/670_proxy_tls_test.sh b/test/670_proxy_tls_test.sh index 470dc8d9..afc941d3 100755 --- a/test/670_proxy_tls_test.sh +++ b/test/670_proxy_tls_test.sh @@ -6,8 +6,7 @@ start_suite "Boot the proxy with TLS-enabled Docker support" PWD=$($SSH $HOST1 pwd) -weave_on $HOST1 launch-router -weave_on $HOST1 launch-proxy \ +weave_on $HOST1 launch \ --tlsverify \ --tlscacert $PWD/tls/ca.pem \ --tlscert $PWD/tls/$HOST1.pem \ diff --git a/test/680_proxy_hostname_derivation_test.sh b/test/680_proxy_hostname_derivation_test.sh index e1729511..b3d53bfa 100755 --- a/test/680_proxy_hostname_derivation_test.sh +++ b/test/680_proxy_hostname_derivation_test.sh @@ -33,18 +33,16 @@ check_dns_records() { } test_setup() { - weave_on $HOST1 launch-proxy $@ + weave_on $HOST1 launch $@ } test_cleanup() { - weave_on $HOST1 stop-proxy + weave_on $HOST1 stop } start_suite "Hostname derivation" -weave_on $HOST1 launch-router - # Hostname derivation through container name substitutions test_setup --hostname-match '^[^-]+-(?P[^-]*)-[^-]+$' --hostname-replacement '$appname' # check that the normal container_name->hostname derivation doesn't break diff --git a/test/690_proxy_config_test.sh b/test/690_proxy_config_test.sh index 8797e3f8..cac1073c 100755 --- a/test/690_proxy_config_test.sh +++ b/test/690_proxy_config_test.sh @@ -2,45 +2,45 @@ . "$(dirname "$0")/config.sh" -start_suite "Various launch-proxy configurations" +start_suite "Various proxy configurations" # Booting it over unix socket listens on unix socket -run_on $HOST1 COVERAGE=$COVERAGE weave launch-proxy +run_on $HOST1 COVERAGE=$COVERAGE weave launch assert_raises "run_on $HOST1 sudo docker -H unix:///var/run/weave/weave.sock ps" assert_raises "proxy docker_on $HOST1 ps" 1 -weave_on $HOST1 stop-proxy +weave_on $HOST1 stop # Booting it over tcp listens on tcp -weave_on $HOST1 launch-proxy +weave_on $HOST1 launch assert_raises "run_on $HOST1 sudo docker -H unix:///var/run/weave/weave.sock ps" 1 assert_raises "proxy docker_on $HOST1 ps" -weave_on $HOST1 stop-proxy +weave_on $HOST1 stop # Booting it over tcp (no prefix) listens on tcp -DOCKER_HOST=tcp://$HOST1:$DOCKER_PORT $WEAVE launch-proxy +DOCKER_HOST=tcp://$HOST1:$DOCKER_PORT $WEAVE launch assert_raises "run_on $HOST1 sudo docker -H unix:///var/run/weave/weave.sock ps" 1 assert_raises "proxy docker_on $HOST1 ps" -weave_on $HOST1 stop-proxy +weave_on $HOST1 stop # Booting it with -H outside /var/run/weave, still works socket="$($SSH $HOST1 mktemp -d)/weave.sock" -weave_on $HOST1 launch-proxy -H unix://$socket +weave_on $HOST1 launch -H unix://$socket assert_raises "run_on $HOST1 sudo docker -H unix:///$socket ps" 0 -weave_on $HOST1 stop-proxy +weave_on $HOST1 stop # Booting it against non-standard docker unix sock -run_on $HOST1 "DOCKER_HOST=unix:///var/run/alt-docker.sock COVERAGE=$COVERAGE weave launch-proxy -H tcp://0.0.0.0:12375" +run_on $HOST1 "DOCKER_HOST=unix:///var/run/alt-docker.sock COVERAGE=$COVERAGE weave launch -H tcp://0.0.0.0:12375" assert_raises "proxy docker_on $HOST1 ps" -weave_on $HOST1 stop-proxy +weave_on $HOST1 stop # Booting it over tls errors -assert_raises "! DOCKER_CLIENT_ARGS='--tls' weave_on $HOST1 launch-proxy" -assert_raises "! DOCKER_CERT_PATH='./tls' DOCKER_TLS_VERIFY=1 weave_on $HOST1 launch-proxy" +assert_raises "! DOCKER_CLIENT_ARGS='--tls' weave_on $HOST1 launch" +assert_raises "! DOCKER_CERT_PATH='./tls' DOCKER_TLS_VERIFY=1 weave_on $HOST1 launch" # Booting it with a specific -H overrides defaults -weave_on $HOST1 launch-proxy -H tcp://0.0.0.0:12345 +weave_on $HOST1 launch -H tcp://0.0.0.0:12345 assert_raises "run_on $HOST1 sudo docker -H tcp://$HOST1:12345 ps" assert_raises "proxy docker_on $HOST1 ps" 1 -weave_on $HOST1 stop-proxy +weave_on $HOST1 stop end_suite diff --git a/test/695_proxy_failure_modes_test.sh b/test/695_proxy_failure_modes_test.sh deleted file mode 100755 index 56c5e953..00000000 --- a/test/695_proxy_failure_modes_test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -. "$(dirname "$0")/config.sh" - -start_suite "Proxy failure modes" - -# docker run should fail when weave router is not running -weave_on $HOST1 launch-proxy -assert_raises "! proxy docker_on $HOST1 run --rm $SMALL_IMAGE true" -assert_raises "proxy docker_on $HOST1 run --rm $SMALL_IMAGE true 2>&1 1>/dev/null | grep 'Error response from daemon: weave container is not present. Have you launched it?'" - -end_suite diff --git a/test/810_plugin_router_restart_test.sh b/test/810_plugin_router_restart_test.sh index 48ee230a..0c54f6b1 100755 --- a/test/810_plugin_router_restart_test.sh +++ b/test/810_plugin_router_restart_test.sh @@ -10,8 +10,8 @@ weave_on $HOST1 launch start_container_local_plugin $HOST1 --name=c1 --hostname=$C1_NAME c1ip=$(container_ip $HOST1 c1) -weave_on $HOST1 stop-router -weave_on $HOST1 launch-router +weave_on $HOST1 stop +weave_on $HOST1 launch assert "container_ip $HOST1 c1" "$c1ip" assert "weave_on $HOST1 dns-lookup $C1_NAME" "$c1ip" diff --git a/test/830_cni_plugin_test.sh b/test/830_cni_plugin_test.sh index dd6dc7fd..92a0bc1c 100755 --- a/test/830_cni_plugin_test.sh +++ b/test/830_cni_plugin_test.sh @@ -90,7 +90,7 @@ assert_raises "exec_on $HOST1 c1 $PING $C3IP" stop_weave_on $HOST1 # Ensure no warning is printed to the standard error: -ACTUAL_OUTPUT=$(CHECKPOINT_DISABLE="$CHECKPOINT_DISABLE" DOCKER_HOST=tcp://$HOST1:$DOCKER_PORT $WEAVE launch-router 2>&1) +ACTUAL_OUTPUT=$(CHECKPOINT_DISABLE="$CHECKPOINT_DISABLE" DOCKER_HOST=tcp://$HOST1:$DOCKER_PORT $WEAVE launch 2>&1) EXPECTED_OUTPUT=$($SSH $HOST1 docker inspect --format="{{.Id}}" weave) assert_raises "[ $EXPECTED_OUTPUT == $ACTUAL_OUTPUT ]" diff --git a/test/config.sh b/test/config.sh index 38c59b54..d25c9152 100644 --- a/test/config.sh +++ b/test/config.sh @@ -136,7 +136,7 @@ stop_weave_on() { host=$1 weave_on $host stop 1>/dev/null 2>&1 || true if [ -n "$COVERAGE" ]; then - for C in weaveplugin weaveproxy weave ; do + for C in weaveplugin weave ; do collect_coverage $host $C done fi diff --git a/weave b/weave index 6dfe0f90..91b34c40 100755 --- a/weave +++ b/weave @@ -42,23 +42,21 @@ weave --help | help setup version -weave launch - launch-router [--password ] [--trusted-subnets ,...] - [--host ] - [--name ] [--nickname ] - [--no-restart] [--resume] [--no-discovery] [--no-dns] - [--ipalloc-init ] - [--ipalloc-range [--ipalloc-default-subnet ]] - [--plugin] - [--log-level=debug|info|warning|error] - ... - launch-proxy [-H ] [--without-dns] [--no-multicast-route] - [--no-rewrite-hosts] [--no-default-ipalloc] [--no-restart] - [--hostname-from-label ] - [--hostname-match ] - [--hostname-replacement ] - [--rewrite-inspect] - [--log-level=debug|info|warning|error] +weave launch [--password ] [--trusted-subnets ,...] + [--host ] + [--name ] [--nickname ] + [--no-restart] [--resume] [--no-discovery] [--no-dns] + [--ipalloc-init ] + [--ipalloc-range [--ipalloc-default-subnet ]] + [--plugin=false] [--proxy=false] + [-H ] [--without-dns] [--no-multicast-route] + [--no-rewrite-hosts] [--no-default-ipalloc] + [--hostname-from-label ] + [--hostname-match ] + [--hostname-replacement ] + [--rewrite-inspect] + [--log-level=debug|info|warning|error] + ... weave prime @@ -87,13 +85,10 @@ weave status [targets | connections | peers | dns | ipam] ps [ ...] weave stop - stop-router - stop-proxy weave reset [--force] rmpeer ... - where = [:] = / = [ip:] | net: | net:default @@ -131,7 +126,7 @@ docker_run_options() { exec_options() { case "$1" in - setup|setup-cni|launch|launch-router) + setup|setup-cni|launch) echo -v /:/host -e HOST_ROOT=/host ;; # All the other commands that may create the bridge and need machine id files. @@ -151,7 +146,6 @@ exec_remote() { -e WEAVE_VERSION \ -e WEAVE_DEBUG \ -e WEAVE_DOCKER_ARGS \ - -e WEAVEPROXY_DOCKER_ARGS \ -e WEAVEPLUGIN_DOCKER_ARGS \ -e WEAVE_PASSWORD \ -e WEAVE_PORT \ @@ -285,7 +279,7 @@ PORT=${WEAVE_PORT:-6783} HTTP_ADDR=${WEAVE_HTTP_ADDR:-127.0.0.1:6784} STATUS_ADDR=${WEAVE_STATUS_ADDR:-127.0.0.1:6782} PROXY_PORT=12375 -PROXY_CONTAINER_NAME=weaveproxy +OLD_PROXY_CONTAINER_NAME=weaveproxy PROC_PATH="/proc" COVERAGE_ARGS="" [ -n "$COVERAGE" ] && COVERAGE_ARGS="-test.coverprofile=/home/weave/cover.prof --" @@ -634,10 +628,6 @@ check_not_running() { esac } -stop() { - docker stop $1 >/dev/null 2>&1 || echo "$2 is not running." >&2 -} - # Given a container name or short ID in $1, ensure the specified # container exists and then print its full ID to stdout. If # it doesn't exist, print an error to stderr and @@ -1133,10 +1123,11 @@ host_arg() { fi PROXY_VOLUMES="$PROXY_VOLUMES -v /var/run/weave:/var/run/weave" fi - PROXY_ARGS="$PROXY_ARGS -H $1" + PROXY_ARGS="-H $1 $PROXY_ARGS" } proxy_parse_args() { + args="" while [ $# -gt 0 ]; do case "$1" in -H) @@ -1178,11 +1169,13 @@ proxy_parse_args() { RESTART_POLICY= ;; *) - PROXY_ARGS="$PROXY_ARGS $1" + args="$args $1" ;; esac shift done + # Merge proxy options and other args, keeping $args at the end, as these could contain peers: + PROXY_ARGS="$PROXY_ARGS $args" } proxy_args() { @@ -1196,7 +1189,7 @@ proxy_args() { if [ -z "$PROXY_TLS_ENABLED" -a -z "$PROXY_TLS_DETECTION_DISABLED" ] ; then if ! DOCKER_TLS_ARGS=$(util_op docker-tls-args) ; then echo -n "Warning: unable to detect proxy TLS configuration. To enable TLS, " >&2 - echo -n "launch the proxy with 'weave launch-proxy' and supply TLS options. " >&2 + echo -n "launch the proxy with 'weave launch' and supply TLS options. " >&2 echo "To suppress this warning, supply the '--no-detect-tls' option." >&2 else proxy_parse_args $DOCKER_TLS_ARGS @@ -1216,11 +1209,10 @@ proxy_args() { } proxy_addrs() { - if addr="$(http_call_unix $PROXY_CONTAINER_NAME status.sock GET /status 2>/dev/null)" ; then + if addr="$(http_call_unix $CONTAINER_NAME status.sock GET /status 2>/dev/null)" ; then echo "$addr" | sed "s/0.0.0.0/$PROXY_HOST/g" - else - echo "$PROXY_CONTAINER_NAME container is not present. Have you launched it?" >&2 + echo "$CONTAINER_NAME container is not present. Have you launched it?" >&2 return 1 fi } @@ -1240,28 +1232,7 @@ warn_if_stopping_proxy_in_env() { # launch helpers ###################################################################### -common_launch_args() { - args="" - while [ $# -gt 0 ] ; do - case "$1" in - --no-restart) - args="$args $1" - ;; - --log-level) - [ $# -gt 1 ] || usage - args="$args $1 $2" - shift - ;; - --log-level=*) - args="$args $1" - ;; - esac - shift - done - echo "$args" -} - -launch_router() { +launch() { LAUNCHING_ROUTER=1 check_forwarding_rules @@ -1311,10 +1282,6 @@ launch_router() { --no-restart) RESTART_POLICY= ;; - --awsvpc) - AWSVPC_ARGS="--awsvpc" - AWSVPC=1 - ;; --plugin) PLUGIN_ARGS="--plugin" ENABLE_PLUGIN=1 @@ -1368,45 +1335,6 @@ launch_router() { RESOLV_CONF_DIR=$(dirname "$RESOLV_CONF") RESOLV_CONF_BASE=$(basename "$RESOLV_CONF") - # Set WEAVE_DOCKER_ARGS in the environment in order to supply - # additional parameters, such as resource limits, to docker - # when launching the weave container. - ROUTER_CONTAINER=$(docker run -d --name=$CONTAINER_NAME \ - $(docker_run_options) \ - $RESTART_POLICY \ - --pid=host \ - --volumes-from $DB_CONTAINER_NAME \ - -v $RESOLV_CONF_DIR:/var/run/weave/etc \ - -v /run/docker/plugins:/run/docker/plugins \ - -v /etc:/host/etc -v /var/lib/dbus:/host/var/lib/dbus \ - -e WEAVE_PASSWORD \ - -e CHECKPOINT_DISABLE \ - $WEAVE_DOCKER_ARGS $IMAGE $COVERAGE_ARGS \ - --port $CONTAINER_PORT --nickname "$(hostname)" \ - --host-root=/host \ - $(router_bridge_opts) \ - --ipalloc-range "$IPRANGE" \ - --dns-effective-listen-address $DOCKER_BRIDGE_IP \ - $DNS_ROUTER_OPTS $NO_DNS_OPT \ - $AWSVPC_ARGS \ - $PLUGIN_ARGS \ - --http-addr $HTTP_ADDR \ - --status-addr $STATUS_ADDR \ - --resolv-conf "/var/run/weave/etc/$RESOLV_CONF_BASE" \ - "$@") - wait_for_status $CONTAINER_NAME http_call $HTTP_ADDR -} - -stop_router() { - ! is_plugin_v1_enabled || util_op remove-plugin-network weave || true - stop $CONTAINER_NAME "Weave" - conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true -} - -launch_proxy() { - # Set WEAVEPROXY_DOCKER_ARGS in the environment in order to supply - # additional parameters, such as resource limits, to docker - # when launching the weaveproxy container. docker_client_args $DOCKER_CLIENT_ARGS proxy_args "$@" mkdir -p /var/run/weave @@ -1416,28 +1344,50 @@ launch_proxy() { docker create -v /w -v /w-noop -v /w-nomcast --name=$VOLUMES_CONTAINER_NAME \ --label=weavevolumes --entrypoint=/bin/false $EXEC_IMAGE >/dev/null fi - detect_awsvpc - [ -n "$AWSVPC" ] && PROXY_ARGS="$PROXY_ARGS --no-multicast-route" - PROXY_CONTAINER=$(docker run -d --name=$PROXY_CONTAINER_NAME \ + + # Set WEAVE_DOCKER_ARGS in the environment in order to supply + # additional parameters, such as resource limits, to docker + # when launching the weave container. + WEAVE_CONTAINER=$(docker run -d --name=$CONTAINER_NAME \ $(docker_run_options) \ $RESTART_POLICY \ --pid=host \ - $PROXY_VOLUMES \ + --volumes-from $DB_CONTAINER_NAME \ --volumes-from $VOLUMES_CONTAINER_NAME \ + $PROXY_VOLUMES \ -v /var/run/weave:/var/run/weave \ + -v $RESOLV_CONF_DIR:/var/run/weave/etc \ + -v /run/docker/plugins:/run/docker/plugins \ + -v /etc:/host/etc -v /var/lib/dbus:/host/var/lib/dbus \ -e DOCKER_BRIDGE \ -e WEAVE_DEBUG \ -e COVERAGE \ -e WEAVE_HTTP_ADDR \ -e EXEC_IMAGE=$EXEC_IMAGE \ - --entrypoint=/home/weave/weaveproxy \ - $WEAVEPROXY_DOCKER_ARGS $EXEC_IMAGE $COVERAGE_ARGS $PROXY_ARGS) - wait_for_status $PROXY_CONTAINER_NAME http_call_unix $PROXY_CONTAINER_NAME status.sock + -e WEAVE_PASSWORD \ + -e CHECKPOINT_DISABLE \ + $WEAVE_DOCKER_ARGS \ + $IMAGE \ + $COVERAGE_ARGS \ + --port $CONTAINER_PORT --nickname "$(hostname)" \ + --host-root=/host \ + $(router_bridge_opts) \ + --ipalloc-range "$IPRANGE" \ + --dns-effective-listen-address $DOCKER_BRIDGE_IP \ + $DNS_ROUTER_OPTS $NO_DNS_OPT \ + $PLUGIN_ARGS \ + --http-addr $HTTP_ADDR \ + --status-addr $STATUS_ADDR \ + --resolv-conf "/var/run/weave/etc/$RESOLV_CONF_BASE" \ + $PROXY_ARGS) + wait_for_status $CONTAINER_NAME http_call $HTTP_ADDR } -stop_proxy() { +stop() { + ! is_plugin_v1_enabled || util_op remove-plugin-network weave || true warn_if_stopping_proxy_in_env - stop $PROXY_CONTAINER_NAME "Proxy" + docker stop $CONTAINER_NAME >/dev/null 2>&1 || echo "Weave is not running." >&2 + conntrack -D -p udp --dport $PORT >/dev/null 2>&1 || true } protect_against_docker_hang() { @@ -1521,7 +1471,6 @@ case "$COMMAND" in version) [ $# -eq 0 ] || usage ask_version $CONTAINER_NAME $IMAGE || true - ask_version $PROXY_CONTAINER_NAME $EXEC_IMAGE --entrypoint=/home/weave/weaveproxy || true ;; # intentionally undocumented since it assumes knowledge of weave # internals @@ -1553,25 +1502,10 @@ EOF launch) deprecation_warnings "$@" check_not_running router $CONTAINER_NAME $BASE_IMAGE - check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE check_not_running_plugin_v2 - COMMON_ARGS=$(common_launch_args "$@") - launch_router --plugin "$@" - launch_proxy $COMMON_ARGS - ;; - launch-router) - deprecation_warnings "$@" - check_not_running router $CONTAINER_NAME $BASE_IMAGE - check_not_running_plugin_v2 - launch_router "$@" - echo $ROUTER_CONTAINER - ;; - launch-proxy) - deprecation_warnings "$@" - check_not_running proxy $PROXY_CONTAINER_NAME $BASE_EXEC_IMAGE - check_not_running_plugin_v2 - launch_proxy "$@" - echo $PROXY_CONTAINER + # Plugin and proxy are started by default. Should users additionally pass --plugin=false or --proxy=false, their overrides will take precedence when parsed by Go. + launch --plugin --proxy "$@" + echo "$WEAVE_CONTAINER" ;; env) if PROXY_ADDR=$(proxy_addr) ; then @@ -1607,7 +1541,7 @@ EOF echo "Invalid 'weave status' sub-command: $SUB_COMMAND" >&2 usage fi - if [ -z "$SUB_STATUS" ] && check_running $PROXY_CONTAINER_NAME 2>/dev/null && PROXY_ADDRS=$(proxy_addrs) ; then + if [ -z "$SUB_STATUS" ] && PROXY_ADDRS=$(proxy_addrs) ; then echo echo " Service: proxy" echo " Address: $PROXY_ADDRS" @@ -1632,7 +1566,7 @@ EOF call_weave GET /report -H 'Accept: application/json' fi ;; - run|start|restart|launch-plugin|stop-plugin) + run|start|restart|launch-plugin|stop-plugin|launch-proxy|stop-proxy|launch-router|stop-router) echo "The 'weave $COMMAND' command has been removed as of Weave Net version 2.0" >&2 echo "Please see release notes for further information" >&2 exit 1 @@ -1759,18 +1693,10 @@ EOF ;; stop) [ $# -eq 0 ] || usage - stop_router - stop_proxy - # In case user has upgraded from /dev/null 2>&1 || true - ;; - stop-router) - [ $# -eq 0 ] || usage - stop_router - ;; - stop-proxy) - [ $# -eq 0 ] || usage - stop_proxy + docker stop $OLD_PROXY_CONTAINER_NAME >/dev/null 2>&1 || true ;; reset) [ $# -eq 0 ] || [ $# -eq 1 -a "$1" = "--force" ] || usage @@ -1792,7 +1718,7 @@ EOF exit 1 ;; esac - for NAME in $CONTAINER_NAME $PROXY_CONTAINER_NAME $OLD_PLUGIN_CONTAINER_NAME ; do + for NAME in $CONTAINER_NAME $OLD_PROXY_CONTAINER_NAME $OLD_PLUGIN_CONTAINER_NAME ; do docker stop $NAME >/dev/null 2>&1 || true docker rm -f $NAME >/dev/null 2>&1 || true done