diff --git a/client/client.go b/client/client.go index fd911b92..883d694b 100644 --- a/client/client.go +++ b/client/client.go @@ -684,11 +684,7 @@ func (o *ovsdbClient) MonitorCancel(ctx context.Context, cookie MonitorCookie) e // RFC 7047 : monitor func (o *ovsdbClient) Monitor(ctx context.Context, monitor *Monitor) (MonitorCookie, error) { cookie := newMonitorCookie(o.primaryDBName) - err := o.monitor(ctx, cookie, false, monitor) - if err != nil && err == ErrUnsupportedRPC { - return cookie, o.monitor(ctx, cookie, false, monitor) - } - return cookie, err + return cookie, o.monitor(ctx, cookie, false, monitor) } func (o *ovsdbClient) monitor(ctx context.Context, cookie MonitorCookie, reconnecting bool, monitor *Monitor) error { @@ -769,17 +765,17 @@ func (o *ovsdbClient) monitor(ctx context.Context, cookie MonitorCookie, reconne if err == rpc2.ErrShutdown { return ErrNotConnected } - // TODO: Match unsupported RPC method error - if monitor.Method == ovsdb.ConditionalMonitorSinceRPC { - log.Printf("libovsdb: method monitor_cond_since not supported, falling back to monitor_cond: %v", err.Error()) - monitor.Method = ovsdb.ConditionalMonitorRPC - // return to ensure that we release any held mutexes, retry must happen from a calling function - return ErrUnsupportedRPC - } else if monitor.Method == ovsdb.ConditionalMonitorRPC { - log.Printf("libovsdb: method monitor_cond not supported, falling back to monitor: %v", err.Error()) - monitor.Method = ovsdb.MonitorRPC - // return to ensure that we release any held mutexes, retry must happen from a calling function - return ErrUnsupportedRPC + if err.Error() == "unknown method" { + if monitor.Method == ovsdb.ConditionalMonitorSinceRPC { + log.Printf("libovsdb: method monitor_cond_since not supported, falling back to monitor_cond: %v", err.Error()) + monitor.Method = ovsdb.ConditionalMonitorRPC + return o.monitor(ctx, cookie, reconnecting, monitor) + } + if monitor.Method == ovsdb.ConditionalMonitorRPC { + log.Printf("libovsdb: method monitor_cond not supported, falling back to monitor: %v", err.Error()) + monitor.Method = ovsdb.MonitorRPC + return o.monitor(ctx, cookie, reconnecting, monitor) + } } return err }