From 163bf3e38ac7ff46b671dc9cd8333053317b7d93 Mon Sep 17 00:00:00 2001 From: ZhiPeng Lu Date: Thu, 22 Feb 2018 21:42:32 +0800 Subject: [PATCH] Add error message when stopping userlandProxy failed Signed-off-by: ZhiPeng Lu --- portmapper/mapper.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/portmapper/mapper.go b/portmapper/mapper.go index 7fa37b1fb6..5b5fb3754d 100644 --- a/portmapper/mapper.go +++ b/portmapper/mapper.go @@ -181,9 +181,14 @@ func (pm *PortMapper) MapRange(container net.Addr, hostIP net.IP, hostPortStart, cleanup := func() error { // need to undo the iptables rules before we return - m.userlandProxy.Stop() + if userlanderr := m.userlandProxy.Stop(); userlanderr != nil { + logrus.Errorf("Error on userlandProxy delete: %s", userlanderr) + } if hostIP.To4() != nil { - pm.forward(iptables.Delete, m.proto, hostIP, allocatedHostPort, containerIP.String(), containerPort) + if forwarderr := pm.forward(iptables.Delete, m.proto, hostIP, allocatedHostPort, containerIP.String(), containerPort); forwarderr != nil { + logrus.Errorf("Error on iptables delete: %s", forwarderr) + } + if err := pm.Allocator.ReleasePort(hostIP, m.proto, allocatedHostPort); err != nil { return err } @@ -215,7 +220,9 @@ func (pm *PortMapper) Unmap(host net.Addr) error { } if data.userlandProxy != nil { - data.userlandProxy.Stop() + if err := data.userlandProxy.Stop(); err != nil { + logrus.Errorf("Error on userlandProxy delete: %s", err) + } } delete(pm.currentMappings, key)