Merge pull request #2262 from weaveworks/issues/2194-reclaim-plugin-addrs

Reclaim plugin addresses without warning

Fixes #2194
This commit is contained in:
Matthias Radestock committed 2016-05-07 14:41:03 +01:00
commit bd06553ce0
3 files changed
+17 -11

No files matched your search

+2 -1
View File
@@ -45,6 +45,7 @@ func WithNetNS(ns netns.NsHandle, work func() error) error {
}
type NetDev struct {
Name string
MAC net.HardwareAddr
CIDRs []*net.IPNet
}
@@ -97,7 +98,7 @@ func linkToNetDev(link netlink.Link) (*NetDev, error) {
return nil, err
}
netDev := &NetDev{MAC: link.Attrs().HardwareAddr}
netDev := &NetDev{Name: link.Attrs().Name, MAC: link.Attrs().HardwareAddr}
for _, addr := range addrs {
netDev.CIDRs = append(netDev.CIDRs, addr.IPNet)
}
+1 -1
View File
@@ -27,7 +27,7 @@ func containerAddrs(args []string) error {
}
for _, netDev := range netDevs {
fmt.Printf("%12s %s", containerID, netDev.MAC.String())
fmt.Printf("%12s %s %s", containerID, netDev.Name, netDev.MAC.String())
for _, cidr := range netDev.CIDRs {
prefixLength, _ := cidr.Mask.Size()
fmt.Printf(" %v/%v", cidr.IP, prefixLength)
+14 -9
View File
@@ -1143,23 +1143,23 @@ with_container_addresses() {
shift 1
CONTAINER_ADDRS=$(util_op container-addrs $BRIDGE "$@") || return 1
echo "$CONTAINER_ADDRS" | while read CONTAINER_ID CONTAINER_MAC CONTAINER_IPS; do
$COMMAND "$CONTAINER_ID" "$CONTAINER_MAC" "$CONTAINER_IPS"
echo "$CONTAINER_ADDRS" | while read CONTAINER_ID CONTAINER_IFACE CONTAINER_MAC CONTAINER_IPS; do
$COMMAND "$CONTAINER_ID" "$CONTAINER_IFACE" "$CONTAINER_MAC" "$CONTAINER_IPS"
done
}
echo_addresses() {
echo $1 $2 $3
echo $1 $3 $4
}
echo_ips() {
for CIDR in $3; do
echo ${3%/*}
for CIDR in $4; do
echo ${CIDR%/*}
done
}
echo_cidrs() {
echo $3
echo $4
}
peer_args() {
@@ -1382,13 +1382,18 @@ check_overlap() {
# Claim addresses for a container in IPAM. Expects to be called from
# with_container_addresses.
ipam_reclaim() {
for CIDR in $3 ; do
http_call $HTTP_ADDR PUT "/ip/$1/$CIDR?noErrorOnUnknown=true&?check-alive=true" || true
CONTAINER_ID="$1"
# The weave IP addresses of containers attached by the plugin are
# recorded specially in IPAM, since the container id is not know
# at the time.
[ "$2" = "$CONTAINER_IFNAME" ] || CONTAINER_ID="_"
for CIDR in $4 ; do
http_call $HTTP_ADDR PUT "/ip/$CONTAINER_ID/$CIDR?noErrorOnUnknown=true&?check-alive=true" || true
done
}
ipam_reclaim_no_check_alive() {
for CIDR in $3 ; do
for CIDR in $4 ; do
http_call $HTTP_ADDR PUT /ip/$1/$CIDR?noErrorOnUnknown=true || true
done
}