| ... | ... |
@@ -303,11 +303,16 @@ func (s *DockerSwarmSuite) TestSwarmContainerEndpointOptions(c *check.C) {
|
| 303 | 303 |
_, err = d.Cmd("run", "-d", "--net=foo", "--name=second", "busybox", "top")
|
| 304 | 304 |
c.Assert(err, checker.IsNil, check.Commentf(out)) |
| 305 | 305 |
|
| 306 |
- // ping first container and its alias |
|
| 306 |
+ _, err = d.Cmd("run", "-d", "--net=foo", "--net-alias=third-alias", "busybox", "top")
|
|
| 307 |
+ c.Assert(err, checker.IsNil, check.Commentf(out)) |
|
| 308 |
+ |
|
| 309 |
+ // ping first container and its alias, also ping third and anonymous container by its alias |
|
| 307 | 310 |
_, err = d.Cmd("exec", "second", "ping", "-c", "1", "first")
|
| 308 | 311 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 309 | 312 |
_, err = d.Cmd("exec", "second", "ping", "-c", "1", "first-alias")
|
| 310 | 313 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 314 |
+ _, err = d.Cmd("exec", "second", "ping", "-c", "1", "third-alias")
|
|
| 315 |
+ c.Assert(err, check.IsNil, check.Commentf(out)) |
|
| 311 | 316 |
} |
| 312 | 317 |
|
| 313 | 318 |
func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *check.C) {
|
| ... | ... |
@@ -23,7 +23,7 @@ github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5 |
| 23 | 23 |
github.com/imdario/mergo 0.2.1 |
| 24 | 24 |
|
| 25 | 25 |
#get libnetwork packages |
| 26 |
-github.com/docker/libnetwork bdc9dcea1a74443c61d4d156dfcece1df8105f13 |
|
| 26 |
+github.com/docker/libnetwork 1a019214c9cb80bd56219e5d6994a22caf302895 |
|
| 27 | 27 |
github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894 |
| 28 | 28 |
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80 |
| 29 | 29 |
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec |
| ... | ... |
@@ -463,6 +463,10 @@ func (ep *endpoint) deleteDriverInfoFromCluster() error {
|
| 463 | 463 |
} |
| 464 | 464 |
|
| 465 | 465 |
func (ep *endpoint) addServiceInfoToCluster() error {
|
| 466 |
+ if ep.isAnonymous() && len(ep.myAliases) == 0 || ep.Iface().Address() == nil {
|
|
| 467 |
+ return nil |
|
| 468 |
+ } |
|
| 469 |
+ |
|
| 466 | 470 |
n := ep.getNetwork() |
| 467 | 471 |
if !n.isClusterEligible() {
|
| 468 | 472 |
return nil |
| ... | ... |
@@ -470,38 +474,42 @@ func (ep *endpoint) addServiceInfoToCluster() error {
|
| 470 | 470 |
|
| 471 | 471 |
c := n.getController() |
| 472 | 472 |
agent := c.getAgent() |
| 473 |
- if !ep.isAnonymous() && ep.Iface().Address() != nil {
|
|
| 474 |
- var ingressPorts []*PortConfig |
|
| 475 |
- if ep.svcID != "" {
|
|
| 476 |
- // Gossip ingress ports only in ingress network. |
|
| 477 |
- if n.ingress {
|
|
| 478 |
- ingressPorts = ep.ingressPorts |
|
| 479 |
- } |
|
| 480 | 473 |
|
| 481 |
- if err := c.addServiceBinding(ep.svcName, ep.svcID, n.ID(), ep.ID(), ep.virtualIP, ingressPorts, ep.svcAliases, ep.Iface().Address().IP); err != nil {
|
|
| 482 |
- return err |
|
| 483 |
- } |
|
| 474 |
+ var ingressPorts []*PortConfig |
|
| 475 |
+ if ep.svcID != "" {
|
|
| 476 |
+ // Gossip ingress ports only in ingress network. |
|
| 477 |
+ if n.ingress {
|
|
| 478 |
+ ingressPorts = ep.ingressPorts |
|
| 484 | 479 |
} |
| 485 | 480 |
|
| 486 |
- buf, err := proto.Marshal(&EndpointRecord{
|
|
| 487 |
- Name: ep.Name(), |
|
| 488 |
- ServiceName: ep.svcName, |
|
| 489 |
- ServiceID: ep.svcID, |
|
| 490 |
- VirtualIP: ep.virtualIP.String(), |
|
| 491 |
- IngressPorts: ingressPorts, |
|
| 492 |
- Aliases: ep.svcAliases, |
|
| 493 |
- TaskAliases: ep.myAliases, |
|
| 494 |
- EndpointIP: ep.Iface().Address().IP.String(), |
|
| 495 |
- }) |
|
| 496 |
- |
|
| 497 |
- if err != nil {
|
|
| 481 |
+ if err := c.addServiceBinding(ep.svcName, ep.svcID, n.ID(), ep.ID(), ep.virtualIP, ingressPorts, ep.svcAliases, ep.Iface().Address().IP); err != nil {
|
|
| 498 | 482 |
return err |
| 499 | 483 |
} |
| 484 |
+ } |
|
| 500 | 485 |
|
| 501 |
- if agent != nil {
|
|
| 502 |
- if err := agent.networkDB.CreateEntry("endpoint_table", n.ID(), ep.ID(), buf); err != nil {
|
|
| 503 |
- return err |
|
| 504 |
- } |
|
| 486 |
+ name := ep.Name() |
|
| 487 |
+ if ep.isAnonymous() {
|
|
| 488 |
+ name = ep.MyAliases()[0] |
|
| 489 |
+ } |
|
| 490 |
+ |
|
| 491 |
+ buf, err := proto.Marshal(&EndpointRecord{
|
|
| 492 |
+ Name: name, |
|
| 493 |
+ ServiceName: ep.svcName, |
|
| 494 |
+ ServiceID: ep.svcID, |
|
| 495 |
+ VirtualIP: ep.virtualIP.String(), |
|
| 496 |
+ IngressPorts: ingressPorts, |
|
| 497 |
+ Aliases: ep.svcAliases, |
|
| 498 |
+ TaskAliases: ep.myAliases, |
|
| 499 |
+ EndpointIP: ep.Iface().Address().IP.String(), |
|
| 500 |
+ }) |
|
| 501 |
+ |
|
| 502 |
+ if err != nil {
|
|
| 503 |
+ return err |
|
| 504 |
+ } |
|
| 505 |
+ |
|
| 506 |
+ if agent != nil {
|
|
| 507 |
+ if err := agent.networkDB.CreateEntry("endpoint_table", n.ID(), ep.ID(), buf); err != nil {
|
|
| 508 |
+ return err |
|
| 505 | 509 |
} |
| 506 | 510 |
} |
| 507 | 511 |
|
| ... | ... |
@@ -509,6 +517,10 @@ func (ep *endpoint) addServiceInfoToCluster() error {
|
| 509 | 509 |
} |
| 510 | 510 |
|
| 511 | 511 |
func (ep *endpoint) deleteServiceInfoFromCluster() error {
|
| 512 |
+ if ep.isAnonymous() && len(ep.myAliases) == 0 {
|
|
| 513 |
+ return nil |
|
| 514 |
+ } |
|
| 515 |
+ |
|
| 512 | 516 |
n := ep.getNetwork() |
| 513 | 517 |
if !n.isClusterEligible() {
|
| 514 | 518 |
return nil |
| ... | ... |
@@ -517,23 +529,23 @@ func (ep *endpoint) deleteServiceInfoFromCluster() error {
|
| 517 | 517 |
c := n.getController() |
| 518 | 518 |
agent := c.getAgent() |
| 519 | 519 |
|
| 520 |
- if !ep.isAnonymous() {
|
|
| 521 |
- if ep.svcID != "" && ep.Iface().Address() != nil {
|
|
| 522 |
- var ingressPorts []*PortConfig |
|
| 523 |
- if n.ingress {
|
|
| 524 |
- ingressPorts = ep.ingressPorts |
|
| 525 |
- } |
|
| 520 |
+ if ep.svcID != "" && ep.Iface().Address() != nil {
|
|
| 521 |
+ var ingressPorts []*PortConfig |
|
| 522 |
+ if n.ingress {
|
|
| 523 |
+ ingressPorts = ep.ingressPorts |
|
| 524 |
+ } |
|
| 526 | 525 |
|
| 527 |
- if err := c.rmServiceBinding(ep.svcName, ep.svcID, n.ID(), ep.ID(), ep.virtualIP, ingressPorts, ep.svcAliases, ep.Iface().Address().IP); err != nil {
|
|
| 528 |
- return err |
|
| 529 |
- } |
|
| 526 |
+ if err := c.rmServiceBinding(ep.svcName, ep.svcID, n.ID(), ep.ID(), ep.virtualIP, ingressPorts, ep.svcAliases, ep.Iface().Address().IP); err != nil {
|
|
| 527 |
+ return err |
|
| 530 | 528 |
} |
| 531 |
- if agent != nil {
|
|
| 532 |
- if err := agent.networkDB.DeleteEntry("endpoint_table", n.ID(), ep.ID()); err != nil {
|
|
| 533 |
- return err |
|
| 534 |
- } |
|
| 529 |
+ } |
|
| 530 |
+ |
|
| 531 |
+ if agent != nil {
|
|
| 532 |
+ if err := agent.networkDB.DeleteEntry("endpoint_table", n.ID(), ep.ID()); err != nil {
|
|
| 533 |
+ return err |
|
| 535 | 534 |
} |
| 536 | 535 |
} |
| 536 |
+ |
|
| 537 | 537 |
return nil |
| 538 | 538 |
} |
| 539 | 539 |
|
| ... | ... |
@@ -147,7 +147,9 @@ func (n *networkNamespace) AddNeighbor(dstIP net.IP, dstMac net.HardwareAddr, op |
| 147 | 147 |
return fmt.Errorf("could not add neighbor entry: %v", err)
|
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 |
+ n.Lock() |
|
| 150 | 151 |
n.neighbors = append(n.neighbors, nh) |
| 152 |
+ n.Unlock() |
|
| 151 | 153 |
|
| 152 | 154 |
return nil |
| 153 | 155 |
} |