Skip to content

Commit

Permalink
Early Networking: retry instead of bailing on 503 (#6106)
Browse files Browse the repository at this point in the history
Related
---
#6064
  • Loading branch information
internet-diglett authored Aug 1, 2024
1 parent 9d811b7 commit 0e64e25
Showing 1 changed file with 35 additions and 11 deletions.
46 changes: 35 additions & 11 deletions sled-agent/src/bootstrap/early_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use dpd_client::types::{
use dpd_client::Client as DpdClient;
use futures::future;
use gateway_client::Client as MgsClient;
use http::StatusCode;
use internal_dns::resolver::{ResolveError, Resolver as DnsResolver};
use internal_dns::ServiceName;
use mg_admin_client::types::BfdPeerConfig as MgBfdPeerConfig;
Expand Down Expand Up @@ -40,6 +41,7 @@ use std::collections::{HashMap, HashSet};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddrV6};
use std::time::{Duration, Instant};
use thiserror::Error;
use tokio::time::sleep;

const BGP_SESSION_RESOLUTION: u64 = 100;

Expand Down Expand Up @@ -436,17 +438,39 @@ impl<'a> EarlyNetworkSetup<'a> {
"Configuring default uplink on switch";
"config" => #?dpd_port_settings
);
dpd.port_settings_apply(
&port_id,
Some(OMICRON_DPD_TAG),
&dpd_port_settings,
)
.await
.map_err(|e| {
EarlyNetworkSetupError::Dendrite(format!(
"unable to apply uplink port configuration: {e}"
))
})?;

loop {
match dpd
.port_settings_apply(
&port_id,
Some(OMICRON_DPD_TAG),
&dpd_port_settings,
)
.await
{
Ok(_) => break Ok(()),
Err(e) => {
if let Some(StatusCode::SERVICE_UNAVAILABLE) =
e.status()
{
warn!(
self.log,
"unable to apply uplink configuration, dendrite not available";
"port_id" => ?port_id,
"configuration" => ?dpd_port_settings,
);
sleep(Duration::from_secs(5)).await;
continue;
} else {
break Err(EarlyNetworkSetupError::Dendrite(
format!(
"unable to apply uplink port configuration: {e}"
),
));
}
}
}
}?;
}

let mgd = MgdClient::new(
Expand Down

0 comments on commit 0e64e25

Please sign in to comment.