1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #1059 from mavenugo/ovNotify

Handle endpoint & network object in notifyEvent avoiding id lookup
This commit is contained in:
Alessandro Boch 2016-03-29 15:35:58 -07:00
commit 45eee51bc3
3 changed files with 19 additions and 9 deletions

View file

@ -129,8 +129,8 @@ func (d *driver) Leave(nid, eid string) error {
if d.notifyCh != nil { if d.notifyCh != nil {
d.notifyCh <- ovNotify{ d.notifyCh <- ovNotify{
action: "leave", action: "leave",
nid: nid, nw: n,
eid: eid, ep: ep,
} }
} }

View file

@ -12,8 +12,8 @@ import (
type ovNotify struct { type ovNotify struct {
action string action string
eid string ep *endpoint
nid string nw *network
} }
type logWriter struct{} type logWriter struct{}
@ -81,13 +81,12 @@ func (d *driver) serfJoin(neighIP string) error {
} }
func (d *driver) notifyEvent(event ovNotify) { func (d *driver) notifyEvent(event ovNotify) {
n := d.network(event.nid) ep := event.ep
ep := n.endpoint(event.eid)
ePayload := fmt.Sprintf("%s %s %s %s", event.action, ep.addr.IP.String(), ePayload := fmt.Sprintf("%s %s %s %s", event.action, ep.addr.IP.String(),
net.IP(ep.addr.Mask).String(), ep.mac.String()) net.IP(ep.addr.Mask).String(), ep.mac.String())
eName := fmt.Sprintf("jl %s %s %s", d.serfInstance.LocalMember().Addr.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 { if err := d.serfInstance.UserEvent(eName, []byte(ePayload), true); err != nil {
logrus.Errorf("Sending user event failed: %v\n", err) logrus.Errorf("Sending user event failed: %v\n", err)

View file

@ -180,13 +180,24 @@ func (d *driver) nodeJoin(node string, self bool) {
} }
func (d *driver) pushLocalEndpointEvent(action, nid, eid string) { 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() { if !d.isSerfAlive() {
return return
} }
d.notifyCh <- ovNotify{ d.notifyCh <- ovNotify{
action: "join", action: "join",
nid: nid, nw: n,
eid: eid, ep: ep,
} }
} }