Skip to content

Commit

Permalink
Always backoff and retry management server (#392)
Browse files Browse the repository at this point in the history
If we hit connectivity issues, make sure we retry until
the server comes back up.

Co-authored-by: Mark Mandel <[email protected]>
  • Loading branch information
iffyio and markmandel authored Sep 8, 2021
1 parent 418041f commit 8adba36
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/xds/ads_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ impl AdsClient {
listener_manager_args: ListenerManagerArgs,
mut shutdown_rx: watch::Receiver<()>,
) -> ExecutionResult {
let mut backoff = ExponentialBackoff::<SystemClock>::default();
let mut backoff = ExponentialBackoff::<SystemClock> {
// If we hit connectivity issues, always backoff and retry.
max_elapsed_time: None,
..Default::default()
};

let log = self.log;
let metrics = self.metrics;

Expand Down Expand Up @@ -205,7 +210,7 @@ impl AdsClient {
Err(RpcSessionError::Receive(handlers, bk_off, status)) => {
resource_handlers = handlers;
backoff = bk_off;
error!(log, "Failed to receive from XDS server"; "address" => server_addr, "status" => #?status);
error!(log, "Failed to receive response from XDS server"; "address" => server_addr, "status" => #?status);
Self::backoff(
&log,
&mut backoff
Expand Down Expand Up @@ -450,9 +455,10 @@ impl AdsClient {
log: &Logger,
backoff: &mut ExponentialBackoff<C>,
) -> Result<(), ExecutionError> {
let delay = backoff
.next_backoff()
.ok_or(ExecutionError::BackoffLimitExceeded)?;
let delay = backoff.next_backoff().ok_or_else(|| {
warn!(log, "Backoff limit exceeded");
ExecutionError::BackoffLimitExceeded
})?;
info!(log, "Retrying"; "delay" => #?delay);
tokio::time::sleep(delay).await;
Ok(())
Expand Down

0 comments on commit 8adba36

Please sign in to comment.