Skip to content

Commit

Permalink
Always backoff and retry management server
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.
  • Loading branch information
iffyio committed Sep 7, 2021
1 parent d2b0f7f commit efe25c1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/xds/ads_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ impl AdsClient {
mut shutdown_rx: watch::Receiver<()>,
) -> ExecutionResult {
let mut backoff = ExponentialBackoff::<SystemClock>::default();
// If we hit connectivity issues, always backoff and retry.
backoff.max_elapsed_time = None;

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

Expand Down Expand Up @@ -205,7 +208,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 +453,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 efe25c1

Please sign in to comment.