Skip to content

Commit

Permalink
Handle endpoint & network object in notifyEvent avoiding id lookup
Browse files Browse the repository at this point in the history
Join & Leave Serf processing happens in a separate goroutine and there
are cases as in #985, it can
cause lookup failures when endpoint delete processing happens before
Serf gets a chance to handle the leave processing.

The fix is to avoid such lookups in this goroutine, but handle the
endpoint and network objects directly.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
  • Loading branch information
mavenugo committed Mar 30, 2016
1 parent 455c2d4 commit 398e47d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions drivers/overlay/joinleave.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ func (d *driver) Leave(nid, eid string) error {
if d.notifyCh != nil {
d.notifyCh <- ovNotify{
action: "leave",
nid: nid,
eid: eid,
nw: n,
ep: ep,
}
}

Expand Down
9 changes: 4 additions & 5 deletions drivers/overlay/ov_serf.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

type ovNotify struct {
action string
eid string
nid string
ep *endpoint
nw *network
}

type logWriter struct{}
Expand Down Expand Up @@ -81,13 +81,12 @@ func (d *driver) serfJoin(neighIP string) error {
}

func (d *driver) notifyEvent(event ovNotify) {
n := d.network(event.nid)
ep := n.endpoint(event.eid)
ep := event.ep

ePayload := fmt.Sprintf("%s %s %s %s", event.action, ep.addr.IP.String(),
net.IP(ep.addr.Mask).String(), ep.mac.String())
eName := fmt.Sprintf("jl %s %s %s", d.serfInstance.LocalMember().Addr.String(),
event.nid, event.eid)
event.nw.id, ep.id)

if err := d.serfInstance.UserEvent(eName, []byte(ePayload), true); err != nil {
logrus.Errorf("Sending user event failed: %v\n", err)
Expand Down
15 changes: 13 additions & 2 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,24 @@ func (d *driver) nodeJoin(node string, self bool) {
}

func (d *driver) pushLocalEndpointEvent(action, nid, eid string) {
n := d.network(nid)
if n == nil {
logrus.Debugf("Error pushing local endpoint event for network %s", nid)
return
}
ep := n.endpoint(eid)
if ep == nil {
logrus.Debugf("Error pushing local endpoint event for ep %s / %s", nid, eid)
return
}

if !d.isSerfAlive() {
return
}
d.notifyCh <- ovNotify{
action: "join",
nid: nid,
eid: eid,
nw: n,
ep: ep,
}
}

Expand Down

0 comments on commit 398e47d

Please sign in to comment.