Reclaim all addresses on restart
This commit is contained in:
1 parent
7985e43e68
commit
2f885a7906
3 files changed
+20
-3
No files matched your search
@@ -40,6 +40,9 @@ func (c *claim) Try(alloc *Allocator) bool {
|
||||
|
||||
alloc.establishRing()
|
||||
|
||||
// If we had heard that this container died, resurrect it
|
||||
delete(alloc.dead, c.ident) // (delete is no-op if key not in map)
|
||||
|
||||
switch owner := alloc.ring.Owner(c.addr); owner {
|
||||
case alloc.ourName:
|
||||
// success
|
||||
@@ -78,6 +81,7 @@ func (c *claim) Try(alloc *Allocator) bool {
|
||||
}
|
||||
case c.ident:
|
||||
// same identifier is claiming same address; that's OK
|
||||
alloc.debugln("Re-Claimed", c.addr, "for", c.ident)
|
||||
c.sendResult(nil)
|
||||
default:
|
||||
// Addr already owned by container on this machine
|
||||
|
||||
+12
-3
@@ -167,12 +167,21 @@ the weave network:
|
||||
host1$ weave ps a1
|
||||
a1 16:c0:6f:5d:c5:73 10.32.0.3/12
|
||||
|
||||
There is also a `weave restart` command, if you are not using the
|
||||
weave Docker API proxy:
|
||||
It works the same if you stop and immediately restart:
|
||||
|
||||
host1$ docker stop a1
|
||||
host1$ docker start a1
|
||||
|
||||
However, additional addresses added with the `weave attach` command
|
||||
will not be retained.
|
||||
|
||||
There is also a `weave restart` command, which does re-attach all
|
||||
current IP addresses:
|
||||
|
||||
host1$ weave restart b1
|
||||
|
||||
(note that the IP address is held for a limited time - currently five seconds)
|
||||
(note that the IP addresses are held for a limited time - currently
|
||||
five seconds)
|
||||
|
||||
### <a name="naming-and-discovery"></a>Naming and discovery
|
||||
|
||||
|
||||
@@ -2036,6 +2036,10 @@ EOF
|
||||
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%/*}
|
||||
done
|
||||
with_container_netns_or_die $1 attach $ALL_CIDRS
|
||||
when_weave_running with_container_fqdn $1 put_dns_fqdn $ALL_CIDRS
|
||||
echo $RES
|
||||
|
||||
Reference in new issue
Block a user