From 33a1dd5070a171f9bcddcda6ad4dede91535d0ff Mon Sep 17 00:00:00 2001 From: Ramiro Date: Thu, 12 Nov 2020 06:14:06 -0800 Subject: [PATCH] handling endpoint not found in hns delete --- network/endpoint_windows.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/network/endpoint_windows.go b/network/endpoint_windows.go index e59d2fc424..9643ebcaa4 100644 --- a/network/endpoint_windows.go +++ b/network/endpoint_windows.go @@ -416,6 +416,16 @@ func (nw *network) deleteEndpointImplHnsV1(ep *endpoint) error { hnsResponse, err := hcsshim.HNSEndpointRequest("DELETE", ep.HnsId, "") log.Printf("[net] HNSEndpointRequest DELETE response:%+v err:%v.", hnsResponse, err) + // todo: may need to improve error handling if hns or hcsshim change their error bubbling. + // hcsshim bubbles up a generic error when delete fails with message "The endpoint was not found". + // the best we can do at the moment is string comparison, which is never great for error checking + if err != nil { + if strings.Contains(strings.ToLower(err.Error()), "not found") { + log.Printf("[net] HNS endpoint id %s not found", ep.HnsId) + return nil + } + } + return err }