Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Extend the timeout for dead containers to 30 seconds,
Browse files Browse the repository at this point in the history
but remove them if they are destroyed, to reduce starvation
when users are creating and destroying containers quickly.
  • Loading branch information
bboreham committed Jan 7, 2016
1 parent d37de59 commit bc43ae8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ipam/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (

tickInterval = time.Second * 5
MinSubnetSize = 4 // first and last addresses are excluded, so 2 would be too small
containerDiedTimeout = time.Second * 5
containerDiedTimeout = time.Second * 30
)

// operation represents something which Allocator wants to do, but
Expand Down
2 changes: 1 addition & 1 deletion site/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ current IP addresses:
host1$ weave restart b1

(note that the IP addresses are held for a limited time - currently
five seconds)
30 seconds)

### <a name="naming-and-discovery"></a>Naming and discovery

Expand Down
2 changes: 1 addition & 1 deletion test/100_cross_hosts_2_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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
assert_raises "exec_on $HOST1 c5 $PING $C6"
sleep 6 # past the IPAM timeout
sleep 31 # past the IPAM timeout
start_container $HOST2 net:$SUBNET_2 --name=c7
C7=$(container_ip $HOST2 c7)
assert_raises "[ $C6 != $C7 ]"
Expand Down
12 changes: 12 additions & 0 deletions test/640_proxy_restart_reattaches_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ wait_for_proxy() {
exit 1
}

N=50
# Create and remove a lot of containers in a small subnet; the failure
# mode is that this takes a long time as it has to wait for the old
# ones to time out, so we run this function inside 'timeout'
run_many() {
for i in $(seq $N); do
proxy docker_on $HOST1 run -e WEAVE_CIDR=net:10.32.4.0/28 --rm -t $SMALL_IMAGE /bin/true
done
}

start_suite "Proxy restart reattaches networking to containers"

WEAVE_DOCKER_ARGS=--restart=always WEAVEPROXY_DOCKER_ARGS=--restart=always weave_on $HOST1 launch
Expand Down Expand Up @@ -49,6 +59,8 @@ sleep 5 # allow for re-tries of attach
C2=$(container_ip $HOST1 c2) || (echo "container c2 has no IP address" 2>&1; exit 1)
check_attached

assert_raises "timeout 90 cat <( run_many )"

# Restarting proxy shouldn't kill unattachable containers
proxy_start_container $HOST1 -di --name=c3 --restart=always # Use ipam, so it won't be attachable w/o weave
weave_on $HOST1 stop
Expand Down

0 comments on commit bc43ae8

Please sign in to comment.