Skip to content

Commit

Permalink
Handle pod delete with non-existent IPs
Browse files Browse the repository at this point in the history
Added the graceful handling for cases when the IPAM gets del
requests for IPs it did not allocate or not managing.

This situation can happen when whereabouts is added later as IPAM
for additional CNI in a cluster already deployed and processing
pod deletion. When this happens, kubelet keeps calling whereabouts
with del request for IPs it did not allocate and whereabouts keep
returning errors. This becomes endless loop between kubelet, which
holds on references to such pods and periodically keep calling all
CNI and IPAMs to cleanup.

With this fix, whereabouts will log such requests and return
gracefully ending possibility of such loops.
  • Loading branch information
ashish.billore committed Jul 9, 2020
1 parent 5cb45d9 commit 7083aa4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/whereabouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"

"strings"
"github.com/containernetworking/cni/pkg/skel"
cnitypes "github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
Expand Down Expand Up @@ -79,8 +79,12 @@ func cmdDel(args *skel.CmdArgs) error {

_, err = storage.IPManagement(types.Deallocate, *ipamConf, args.ContainerID)
if err != nil {
logging.Errorf("Error deallocating IP: %s", err)
return fmt.Errorf("Error deallocating IP: %s", err)
if (strings.Contains(fmt.Sprintf("%s", err), "Did not find reserved IP for container")) {
logging.Debugf("Cannot deallocate IP, it might not have been assigned by us. %s", err)
} else {
logging.Errorf("Error deallocating IP: %s", err)
return fmt.Errorf("Error deallocating IP: %s", err)
}
}

return nil
Expand Down

0 comments on commit 7083aa4

Please sign in to comment.