From 3b7099798e8b5750b46a09affa8320057f0d80b6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 14 Mar 2018 23:45:58 +0100 Subject: [PATCH] Update libnetwork to fix stale HNS endpoints on Windows Update libnetwork to 1b91bc94094ecfdae41daa465cc0c8df37dfb3dd to bring in a fix for stale HNS endpoints on Windows: When Windows Server 2016 is restarted with the Docker service running, it is possible for endpoints to be deleted from the libnetwork store without being deleted from HNS. This does not occur if the Docker service is stopped cleanly first, or forcibly terminated (since the endpoints still exist in both). This change works around the issue by removing any stale HNS endpoints for a network when creating it. Signed-off-by: Sebastiaan van Stijn (cherry picked from commit fb364f07468e94226250a1e77579ee6117c64be2) Signed-off-by: Andrew Hsu --- .../hack/dockerfile/install/proxy.installer | 2 +- components/engine/vendor.conf | 2 +- .../docker/libnetwork/drivers/windows/windows.go | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/components/engine/hack/dockerfile/install/proxy.installer b/components/engine/hack/dockerfile/install/proxy.installer index 5a0cd585dc..bc2f92a63a 100755 --- a/components/engine/hack/dockerfile/install/proxy.installer +++ b/components/engine/hack/dockerfile/install/proxy.installer @@ -3,7 +3,7 @@ # LIBNETWORK_COMMIT is used to build the docker-userland-proxy binary. When # updating the binary version, consider updating github.com/docker/libnetwork # in vendor.conf accordingly -LIBNETWORK_COMMIT=8892d7537c67232591f1f3af60587e3e77e61d41 +LIBNETWORK_COMMIT=1b91bc94094ecfdae41daa465cc0c8df37dfb3dd install_proxy() { case "$1" in diff --git a/components/engine/vendor.conf b/components/engine/vendor.conf index f76ea60317..af612a1324 100644 --- a/components/engine/vendor.conf +++ b/components/engine/vendor.conf @@ -33,7 +33,7 @@ github.com/tonistiigi/fsutil dea3a0da73aee887fc02142d995be764106ac5e2 #get libnetwork packages # When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy accordingly -github.com/docker/libnetwork 8892d7537c67232591f1f3af60587e3e77e61d41 +github.com/docker/libnetwork 1b91bc94094ecfdae41daa465cc0c8df37dfb3dd github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec diff --git a/components/engine/vendor/github.com/docker/libnetwork/drivers/windows/windows.go b/components/engine/vendor/github.com/docker/libnetwork/drivers/windows/windows.go index eabf590a9d..5927fd8560 100644 --- a/components/engine/vendor/github.com/docker/libnetwork/drivers/windows/windows.go +++ b/components/engine/vendor/github.com/docker/libnetwork/drivers/windows/windows.go @@ -365,6 +365,22 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo d config.HnsID = hnsresponse.Id genData[HNSID] = config.HnsID + + } else { + // Delete any stale HNS endpoints for this network. + if endpoints, err := hcsshim.HNSListEndpointRequest(); err == nil { + for _, ep := range endpoints { + if ep.VirtualNetwork == config.HnsID { + logrus.Infof("Removing stale HNS endpoint %s", ep.Id) + _, err = hcsshim.HNSEndpointRequest("DELETE", ep.Id, "") + if err != nil { + logrus.Warnf("Error removing HNS endpoint %s", ep.Id) + } + } + } + } else { + logrus.Warnf("Error listing HNS endpoints for network %s", config.HnsID) + } } n, err := d.getNetwork(id)