Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 97 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions orb-backend-status/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ orb-update-agent-dbus.workspace = true
reqwest = { workspace = true, features = ["json"] }
reqwest-middleware = { version = "0.4.1", features = ["json"] }
reqwest-tracing = { version = "0.5.6", features = ["opentelemetry_0_27"] }
reqwest-retry = "0.7.0"
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
serde_with = { version = "3.11.0" }
Expand Down
12 changes: 11 additions & 1 deletion orb-backend-status/src/backend/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use orb_endpoints::{v2::Endpoints as EndpointsV2, Backend};
use orb_info::{OrbId, OrbJabilId, OrbName};
use reqwest::Url;
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware, Extension};
use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware};
use reqwest_tracing::{OtelName, TracingMiddleware};
use std::{str::FromStr, time::Duration};
use tokio::sync::watch;
Expand Down Expand Up @@ -54,15 +55,24 @@ impl StatusClient {
) -> Result<Self> {
let orb_os_version = orb_os_version()?;
info!("backend-status orb_os_version: {}", orb_os_version);

let retry_policy = ExponentialBackoff::builder()
.retry_bounds(Duration::from_millis(100), Duration::from_secs(2))
.build_with_max_retries(5);

let reqwest_client = reqwest::Client::builder()
.timeout(Duration::from_secs(60))
.connect_timeout(Duration::from_secs(2))
.timeout(Duration::from_secs(3))
.user_agent("orb-backend-status")
.build()
.expect("Failed to build client");

let name = orb_id.as_str().to_string().into();

let client = ClientBuilder::new(reqwest_client)
.with_init(Extension(OtelName(name)))
.with(TracingMiddleware::default())
.with(RetryTransientMiddleware::new_with_policy(retry_policy))
.build();

let backend = match Backend::from_str(&args.backend) {
Expand Down
45 changes: 28 additions & 17 deletions orb-connd/src/telemetry/backend_status_wifi_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,33 @@ async fn run_reporter(
interval.set_missed_tick_behavior(time::MissedTickBehavior::Skip);

loop {
tokio::select! {
let scan = tokio::select! {
_ = state_stream.next() => {
info!("NetworkManager state changed - sending immediate WiFi status");
false
}

_ = primary_conn_stream.next() => {
info!("Primary connection changed - sending immediate WiFi status");
false
}

_ = interval.tick() => {}
_ = interval.tick() => {
true
}
};

if let Err(e) = report(&nm, &session_bus).await {
if let Err(e) = report(&nm, &session_bus, scan).await {
error!("failed to report to backend status: {e}");
}
}
}

async fn report(nm: &NetworkManager, session_bus: &zbus::Connection) -> Result<()> {
async fn report(
nm: &NetworkManager,
session_bus: &zbus::Connection,
scan: bool,
) -> Result<()> {
let be_status = BackendStatusProxy::new(session_bus)
.await
.wrap_err("Failed to create Backend Status dbus Proxy")?;
Expand Down Expand Up @@ -106,19 +114,22 @@ async fn report(nm: &NetworkManager, session_bus: &zbus::Connection) -> Result<(
})
.collect();

let scanned_networks: Vec<WifiNetwork> = nm
.wifi_scan()
.await
.inspect_err(|e| warn!("failed to scan wifi: {e}"))
.unwrap_or_default()
.into_iter()
.map(|ap| WifiNetwork {
bssid: ap.bssid,
ssid: ap.ssid,
frequency: ap.freq_mhz,
signal_level: ap.rssi.unwrap_or_default(),
})
.collect();
let scanned_networks = match scan {
true => nm
.wifi_scan()
.await
.inspect_err(|e| warn!("failed to scan wifi: {e}"))
.unwrap_or_default()
.into_iter()
.map(|ap| WifiNetwork {
bssid: ap.bssid,
ssid: ap.ssid,
frequency: ap.freq_mhz,
signal_level: ap.rssi.unwrap_or_default(),
})
.collect(),
false => Vec::new(),
};

let _ = async {
be_status
Expand Down
7 changes: 4 additions & 3 deletions orb-jobs-agent/src/job_system/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ impl JobHandler {
.namespace(relay_namespace)
.auth(auth.clone())
.connection_timeout(Duration::from_secs(5))
.connection_backoff(Duration::from_secs(3))
.keep_alive_interval(Duration::from_secs(10))
.keep_alive_timeout(Duration::from_secs(5))
.connection_backoff(Duration::from_millis(500))
.keep_alive_interval(Duration::from_secs(2))
.keep_alive_timeout(Duration::from_secs(2))
.ack_timeout(Duration::from_secs(5))
.build();

info!("Connecting to relay: {:?}", relay_host);
Expand Down
Loading