From b0b2fc1be3cdb5cdde9ff4b13094488bf2c39d28 Mon Sep 17 00:00:00 2001 From: Claes Mogren Date: Tue, 24 Sep 2019 13:59:35 -0700 Subject: [PATCH] Return delete success for pods that never got scheduled --- ipamd/rpc_handler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipamd/rpc_handler.go b/ipamd/rpc_handler.go index dc5585b633..08e77c4a00 100644 --- a/ipamd/rpc_handler.go +++ b/ipamd/rpc_handler.go @@ -101,7 +101,14 @@ func (s *server) DelNetwork(ctx context.Context, in *pb.DelNetworkRequest) (*pb. } log.Infof("Send DelNetworkReply: IPv4Addr %s, DeviceNumber: %d, err: %v", ip, deviceNumber, err) - return &pb.DelNetworkReply{Success: err == nil, IPv4Addr: ip, DeviceNumber: int32(deviceNumber)}, nil + // Plugins should generally complete a DEL action without error even if some resources are missing. For example, + // an IPAM plugin should generally release an IP allocation and return success even if the container network + // namespace no longer exists, unless that network namespace is critical for IPAM management + success := true + if err != nil && err != datastore.ErrUnknownPod { + success = false + } + return &pb.DelNetworkReply{Success: success, IPv4Addr: ip, DeviceNumber: int32(deviceNumber)}, nil } // RunRPCHandler handles request from gRPC