fix(detmir): stabilize rust health gates
This commit is contained in:
@@ -307,7 +307,7 @@ fn latest_bucket_event(client: &Client, api_base: &str, bucket_id: &str) -> Resu
|
||||
.filter(|item| item.is_object())
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
objects.sort_by(|left, right| event_effective_ts(right).cmp(&event_effective_ts(left)));
|
||||
objects.sort_by_key(|item| std::cmp::Reverse(event_effective_ts(item)));
|
||||
Ok(objects.into_iter().next())
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ fn read_context(
|
||||
.pointer("/data/active")
|
||||
.and_then(Value::as_bool)
|
||||
.unwrap_or(false);
|
||||
if age >= 0 && age < 900 && !active {
|
||||
if (0..900).contains(&age) && !active {
|
||||
state.host_inactive = true;
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,7 @@ fn read_context(
|
||||
.and_then(Value::as_array)
|
||||
.map(Vec::len)
|
||||
.unwrap_or(0);
|
||||
if age >= 0 && age < 300 && status == "ok" && problems == 0 {
|
||||
if (0..300).contains(&age) && status == "ok" && problems == 0 {
|
||||
state.guard_healthy = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,6 +755,15 @@ fn counter_delta(
|
||||
}
|
||||
}
|
||||
|
||||
fn transport_counter_key(prefix: &str, bucket_id: &str, data: &Value, metric: &str) -> String {
|
||||
format!(
|
||||
"{prefix}:{bucket_id}:{}:{}:{}:{metric}",
|
||||
value_str(data.get("hostname")),
|
||||
int_or_zero(data.get("sessionId")),
|
||||
value_str(data.get("username"))
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct RuntimeThresholds {
|
||||
sample_limit: i64,
|
||||
@@ -858,7 +867,7 @@ fn check_file_operations_runtime(
|
||||
let send_failures = int_or_zero(health_data.get("sendFailures"));
|
||||
let (previous, delta) = counter_delta(
|
||||
counter_state.as_deref_mut(),
|
||||
&format!("file-operations:{bucket_id}:sendFailures"),
|
||||
&transport_counter_key("file-operations", bucket_id, health_data, "sendFailures"),
|
||||
send_failures,
|
||||
);
|
||||
let health_item = json!({
|
||||
@@ -996,7 +1005,7 @@ fn check_endpoint_self_test_metrics(
|
||||
let send_failures = int_or_zero(data.get("sendFailures"));
|
||||
let (previous, delta) = counter_delta(
|
||||
counter_state.as_deref_mut(),
|
||||
&format!("endpoint-self-test:{bucket_id}:sendFailures"),
|
||||
&transport_counter_key("endpoint-self-test", &bucket_id, data, "sendFailures"),
|
||||
send_failures,
|
||||
);
|
||||
let item = json!({
|
||||
@@ -1501,6 +1510,24 @@ mod tests {
|
||||
assert_eq!(counter_delta(Some(&mut state), "k", 1), (Some(13), 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transport_counter_key_separates_sessions() {
|
||||
let data = json!({
|
||||
"hostname": "SHARKON2025",
|
||||
"sessionId": 4,
|
||||
"username": "USER4"
|
||||
});
|
||||
assert_eq!(
|
||||
transport_counter_key(
|
||||
"file-operations",
|
||||
"aw-file-operations_SHARKON2025",
|
||||
&data,
|
||||
"sendFailures"
|
||||
),
|
||||
"file-operations:aw-file-operations_SHARKON2025:SHARKON2025:4:USER4:sendFailures"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_excerpt_truncates_like_python() {
|
||||
let text = json!("one two three");
|
||||
|
||||
@@ -151,12 +151,18 @@ fn process_one(zip_path: &Path) -> Result<ProcessResult> {
|
||||
}
|
||||
archive_sidecars(&report_dir, &sidecars)?;
|
||||
archive_drop_package(&report_dir, zip_path)?;
|
||||
if sidecars.case_id.is_some() && !Path::new(CASE_ALERT).is_file() {
|
||||
if let Some(case_id) = sidecars.case_id {
|
||||
if Path::new(CASE_ALERT).is_file() {
|
||||
return Ok(ProcessResult {
|
||||
latest_intake: latest,
|
||||
case_alert,
|
||||
});
|
||||
}
|
||||
run_checked(
|
||||
Path::new(LINKER),
|
||||
&[
|
||||
"--case-id".to_string(),
|
||||
sidecars.case_id.unwrap().to_string(),
|
||||
case_id.to_string(),
|
||||
"--mode".to_string(),
|
||||
mode,
|
||||
"--link-source".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user