Skip to content

Commit

Permalink
Merge pull request #248 from dave-tucker/fix-monitor-fallback
Browse files Browse the repository at this point in the history
client: Monitor fallback only on unsupported rpc
  • Loading branch information
dave-tucker authored Oct 14, 2021
2 parents 8f9d582 + 12f9d1e commit d84057e
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,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 {
Expand Down Expand Up @@ -766,17 +762,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 {
o.options.logger.V(3).Error(err, "method monitor_cond_since not supported, falling back to monitor_cond")
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 {
o.options.logger.V(3).Error(err, "method monitor_cond not supported, falling back to monitor")
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 {
o.options.logger.V(3).Error(err, "method monitor_cond_since not supported, falling back to monitor_cond")
monitor.Method = ovsdb.ConditionalMonitorRPC
return o.monitor(ctx, cookie, reconnecting, monitor)
}
if monitor.Method == ovsdb.ConditionalMonitorRPC {
o.options.logger.V(3).Error(err, "method monitor_cond not supported, falling back to monitor")
monitor.Method = ovsdb.MonitorRPC
return o.monitor(ctx, cookie, reconnecting, monitor)
}
}
return err
}
Expand Down

0 comments on commit d84057e

Please sign in to comment.