From a0d0b00938fdba9e1632bee49a342de6fb021830 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 12 Jun 2017 09:07:31 +0000 Subject: [PATCH 1/3] Pass check-alive flag on claim for container --- api/ipam.go | 4 ++-- plugin/ipam/driver.go | 2 +- proxy/proxy.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/ipam.go b/api/ipam.go index 0f72b0b0..ea25b618 100644 --- a/api/ipam.go +++ b/api/ipam.go @@ -51,8 +51,8 @@ func (client *Client) LookupIP(ID string) (*net.IPNet, error) { } // Claim a specific IP on behalf of the ID -func (client *Client) ClaimIP(ID string, cidr *net.IPNet) error { - _, err := client.httpVerb("PUT", fmt.Sprintf("/ip/%s/%s", ID, cidr), nil) +func (client *Client) ClaimIP(ID string, cidr *net.IPNet, checkAlive bool) error { + _, err := client.httpVerb("PUT", fmt.Sprintf("/ip/%s/%s", ID, cidr), ipamValues(checkAlive)) return err } diff --git a/plugin/ipam/driver.go b/plugin/ipam/driver.go index 9bb90a2d..ceb9458b 100644 --- a/plugin/ipam/driver.go +++ b/plugin/ipam/driver.go @@ -87,7 +87,7 @@ func (i *Ipam) RequestAddress(poolID string, address net.IP, options map[string] } if address != nil { // try to claim specific address requested ip = &net.IPNet{IP: address, Mask: subnet.Mask} - if err = i.weave.ClaimIP(api.NoContainerID, ip); err != nil { + if err = i.weave.ClaimIP(api.NoContainerID, ip, false); err != nil { return } } else { diff --git a/proxy/proxy.go b/proxy/proxy.go index d991794c..893168bc 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -568,7 +568,7 @@ func (proxy *Proxy) claimCIDR(containerID, cidr string) (*net.IPNet, error) { return nil, err } ipnet.IP = ip // we want the specific IP plus the mask - err = proxy.weave.ClaimIP(containerID, ipnet) + err = proxy.weave.ClaimIP(containerID, ipnet, true) return ipnet, err } From ea098ac53e6499f0b46b85d679611b824f0c4210 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 12 Jun 2017 10:15:06 +0000 Subject: [PATCH 2/3] Only retain IP addresses for running containers --- prog/weaver/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prog/weaver/main.go b/prog/weaver/main.go index d2c72533..1532572f 100644 --- a/prog/weaver/main.go +++ b/prog/weaver/main.go @@ -392,7 +392,7 @@ func main() { observeContainers(allocator) if dockerCli != nil { - allContainerIDs, err := dockerCli.AllContainerIDs() + allContainerIDs, err := dockerCli.RunningContainerIDs() checkFatal(err) allocator.PruneOwned(allContainerIDs) } From f91a9c25629ce66d7c1e652e9665438df767d7f3 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 12 Jun 2017 10:15:42 +0000 Subject: [PATCH 3/3] Fix test: committed image embeds WEAVE_CIDR so we cannot run two of those containers at the same time. Fixed by stopping the first one before we start the second. --- test/610_proxy_wait_for_weave_test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/610_proxy_wait_for_weave_test.sh b/test/610_proxy_wait_for_weave_test.sh index 8a57f941..a701a9bb 100755 --- a/test/610_proxy_wait_for_weave_test.sh +++ b/test/610_proxy_wait_for_weave_test.sh @@ -27,6 +27,7 @@ check_iface_ready 10.2.1.1/24 # Check committed containers only have one weavewait prepended proxy_start_container $HOST1 --name c1 -e 'WEAVE_CIDR=10.2.1.1/24' COMMITTED_IMAGE=$(proxy docker_on $HOST1 commit c1) +docker_on $HOST1 stop -t=1 c1 assert_raises "proxy docker_on $HOST1 run --name c2 $COMMITTED_IMAGE" assert "entrypoint c2" "$(entrypoint $COMMITTED_IMAGE)"