Browse code

Vendoring in libnetwork to fix daemon bootup instabilities

Signed-off-by: Madhu Venugopal <madhu@docker.com>

Madhu Venugopal authored on 2015/10/21 11:49:08
Showing 2 changed files
... ...
@@ -21,7 +21,7 @@ clone git github.com/vdemeester/shakers 3c10293ce22b900c27acad7b28656196fcc2f73b
21 21
 clone git golang.org/x/net 3cffabab72adf04f8e3b01c5baf775361837b5fe https://github.com/golang/net.git
22 22
 
23 23
 #get libnetwork packages
24
-clone git github.com/docker/libnetwork fc6cbea49cd8197c0a8d22b9e8f24f37d9e7b1b8
24
+clone git github.com/docker/libnetwork 0d7a57ddb94a92a57755eec5dc54f905287c7e65
25 25
 clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
26 26
 clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
27 27
 clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
... ...
@@ -60,12 +60,11 @@ func (c *controller) getNetworkFromStore(nid string) (*network, error) {
60 60
 	for _, store := range c.getStores() {
61 61
 		n := &network{id: nid, ctrlr: c}
62 62
 		err := store.GetObject(datastore.Key(n.Key()...), n)
63
-		if err != nil && err != datastore.ErrKeyNotFound {
64
-			return nil, fmt.Errorf("could not find network %s: %v", nid, err)
65
-		}
66
-
67 63
 		// Continue searching in the next store if the key is not found in this store
68
-		if err == datastore.ErrKeyNotFound {
64
+		if err != nil {
65
+			if err != datastore.ErrKeyNotFound {
66
+				log.Debugf("could not find network %s: %v", nid, err)
67
+			}
69 68
 			continue
70 69
 		}
71 70
 
... ...
@@ -120,13 +119,11 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
120 120
 	for _, store := range c.getStores() {
121 121
 		kvol, err := store.List(datastore.Key(datastore.NetworkKeyPrefix),
122 122
 			&network{ctrlr: c})
123
-		if err != nil && err != datastore.ErrKeyNotFound {
124
-			return nil, fmt.Errorf("failed to get networks for scope %s: %v",
125
-				store.Scope(), err)
126
-		}
127
-
128 123
 		// Continue searching in the next store if no keys found in this store
129
-		if err == datastore.ErrKeyNotFound {
124
+		if err != nil {
125
+			if err != datastore.ErrKeyNotFound {
126
+				log.Debugf("failed to get networks for scope %s: %v", store.Scope(), err)
127
+			}
130 128
 			continue
131 129
 		}
132 130
 
... ...
@@ -149,22 +146,17 @@ func (c *controller) getNetworksFromStore() ([]*network, error) {
149 149
 }
150 150
 
151 151
 func (n *network) getEndpointFromStore(eid string) (*endpoint, error) {
152
-	for _, store := range n.ctrlr.getStores() {
153
-		ep := &endpoint{id: eid, network: n}
154
-		err := store.GetObject(datastore.Key(ep.Key()...), ep)
155
-		if err != nil && err != datastore.ErrKeyNotFound {
156
-			return nil, fmt.Errorf("could not find endpoint %s: %v", eid, err)
157
-		}
158
-
159
-		// Continue searching in the next store if the key is not found in this store
160
-		if err == datastore.ErrKeyNotFound {
161
-			continue
162
-		}
163
-
164
-		return ep, nil
152
+	store := n.ctrlr.getStore(n.Scope())
153
+	if store == nil {
154
+		return nil, fmt.Errorf("could not find endpoint %s: datastore not found for scope %s", eid, n.Scope())
165 155
 	}
166 156
 
167
-	return nil, fmt.Errorf("endpoint %s not found", eid)
157
+	ep := &endpoint{id: eid, network: n}
158
+	err := store.GetObject(datastore.Key(ep.Key()...), ep)
159
+	if err != nil {
160
+		return nil, fmt.Errorf("could not find endpoint %s: %v", eid, err)
161
+	}
162
+	return ep, nil
168 163
 }
169 164
 
170 165
 func (n *network) getEndpointsFromStore() ([]*endpoint, error) {
... ...
@@ -173,14 +165,12 @@ func (n *network) getEndpointsFromStore() ([]*endpoint, error) {
173 173
 	tmp := endpoint{network: n}
174 174
 	for _, store := range n.getController().getStores() {
175 175
 		kvol, err := store.List(datastore.Key(tmp.KeyPrefix()...), &endpoint{network: n})
176
-		if err != nil && err != datastore.ErrKeyNotFound {
177
-			return nil,
178
-				fmt.Errorf("failed to get endpoints for network %s scope %s: %v",
179
-					n.Name(), store.Scope(), err)
180
-		}
181
-
182 176
 		// Continue searching in the next store if no keys found in this store
183
-		if err == datastore.ErrKeyNotFound {
177
+		if err != nil {
178
+			if err != datastore.ErrKeyNotFound {
179
+				log.Debugf("failed to get endpoints for network %s scope %s: %v",
180
+					n.Name(), store.Scope(), err)
181
+			}
184 182
 			continue
185 183
 		}
186 184