From 05bd0fbc28a8ad3f772a5fb4ca069ea50763bc51 Mon Sep 17 00:00:00 2001 From: Flavio Crisciani Date: Sat, 17 Jun 2017 17:25:04 -0700 Subject: [PATCH] NetworkDB deleteEntry has to happen Signed-off-by: Flavio Crisciani (cherry picked from commit 49378070a1683d0b53550bc21e121816bdf28cd8) --- agent.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/agent.go b/agent.go index 6f072ae1be..173dd768d4 100644 --- a/agent.go +++ b/agent.go @@ -525,13 +525,13 @@ func (ep *endpoint) addServiceInfoToCluster(sb *sandbox) error { TaskAliases: ep.myAliases, EndpointIP: ep.Iface().Address().IP.String(), }) - if err != nil { return err } if agent != nil { if err := agent.networkDB.CreateEntry("endpoint_table", n.ID(), ep.ID(), buf); err != nil { + logrus.Warnf("addServiceInfoToCluster NetworkDB CreateEntry failed for %s %s err:%s", ep.id, n.id, err) return err } } @@ -556,6 +556,13 @@ func (ep *endpoint) deleteServiceInfoFromCluster(sb *sandbox, method string) err agent := c.getAgent() if !ep.isAnonymous() && ep.Iface().Address() != nil { + // Delete the entry from network DB, this will trigger a notification to other nodes + if agent != nil { + if err := agent.networkDB.DeleteEntry("endpoint_table", n.ID(), ep.ID()); err != nil { + logrus.Warnf("deleteServiceInfoFromCluster NetworkDB DeleteEntry failed for %s %s err:%s", ep.id, n.id, err) + } + } + // Update locally if ep.svcID != "" { // This is a task part of a service var ingressPorts []*PortConfig @@ -571,11 +578,6 @@ func (ep *endpoint) deleteServiceInfoFromCluster(sb *sandbox, method string) err return err } } - if agent != nil { - if err := agent.networkDB.DeleteEntry("endpoint_table", n.ID(), ep.ID()); err != nil { - return err - } - } } logrus.Debugf("deleteServiceInfoFromCluster from %s END for %s %s", method, ep.svcName, ep.ID())