-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose ready queue states via api, and in kcli queue-summary
This adds connection limit/throttle states to the readyq rows in `kcli queue-summary`, alongside where we would show the suspension state. This makes it easier to understand when a given egress path might be hitting connection limits.
- Loading branch information
Showing
7 changed files
with
248 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use crate::ready_queue::ReadyQueueManager; | ||
use axum::extract::{Json, Query}; | ||
use kumo_api_types::{QueueState, ReadyQueueStateRequest, ReadyQueueStateResponse}; | ||
use kumo_server_common::http_server::auth::TrustedIpRequired; | ||
use kumo_server_common::http_server::AppError; | ||
use std::collections::HashMap; | ||
|
||
/// Retrieve information about the states that apply to a set of | ||
/// ready queues, or all queues if no specific queues were named | ||
/// in the request. | ||
#[utoipa::path( | ||
get, | ||
tag="inspect", | ||
path="/api/admin/ready-q-states/v1", | ||
params(ReadyQueueStateRequest), | ||
responses( | ||
(status = 200, description = "Obtained state information", body=ReadyQueueStateResponse), | ||
), | ||
)] | ||
pub async fn readyq_states( | ||
_: TrustedIpRequired, | ||
Query(request): Query<ReadyQueueStateRequest>, | ||
) -> Result<Json<ReadyQueueStateResponse>, AppError> { | ||
let mut states_by_ready_queue = HashMap::new(); | ||
let queues = ReadyQueueManager::all_queues(); | ||
|
||
for queue in queues { | ||
if !request.queues.is_empty() | ||
&& request | ||
.queues | ||
.iter() | ||
.find(|name| name.as_str() == queue.name()) | ||
.is_none() | ||
{ | ||
continue; | ||
} | ||
|
||
fn add_state( | ||
states_by_ready_queue: &mut HashMap<String, HashMap<String, QueueState>>, | ||
queue_name: &str, | ||
state_name: &str, | ||
state: QueueState, | ||
) { | ||
let entry = states_by_ready_queue | ||
.entry(queue_name.to_string()) | ||
.or_default(); | ||
entry.insert(state_name.to_string(), state); | ||
} | ||
|
||
let states = queue.states.lock(); | ||
if let Some(s) = &states.connection_limited { | ||
add_state( | ||
&mut states_by_ready_queue, | ||
queue.name(), | ||
"connection_limited", | ||
QueueState { | ||
context: s.context.clone(), | ||
since: s.since, | ||
}, | ||
); | ||
} | ||
if let Some(s) = &states.connection_rate_throttled { | ||
add_state( | ||
&mut states_by_ready_queue, | ||
queue.name(), | ||
"connection_rate_throttled", | ||
QueueState { | ||
context: s.context.clone(), | ||
since: s.since, | ||
}, | ||
); | ||
} | ||
} | ||
|
||
Ok(Json(ReadyQueueStateResponse { | ||
states_by_ready_queue, | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters