From b7412d34b23ca1cb88778a3633caa84d74c2b07a Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Fri, 6 Mar 2020 09:13:22 +0100 Subject: [PATCH] daemon: Improve error msg for endpoint IP reallocation Previously, when restoring endpoints, if the reallocation of an IP addr of an endpoint failed, the error log message didn't include that IP. E.g.: level=warning msg="Unable to restore endpoint, ignoring" endpointID=2930 error="Failed to re-allocate IP of endpoint: unable to reallocate IPv6 address: provided IP is not in the valid range. The range of valid IPs is f00d::a0c:0:0:0/96" k8sPodName=default/testds-l87pp subsys=daemon This commit includes IP addr in the error msg for a better troubleshooting. Signed-off-by: Martynas Pumputis --- daemon/state.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/state.go b/daemon/state.go index cdaa90e67fad..39f19366234a 100644 --- a/daemon/state.go +++ b/daemon/state.go @@ -326,7 +326,7 @@ func (d *Daemon) allocateIPsLocked(ep *endpoint.Endpoint) error { if option.Config.EnableIPv6 && ep.IPv6 != nil { err = d.ipam.AllocateIP(ep.IPv6.IP(), ep.HumanStringLocked()+" [restored]") if err != nil { - return fmt.Errorf("unable to reallocate IPv6 address: %s", err) + return fmt.Errorf("unable to reallocate %s IPv6 address: %s", ep.IPv6.IP(), err) } defer func() { @@ -338,7 +338,7 @@ func (d *Daemon) allocateIPsLocked(ep *endpoint.Endpoint) error { if option.Config.EnableIPv4 && ep.IPv4 != nil { if err = d.ipam.AllocateIP(ep.IPv4.IP(), ep.HumanStringLocked()+" [restored]"); err != nil { - return fmt.Errorf("unable to reallocate IPv4 address: %s", err) + return fmt.Errorf("unable to reallocate %s IPv4 address: %s", ep.IPv4.IP(), err) } }