Skip to content

Commit c856bc1

Browse files
Merge pull request #728 from ramiro-gamarra/hns-endpoint-not-found
Handling "endpoint not found" in hns delete
2 parents 0309922 + 33a1dd5 commit c856bc1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

network/endpoint_windows.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ func (nw *network) deleteEndpointImplHnsV1(ep *endpoint) error {
416416
hnsResponse, err := hcsshim.HNSEndpointRequest("DELETE", ep.HnsId, "")
417417
log.Printf("[net] HNSEndpointRequest DELETE response:%+v err:%v.", hnsResponse, err)
418418

419+
// todo: may need to improve error handling if hns or hcsshim change their error bubbling.
420+
// hcsshim bubbles up a generic error when delete fails with message "The endpoint was not found".
421+
// the best we can do at the moment is string comparison, which is never great for error checking
422+
if err != nil {
423+
if strings.Contains(strings.ToLower(err.Error()), "not found") {
424+
log.Printf("[net] HNS endpoint id %s not found", ep.HnsId)
425+
return nil
426+
}
427+
}
428+
419429
return err
420430
}
421431

0 commit comments

Comments
 (0)