1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
Skip "no chain" error on deleting chain in Unmap
This commit is contained in:
Victor Vieux 2014-08-27 14:43:57 -07:00
commit 0cb672e6a9

View file

@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net" "net"
"strings"
"sync" "sync"
"github.com/docker/docker/daemon/networkdriver/portallocator" "github.com/docker/docker/daemon/networkdriver/portallocator"
@ -126,18 +127,17 @@ func Unmap(host net.Addr) error {
containerIP, containerPort := getIPAndPort(data.container) containerIP, containerPort := getIPAndPort(data.container)
hostIP, hostPort := getIPAndPort(data.host) hostIP, hostPort := getIPAndPort(data.host)
if err := forward(iptables.Delete, data.proto, hostIP, hostPort, containerIP.String(), containerPort); err != nil { if err := forward(iptables.Delete, data.proto, hostIP, hostPort, containerIP.String(), containerPort); err != nil {
// skip "no chain" errors because we can safely release port in this case
if !strings.Contains(err.Error(), "No chain/target/match by that name") {
return err return err
} }
}
switch a := host.(type) { switch a := host.(type) {
case *net.TCPAddr: case *net.TCPAddr:
if err := portallocator.ReleasePort(a.IP, "tcp", a.Port); err != nil { return portallocator.ReleasePort(a.IP, "tcp", a.Port)
return err
}
case *net.UDPAddr: case *net.UDPAddr:
if err := portallocator.ReleasePort(a.IP, "udp", a.Port); err != nil { return portallocator.ReleasePort(a.IP, "udp", a.Port)
return err
}
} }
return nil return nil