libnetwork: fix flaky Swarm service DNS

When libnetwork receives a watch event for a driver table entry from
NetworkDB it passes the event along to the interested driver. This code
contains a subtle bug: update events from NetworkDB are passed along to
the driver as Delete events! This bug was lying dormant as driver-table
entries can only be added by the driver, not updated. Now that NetworkDB
broadcasts an UpdateEvent to watchers if the entry is already known to
the local NetworkDB, irrespective of whether the event received from the
remote peer was a CREATE or UPDATE event, the bug is causing problems.
Whenever a remote node replaces an entry in the overlay_peer_table but
the intermediate delete state was not received by the local node, the
new CREATE event would be translated to an UpdateEvent by NetworkDB and
subsequently handled by the overlay driver as if the entry was deleted!

Bubble table UPDATE events up to the network driver as Update events.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider
2025-06-18 17:58:08 -04:00
parent de24c536b0
commit a7f01d238e

View File

@@ -836,7 +836,7 @@ func (n *Network) handleDriverTableEvent(ev events.Event) {
tname = event.Table
key = event.Key
value = event.Value
etype = driverapi.Delete
etype = driverapi.Update
}
d.EventNotify(etype, n.ID(), tname, key, value)