Skip to content

Commit

Permalink
daemon: Improve error msg for endpoint IP reallocation
Browse files Browse the repository at this point in the history
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 <m@lambda.lt>
  • Loading branch information
brb committed Mar 6, 2020
1 parent 2a49a0b commit b7412d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions daemon/state.go
Expand Up @@ -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() {
Expand All @@ -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)
}
}

Expand Down

0 comments on commit b7412d3

Please sign in to comment.