Fix race condition in ovn routeagent handler
Fixes:
@@ -139,6 +139,14 @@ func (ovn *Handler) RemoteEndpointCreated(endpoint *submV1.Endpoint) error {
ovn.mutex.Lock()
defer ovn.mutex.Unlock()
+ existingEndPoint, ok := ovn.remoteEndpoints[endpoint.Spec.ClusterID]
+
+ if ok && existingEndPoint.CreationTimestamp.After(endpoint.CreationTimestamp.Time) {
+ logger.Infof("Ignoring new remote %#v since a later endpoint was already"+
+ "processed", endpoint)
+ return nil
+ }
+
ovn.remoteEndpoints[endpoint.Name] = endpoint
err := ovn.updateHostNetworkDataplane()
@@ -187,6 +195,14 @@ func (ovn *Handler) RemoteEndpointRemoved(endpoint *submV1.Endpoint) error {
ovn.mutex.Lock()
defer ovn.mutex.Unlock()
+ existingEndPoint, ok := ovn.remoteEndpoints[endpoint.Spec.ClusterID]
+
+ if ok && existingEndPoint.CreationTimestamp.After(endpoint.CreationTimestamp.Time) {
+ logger.Infof("Ignoring deleted remote %#v since a later endpoint was already"+
+ "processed", endpoint)
+ return nil
+ }
+
delete(ovn.remoteEndpoints, endpoint.Name)
err := ovn.updateHostNetworkDataplane()
