Browse code

Vendoring libnetwork v0.6.0-rc5

- Cleanup stale overlay sandboxes

Fixes #19694

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>

Jana Radhakrishnan authored on 2016/01/27 04:44:43
Showing 3 changed files
... ...
@@ -27,7 +27,7 @@ clone git github.com/RackSec/srslog 6eb773f331e46fbba8eecb8e794e635e75fc04de
27 27
 clone git github.com/imdario/mergo 0.2.1
28 28
 
29 29
 #get libnetwork packages
30
-clone git github.com/docker/libnetwork v0.6.0-rc4
30
+clone git github.com/docker/libnetwork v0.6.0-rc5
31 31
 clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
32 32
 clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
33 33
 clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
... ...
@@ -1,5 +1,8 @@
1 1
 # Changelog
2 2
 
3
+## 0.6.0-rc5 (2016-01-26)
4
+- Cleanup stale overlay sandboxes
5
+
3 6
 ## 0.6.0-rc4 (2016-01-25)
4 7
 - Add Endpoints() API to Sandbox interface
5 8
 - Fixed a race-condition in default gateway network creation
... ...
@@ -17,7 +20,7 @@
17 17
 
18 18
 ## 0.6.0-rc1 (2016-01-14)
19 19
 - Fixes docker/docker#19404
20
-- Fixes the ungraceful daemon restart issue in systemd with remote network plugin 
20
+- Fixes the ungraceful daemon restart issue in systemd with remote network plugin
21 21
   (https://github.com/docker/libnetwork/issues/813)
22 22
 
23 23
 ## 0.5.6 (2016-01-14)
... ...
@@ -70,6 +73,6 @@
70 70
 - Fixed a bunch of issues with osl namespace mgmt
71 71
 
72 72
 ## 0.3.0 (2015-05-27)
73
- 
73
+
74 74
 - Introduce CNM (Container Networking Model)
75 75
 - Replace docker networking with CNM & Bridge driver
... ...
@@ -5,6 +5,8 @@ import (
5 5
 	"fmt"
6 6
 	"net"
7 7
 	"os"
8
+	"path/filepath"
9
+	"strings"
8 10
 	"sync"
9 11
 	"syscall"
10 12
 
... ...
@@ -298,6 +300,26 @@ func (n *network) initSubnetSandbox(s *subnet) error {
298 298
 	return nil
299 299
 }
300 300
 
301
+func (n *network) cleanupStaleSandboxes() {
302
+	filepath.Walk(filepath.Dir(osl.GenerateKey("walk")),
303
+		func(path string, info os.FileInfo, err error) error {
304
+			_, fname := filepath.Split(path)
305
+
306
+			pList := strings.Split(fname, "-")
307
+			if len(pList) <= 1 {
308
+				return nil
309
+			}
310
+
311
+			pattern := pList[1]
312
+			if strings.Contains(n.id, pattern) {
313
+				syscall.Unmount(path, syscall.MNT_DETACH)
314
+				os.Remove(path)
315
+			}
316
+
317
+			return nil
318
+		})
319
+}
320
+
301 321
 func (n *network) initSandbox() error {
302 322
 	n.Lock()
303 323
 	n.initEpoch++
... ...
@@ -311,6 +333,10 @@ func (n *network) initSandbox() error {
311 311
 		}
312 312
 	}
313 313
 
314
+	// If there are any stale sandboxes related to this network
315
+	// from previous daemon life clean it up here
316
+	n.cleanupStaleSandboxes()
317
+
314 318
 	sbox, err := osl.NewSandbox(
315 319
 		osl.GenerateKey(fmt.Sprintf("%d-", n.initEpoch)+n.id), !hostMode)
316 320
 	if err != nil {