فهرست منبع

Do not hold sandbox if not in distributed control

When the libnetwork controller is not in distributed control mode avoid
retaining stale sandboxes when the network cannot be retrieved from
store. This ratining logic is only applicable for an independent k/v
store which manages libnetwork state. In such case the k/v store may be
temporarily unavailable so there is a need to retain the sandbox so that
the resource cleanup happens properly.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
Jana Radhakrishnan 8 سال پیش
والد
کامیت
bf7ef3fd7b
1فایلهای تغییر یافته به همراه4 افزوده شده و 2 حذف شده
  1. 4 2
      libnetwork/sandbox.go

+ 4 - 2
libnetwork/sandbox.go

@@ -202,12 +202,14 @@ func (sb *sandbox) delete(force bool) error {
 	retain := false
 	retain := false
 	for _, ep := range sb.getConnectedEndpoints() {
 	for _, ep := range sb.getConnectedEndpoints() {
 		// gw network endpoint detach and removal are automatic
 		// gw network endpoint detach and removal are automatic
-		if ep.endpointInGWNetwork() {
+		if ep.endpointInGWNetwork() && !force {
 			continue
 			continue
 		}
 		}
 		// Retain the sanbdox if we can't obtain the network from store.
 		// Retain the sanbdox if we can't obtain the network from store.
 		if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
 		if _, err := c.getNetworkFromStore(ep.getNetwork().ID()); err != nil {
-			retain = true
+			if c.isDistributedControl() {
+				retain = true
+			}
 			log.Warnf("Failed getting network for ep %s during sandbox %s delete: %v", ep.ID(), sb.ID(), err)
 			log.Warnf("Failed getting network for ep %s during sandbox %s delete: %v", ep.ID(), sb.ID(), err)
 			continue
 			continue
 		}
 		}