fix terminal exit delivery and stale control-plane views
This commit is contained in:
5 files changed
+307
-34
No files matched your search
@@ -27,7 +27,6 @@ use types::{
|
||||
RefreshFleetDevicesResponse, WakeFleetDeviceRequest, WakeFleetDeviceResponse,
|
||||
};
|
||||
|
||||
const MAX_REFRESH_AGENTS: usize = 128;
|
||||
const REFRESH_CONCURRENCY: usize = 8;
|
||||
|
||||
pub async fn list_fleet_devices(
|
||||
@@ -51,22 +50,13 @@ pub async fn refresh_fleet_devices(
|
||||
State(state): State<AppState>,
|
||||
Json(req): Json<RefreshFleetDevicesRequest>,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
let mut agent_ids = if req.agent_ids.is_empty() {
|
||||
let agent_ids = if req.agent_ids.is_empty() {
|
||||
let sessions = state.sessions.read().await;
|
||||
sessions.keys().cloned().collect::<Vec<_>>()
|
||||
} else {
|
||||
req.agent_ids.clone()
|
||||
};
|
||||
agent_ids.sort();
|
||||
agent_ids.dedup();
|
||||
if agent_ids.len() > MAX_REFRESH_AGENTS {
|
||||
warn!(
|
||||
requested = agent_ids.len(),
|
||||
capped = MAX_REFRESH_AGENTS,
|
||||
"capping fleet refresh agent count"
|
||||
);
|
||||
agent_ids.truncate(MAX_REFRESH_AGENTS);
|
||||
}
|
||||
let agent_ids = normalize_refresh_agent_ids(agent_ids);
|
||||
|
||||
let results = futures_util::stream::iter(agent_ids.into_iter().map(|agent_id| {
|
||||
let state = state.clone();
|
||||
@@ -105,6 +95,12 @@ pub async fn refresh_fleet_devices(
|
||||
))
|
||||
}
|
||||
|
||||
fn normalize_refresh_agent_ids(mut agent_ids: Vec<String>) -> Vec<String> {
|
||||
agent_ids.sort();
|
||||
agent_ids.dedup();
|
||||
agent_ids
|
||||
}
|
||||
|
||||
async fn refresh_fleet_agent_result(
|
||||
state: &AppState,
|
||||
agent_id: &str,
|
||||
|
||||
@@ -8,9 +8,23 @@ use super::build::{
|
||||
AgentRuntimeStatus, FleetBuildContext, build_fleet_devices, filter_fleet_devices,
|
||||
known_device_summary,
|
||||
};
|
||||
use super::normalize_refresh_agent_ids;
|
||||
use super::types::ListFleetDevicesQuery;
|
||||
use crate::state::{AgentDeviceRow, AgentDeviceWithChildren, DeviceIdentifier, KnownDevice};
|
||||
|
||||
#[test]
|
||||
fn refresh_agent_selection_keeps_all_agents_beyond_previous_cap() {
|
||||
let ids = (0..140)
|
||||
.map(|index| format!("agent-{index:03}"))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let selected = normalize_refresh_agent_ids(ids);
|
||||
|
||||
assert_eq!(selected.len(), 140);
|
||||
assert_eq!(selected.first().map(String::as_str), Some("agent-000"));
|
||||
assert_eq!(selected.last().map(String::as_str), Some("agent-139"));
|
||||
}
|
||||
|
||||
fn context(connected: &[&str]) -> FleetBuildContext {
|
||||
FleetBuildContext {
|
||||
agent_status: connected
|
||||
|
||||
Reference in new issue
Block a user