Remove 'weave run', 'start' and 'restart'

Replace with informative message.
Also fix up tests which were calling these commands.
This commit is contained in:
Bryan Boreham authored and Marc CARRE committed 2017-04-12 12:15:37 +01:00
1 parent 19a31a5b82
commit 98e6571059
11 files changed
+72 -193

No files matched your search

+3 -2
View File
@@ -27,8 +27,9 @@ start_container $HOST2 net:$SUBNET_2 --name=c6
C6=$(container_ip $HOST2 c6)
assert_raises "exec_on $HOST1 c5 $PING $C6"
# check that restart retains the same IP, and reclaims it in IPAM
weave_on $HOST2 restart c6
# check that restart+attach retains the same IP, and reclaims it in IPAM
docker_on $HOST2 restart c6
weave_on $HOST2 attach net:$SUBNET_2 c6
assert_raises "exec_on $HOST1 c5 $PING $C6"
# check that restart does not create any additional DNS entry
assert "weave_on $HOST2 report -f \"{{len .DNS.Entries}}\"" "6"
+4 -2
View File
@@ -15,10 +15,12 @@ weave_local_on $HOST1 reset
weave_local_on $HOST1 launch --ipalloc-range 10.2.5.0/24
assert_raises "docker_on $HOST1 ps | grep weave"
weave_local_on $HOST1 run 10.2.6.5/24 -ti --name=c1 $SMALL_IMAGE /bin/sh
docker_on $HOST1 run -dti --name=c1 $SMALL_IMAGE /bin/sh
weave_local_on $HOST1 attach 10.2.6.5/24 c1
wait_for_attached $HOST1 c1
weave_local_on $HOST1 run -ti --name=c2 $SMALL_IMAGE /bin/sh
docker_on $HOST1 run -dti --name=c2 $SMALL_IMAGE /bin/sh
weave_local_on $HOST1 attach c2
wait_for_attached $HOST1 c2
assert "weave_local_on $HOST1 ps | wc -l" 3
+2 -1
View File
@@ -16,7 +16,8 @@ weave_on $HOST1 launch-router
weave_on $HOST1 launch-proxy --no-multicast-route
weave_on $HOST1 launch-plugin # plugin defaults to multicast off except for 'net=weave'
start_container $HOST1 --no-multicast-route --name c1
docker_on $HOST1 run --name c1 -dt $SMALL_IMAGE /bin/sh
weave_on $HOST1 attach --no-multicast-route c1
proxy_start_container $HOST1 --name c2
start_container_local_plugin $HOST1 --name=c3
-6
View File
@@ -12,12 +12,6 @@ assert "weave_on $HOST1 dns-args" ""
C=$(start_container_with_dns $HOST1 $C1/24 --name=c1)
# hostname is left untouched; equals short container id
assert "exec_on $HOST1 c1 hostname" $(echo $C | cut -c1-12)
# domainname is left empty
assert "exec_on $HOST1 c1 dnsdomainname" ""
# external name resolution works
assert_raises "exec_on $HOST1 c1 getent hosts www.weave.works"
-4
View File
@@ -26,8 +26,4 @@ docker_on $HOST1 run $DOPTS -dt $SMALL_IMAGE /bin/sh
weave_on $HOST1 attach $C2/24 c2
check
docker_on $HOST1 create $DOPTS -t $SMALL_IMAGE /bin/sh
weave_on $HOST1 start $C2/24 c2
check
end_suite
-4
View File
@@ -34,8 +34,4 @@ assert_expected_fqdn "$HOSTNAME" -h $HOSTNAME --name=$NAME
assert_expected_fqdn "$HOSTNAME" --hostname=$HOSTNAME --name=$NAME
assert_expected_fqdn "$HOSTNAME" --hostname $HOSTNAME --name=$NAME
# Ensure we can launch a container with a name that is too long for hostname derivation
SIXTY_FIVE_CHARS=01234567890123456789012345678901234567890123456789012345678901234
assert_raises "start_container $HOST1 --name=$SIXTY_FIVE_CHARS"
end_suite
+2 -1
View File
@@ -12,7 +12,8 @@ check_dns() {
chk=$1
shift
container=$(weave_on $HOST1 run $@ $IP/24 -t --add-host=$STATIC:$STATIC_IP $DNS_IMAGE /bin/sh)
container=$(docker_on $HOST1 run $(dns_args $HOST1 "$@") -dt $DNS_IMAGE /bin/sh)
weave_on $HOST1 attach $IP/24 "$@" --rewrite-hosts --add-host=$STATIC:$STATIC_IP $container
$chk $HOST1 $container $TARGET
assert_dns_record $HOST1 $container $STATIC $STATIC_IP
rm_containers $HOST1 $container
+3 -10
View File
@@ -62,7 +62,7 @@ assert_equal() {
assert "echo $result" "$expected"
}
start_suite "Weave run/start/attach/detach/expose/hide with multiple cidr arguments"
start_suite "Weave attach/detach/expose/hide with multiple cidr arguments"
# also check that these commands understand all address flavours
@@ -73,15 +73,8 @@ start_suite "Weave run/start/attach/detach/expose/hide with multiple cidr argume
weave_on $HOST1 launch-router --ipalloc-range 10.2.3.0/24
# Run container with three cidrs
CID=$(start_container $HOST1 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 --name=multicidr -h $NAME)
assert_ips_and_dns $HOST1 $CID $NAME. 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24
# Stop the container
docker_on $HOST1 stop -t 1 $CID
assert_ips_and_dns $HOST1 $CID $NAME.
# Restart with three IPs
weave_on $HOST1 start 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 $CID
CID=$(docker_on $HOST1 run --name=multicidr -h $NAME -dt $SMALL_IMAGE /bin/sh)
weave_on $HOST1 attach 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 $CID
assert_ips_and_dns $HOST1 $CID $NAME. 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24
# Remove two of them
-15
View File
@@ -1,15 +0,0 @@
#! /bin/bash
. "$(dirname "$0")/config.sh"
C1=10.2.1.13
start_suite "Start containers with 'weave run' via proxy"
weave_on $HOST1 launch
proxy start_container $HOST1 $C1/24 --name=c1
# check we get exactly one IP back, the one specified
assert "weave_on $HOST1 ps c1 | cut -d ' ' -f 3-" $C1/24
end_suite
+53 -6
View File
@@ -46,6 +46,15 @@ DOCKER_PORT=2375
CHECKPOINT_DISABLE=true
# The regexp here is far from precise, but good enough. (taken from weave script)
IP_REGEXP="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
CIDR_REGEXP="(ip:|net:)?$IP_REGEXP/[0-9]{1,2}"
is_cidr() {
[ $1 = "net:default" ] && return
echo "$1" | grep -E "^$CIDR_REGEXP$" >/dev/null
}
upload_executable() {
host=$1
file=$2
@@ -140,16 +149,54 @@ exec_on() {
docker -H tcp://$host:$DOCKER_PORT exec $container "$@"
}
# Look through 'docker run' args and try to make the hostname match the name
dns_args() {
local host=$1 NAME_ARG="" HOSTNAME_SPECIFIED=""
shift
weave_on $host dns-args "$@"
while [ $# -gt 0 ] ; do
case "$1" in
--name)
NAME_ARG="$2"
shift
;;
--name=*)
NAME_ARG="${1#*=}"
;;
-h|--hostname|--hostname=*)
HOSTNAME_SPECIFIED=1
;;
esac
shift
done
if [ -n "$NAME_ARG" -a -z "$HOSTNAME_SPECIFIED" ] ; then
echo " --hostname=$NAME_ARG.weave.local"
fi
}
start_container_image() {
local image=$1 host=$2 cidr="" weave_dns_args="" container
shift 2
if [ "$1" = "--without-dns" ] ; then
shift
else
weave_dns_args=$(dns_args $host "$@")
fi
is_cidr $1 && { cidr=$1; shift; }
container=$(docker_on $host run $weave_dns_args $name_args "$@" -dt $image /bin/sh)
if ! weave_on $host attach $cidr $container >/dev/null ; then
docker_on $host rm -f $container
return 1
fi
echo $container
}
start_container() {
host=$1
shift 1
weave_on $host run "$@" -t $SMALL_IMAGE /bin/sh
start_container_image $SMALL_IMAGE "$@"
}
start_container_with_dns() {
host=$1
shift 1
weave_on $host run "$@" -t $DNS_IMAGE /bin/sh
start_container_image $DNS_IMAGE "$@"
}
start_container_local_plugin() {
+5 -142
View File
@@ -70,12 +70,8 @@ weave env [--restore]
weave connect [--replace] [<peer> ...]
forget <peer> ...
weave run [--without-dns] [--no-rewrite-hosts] [--no-multicast-route]
[<addr> ...] <docker run args> ...
start [<addr> ...] <container_id>
attach [<addr> ...] <container_id>
weave attach [<addr> ...] <container_id>
detach [<addr> ...] <container_id>
restart <container_id>
weave expose [<addr> ...] [-h <fqdn>]
hide [<addr> ...]
@@ -223,33 +219,6 @@ collect_cidr_args() {
done
}
dns_arg_count() {
if [ "$1" = "--with-dns" -o "$1" = "--without-dns" ] ; then
echo 1
else
echo 0
fi
}
extra_hosts_args() {
DNS_EXTRA_HOSTS=
DNS_EXTRA_HOSTS_ARGS=
while [ $# -gt 0 ] ; do
case "$1" in
--add-host)
DNS_EXTRA_HOSTS="$2 $DNS_EXTRA_HOSTS"
DNS_EXTRA_HOSTS_ARGS="--add-host=$2 $DNS_EXTRA_HOSTS_ARGS"
shift
;;
--add-host=*)
DNS_EXTRA_HOSTS="${1#*=} $DNS_EXTRA_HOSTS"
DNS_EXTRA_HOSTS_ARGS="--add-host=${1#*=} $DNS_EXTRA_HOSTS_ARGS"
;;
esac
shift
done
}
kill_container() {
docker kill $1 >/dev/null 2>&1 || true
}
@@ -281,46 +250,6 @@ elif [ "$1" = "env" -a "$2" = "--restore" ] ; then
echo "DOCKER_HOST=$ORIG_DOCKER_HOST"
exit 0
fi
elif [ "$1" = "run" -a -z "$IS_LOCAL" ] ; then
# non-local "run" is a special case because we want to use docker
# directly, rather than the docker in $EXEC_IMAGE remotely. That's
# because we are passing arbitrary arguments on to docker run, and
# we can't rely on our baked-in docker to support those arguments.
shift 1
handle_help_arg "$1"
[ "$1" = "--without-dns" ] || DNS_ARGS=$(exec_remote dns-args "$@" || true)
shift $(dns_arg_count "$@")
REWRITE_HOSTS=1
NO_MULTICAST_ROUTE=
while [ $# -gt 0 ]; do
case "$1" in
--no-rewrite-hosts)
REWRITE_HOSTS=
;;
--no-multicast-route)
NO_MULTICAST_ROUTE=1
;;
*)
break
;;
esac
shift
done
[ -n "$REWRITE_HOSTS" ] && extra_hosts_args "$@" && DNS_EXTRA_HOSTS_ARGS="--rewrite-hosts $DNS_EXTRA_HOSTS_ARGS"
[ -n "$NO_MULTICAST_ROUTE" ] && ATTACH_ARGS="--no-multicast-route"
collect_cidr_args "$@"
shift $CIDR_ARG_COUNT
CONTAINER=$(docker $DOCKER_CLIENT_ARGS run -e WEAVE_CIDR=none $DNS_ARGS -d "$@")
if ! exec_remote attach $CIDR_ARGS $DNS_EXTRA_HOSTS_ARGS $ATTACH_ARGS $CONTAINER >/dev/null ; then
kill_container $CONTAINER
exit 1
fi
echo $CONTAINER
exit 0
fi
if [ -z "$IS_LOCAL" ] ; then
@@ -822,15 +751,6 @@ destroy_bridge() {
run_iptables -t nat -X WEAVE >/dev/null 2>&1 || true
}
do_or_die() {
CONTAINER="$1"
shift 1
if ! "$@" ; then
kill_container $CONTAINER
exit 1
fi
}
add_iface_fastdp() {
util_op add-datapath-interface $DATAPATH $1
}
@@ -1371,13 +1291,6 @@ ipam_cidrs() {
done
}
ipam_cidrs_or_die() {
if ! ipam_cidrs "$@" ; then
kill_container $2
exit 1
fi
}
show_addrs() {
addrs=
for cidr in "$@" ; do
@@ -2078,34 +1991,10 @@ EOF
call_weave GET /report -H 'Accept: application/json'
fi
;;
run)
dns_args "$@"
shift $(dns_arg_count "$@")
REWRITE_HOSTS=1
NO_MULTICAST_ROUTE=
while [ $# -gt 0 ]; do
case "$1" in
--no-rewrite-hosts)
REWRITE_HOSTS=
;;
--no-multicast-route)
NO_MULTICAST_ROUTE=1
;;
*)
break
;;
esac
shift
done
collect_cidr_args "$@"
shift $CIDR_ARG_COUNT
CONTAINER=$(docker run -e WEAVE_CIDR=none $DNS_ARGS -d "$@")
create_bridge
ipam_cidrs_or_die allocate $CONTAINER $CIDR_ARGS
[ -n "$REWRITE_HOSTS" ] && extra_hosts_args "$@" && rewrite_etc_hosts $DNS_EXTRA_HOSTS
do_or_die $CONTAINER attach $ALL_CIDRS
when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
echo $CONTAINER
run|start|restart)
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
;;
dns-args)
dns_args "$@"
@@ -2114,18 +2003,6 @@ EOF
docker-bridge-ip)
util_op bridge-ip $DOCKER_BRIDGE
;;
start)
collect_cidr_args "$@"
shift $CIDR_ARG_COUNT
[ $# -eq 1 ] || usage
RES=$(docker start $1)
CONTAINER=$(container_id $1)
create_bridge
ipam_cidrs_or_die allocate $CONTAINER $CIDR_ARGS
do_or_die $CONTAINER attach $ALL_CIDRS
when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
echo $RES
;;
attach)
DNS_EXTRA_HOSTS=
REWRITE_HOSTS=
@@ -2175,20 +2052,6 @@ EOF
done
show_addrs $ALL_CIDRS
;;
restart)
[ $# -ge 1 ] || usage
create_bridge
ALL_CIDRS=$(with_container_addresses echo_cidrs $1)
RES=$(docker restart $1)
CONTAINER=$(container_id $1)
for CIDR in $ALL_CIDRS ; do
call_weave PUT /ip/$CONTAINER/$CIDR?check-alive=true
done
detect_awsvpc
do_or_die $CONTAINER attach $ALL_CIDRS
when_weave_running with_container_fqdn $CONTAINER put_dns_fqdn $ALL_CIDRS
echo $RES
;;
dns-add)
collect_dns_add_remove_args "$@"
FN=put_dns_fqdn