Signed-off-by: Alessandro Boch <aboch@docker.com>
| ... | ... |
@@ -24,7 +24,7 @@ github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5 |
| 24 | 24 |
github.com/imdario/mergo 0.2.1 |
| 25 | 25 |
|
| 26 | 26 |
#get libnetwork packages |
| 27 |
-github.com/docker/libnetwork b13e0604016a4944025aaff521d9c125850b0d04 |
|
| 27 |
+github.com/docker/libnetwork 5d4e5de2f9962c2de8a7872128e2cc09dfdd99aa |
|
| 28 | 28 |
github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894 |
| 29 | 29 |
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 |
| 30 | 30 |
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec |
| ... | ... |
@@ -187,6 +187,13 @@ func (c *controller) agentSetup() error {
|
| 187 | 187 |
clusterProvider := c.cfg.Daemon.ClusterProvider |
| 188 | 188 |
agent := c.agent |
| 189 | 189 |
c.Unlock() |
| 190 |
+ |
|
| 191 |
+ if clusterProvider == nil {
|
|
| 192 |
+ msg := "Aborting initialization of Libnetwork Agent because cluster provider is now unset" |
|
| 193 |
+ logrus.Errorf(msg) |
|
| 194 |
+ return fmt.Errorf(msg) |
|
| 195 |
+ } |
|
| 196 |
+ |
|
| 190 | 197 |
bindAddr := clusterProvider.GetLocalAddress() |
| 191 | 198 |
advAddr := clusterProvider.GetAdvertiseAddress() |
| 192 | 199 |
remote := clusterProvider.GetRemoteAddress() |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"strings" |
| 6 | 6 |
|
| 7 |
+ "github.com/Sirupsen/logrus" |
|
| 7 | 8 |
"github.com/docker/libnetwork/netlabel" |
| 8 | 9 |
"github.com/docker/libnetwork/types" |
| 9 | 10 |
) |
| ... | ... |
@@ -72,9 +73,19 @@ func (sb *sandbox) setupDefaultGW() error {
|
| 72 | 72 |
if err != nil {
|
| 73 | 73 |
return fmt.Errorf("container %s: endpoint create on GW Network failed: %v", sb.containerID, err)
|
| 74 | 74 |
} |
| 75 |
+ |
|
| 76 |
+ defer func() {
|
|
| 77 |
+ if err != nil {
|
|
| 78 |
+ if err2 := newEp.Delete(true); err2 != nil {
|
|
| 79 |
+ logrus.Warnf("Failed to remove gw endpoint for container %s after failing to join the gateway network: %v",
|
|
| 80 |
+ sb.containerID, err2) |
|
| 81 |
+ } |
|
| 82 |
+ } |
|
| 83 |
+ }() |
|
| 84 |
+ |
|
| 75 | 85 |
epLocal := newEp.(*endpoint) |
| 76 | 86 |
|
| 77 |
- if err := epLocal.sbJoin(sb); err != nil {
|
|
| 87 |
+ if err = epLocal.sbJoin(sb); err != nil {
|
|
| 78 | 88 |
return fmt.Errorf("container %s: endpoint join on GW Network failed: %v", sb.containerID, err)
|
| 79 | 89 |
} |
| 80 | 90 |
|
| ... | ... |
@@ -427,7 +427,7 @@ func (ep *endpoint) Join(sbox Sandbox, options ...EndpointOption) error {
|
| 427 | 427 |
return ep.sbJoin(sb, options...) |
| 428 | 428 |
} |
| 429 | 429 |
|
| 430 |
-func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
|
|
| 430 |
+func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) (err error) {
|
|
| 431 | 431 |
n, err := ep.getNetworkFromStore() |
| 432 | 432 |
if err != nil {
|
| 433 | 433 |
return fmt.Errorf("failed to get network from store during join: %v", err)
|
| ... | ... |
@@ -462,7 +462,7 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
|
| 462 | 462 |
|
| 463 | 463 |
d, err := n.driver(true) |
| 464 | 464 |
if err != nil {
|
| 465 |
- return fmt.Errorf("failed to join endpoint: %v", err)
|
|
| 465 |
+ return fmt.Errorf("failed to get driver during join: %v", err)
|
|
| 466 | 466 |
} |
| 467 | 467 |
|
| 468 | 468 |
err = d.Join(nid, epid, sb.Key(), ep, sb.Labels()) |
| ... | ... |
@@ -471,8 +471,8 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
|
| 471 | 471 |
} |
| 472 | 472 |
defer func() {
|
| 473 | 473 |
if err != nil {
|
| 474 |
- if err := d.Leave(nid, epid); err != nil {
|
|
| 475 |
- logrus.Warnf("driver leave failed while rolling back join: %v", err)
|
|
| 474 |
+ if e := d.Leave(nid, epid); e != nil {
|
|
| 475 |
+ logrus.Warnf("driver leave failed while rolling back join: %v", e)
|
|
| 476 | 476 |
} |
| 477 | 477 |
} |
| 478 | 478 |
}() |
| ... | ... |
@@ -538,11 +538,11 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
|
| 538 | 538 |
logrus.Debugf("Revoking external connectivity on endpoint %s (%s)", extEp.Name(), extEp.ID())
|
| 539 | 539 |
extN, err := extEp.getNetworkFromStore() |
| 540 | 540 |
if err != nil {
|
| 541 |
- return fmt.Errorf("failed to get network from store during join: %v", err)
|
|
| 541 |
+ return fmt.Errorf("failed to get network from store for revoking external connectivity during join: %v", err)
|
|
| 542 | 542 |
} |
| 543 | 543 |
extD, err := extN.driver(true) |
| 544 | 544 |
if err != nil {
|
| 545 |
- return fmt.Errorf("failed to join endpoint: %v", err)
|
|
| 545 |
+ return fmt.Errorf("failed to get driver for revoking external connectivity during join: %v", err)
|
|
| 546 | 546 |
} |
| 547 | 547 |
if err = extD.RevokeExternalConnectivity(extEp.network.ID(), extEp.ID()); err != nil {
|
| 548 | 548 |
return types.InternalErrorf( |
| ... | ... |
@@ -570,9 +570,9 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
|
| 570 | 570 |
} |
| 571 | 571 |
|
| 572 | 572 |
if !sb.needDefaultGW() {
|
| 573 |
- if err := sb.clearDefaultGW(); err != nil {
|
|
| 573 |
+ if e := sb.clearDefaultGW(); e != nil {
|
|
| 574 | 574 |
logrus.Warnf("Failure while disconnecting sandbox %s (%s) from gateway network: %v",
|
| 575 |
- sb.ID(), sb.ContainerID(), err) |
|
| 575 |
+ sb.ID(), sb.ContainerID(), e) |
|
| 576 | 576 |
} |
| 577 | 577 |
} |
| 578 | 578 |
|
| ... | ... |
@@ -705,7 +705,7 @@ func (ep *endpoint) sbLeave(sb *sandbox, force bool, options ...EndpointOption) |
| 705 | 705 |
|
| 706 | 706 |
d, err := n.driver(!force) |
| 707 | 707 |
if err != nil {
|
| 708 |
- return fmt.Errorf("failed to leave endpoint: %v", err)
|
|
| 708 |
+ return fmt.Errorf("failed to get driver during endpoint leave: %v", err)
|
|
| 709 | 709 |
} |
| 710 | 710 |
|
| 711 | 711 |
ep.Lock() |
| ... | ... |
@@ -765,11 +765,11 @@ func (ep *endpoint) sbLeave(sb *sandbox, force bool, options ...EndpointOption) |
| 765 | 765 |
logrus.Debugf("Programming external connectivity on endpoint %s (%s)", extEp.Name(), extEp.ID())
|
| 766 | 766 |
extN, err := extEp.getNetworkFromStore() |
| 767 | 767 |
if err != nil {
|
| 768 |
- return fmt.Errorf("failed to get network from store during leave: %v", err)
|
|
| 768 |
+ return fmt.Errorf("failed to get network from store for programming external connectivity during leave: %v", err)
|
|
| 769 | 769 |
} |
| 770 | 770 |
extD, err := extN.driver(true) |
| 771 | 771 |
if err != nil {
|
| 772 |
- return fmt.Errorf("failed to leave endpoint: %v", err)
|
|
| 772 |
+ return fmt.Errorf("failed to get driver for programming external connectivity during leave: %v", err)
|
|
| 773 | 773 |
} |
| 774 | 774 |
if err := extD.ProgramExternalConnectivity(extEp.network.ID(), extEp.ID(), sb.Labels()); err != nil {
|
| 775 | 775 |
logrus.Warnf("driver failed programming external connectivity on endpoint %s: (%s) %v",
|
| ... | ... |
@@ -86,6 +86,15 @@ func (nDB *NetworkDB) sendNodeEvent(event NodeEvent_Type) error {
|
| 86 | 86 |
notify: notifyCh, |
| 87 | 87 |
}) |
| 88 | 88 |
|
| 89 |
+ nDB.RLock() |
|
| 90 |
+ noPeers := len(nDB.nodes) <= 1 |
|
| 91 |
+ nDB.RUnlock() |
|
| 92 |
+ |
|
| 93 |
+ // Message enqueued, do not wait for a send if no peer is present |
|
| 94 |
+ if noPeers {
|
|
| 95 |
+ return nil |
|
| 96 |
+ } |
|
| 97 |
+ |
|
| 89 | 98 |
// Wait for the broadcast |
| 90 | 99 |
select {
|
| 91 | 100 |
case <-notifyCh: |