mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-28 08:06:16 +00:00
fix: narrow system errors and apply the filter to every runs list
This commit is contained in:
@@ -337,11 +337,12 @@ async fn get_concurrent_intervals(
|
||||
let sql_c = sqlb_c.query()?;
|
||||
|
||||
let mut tx = user_db.begin(&authed).await?;
|
||||
let running_jobs: Vec<UnifiedJob> = if lq.success.is_none() && lq.resolved != Some(true) {
|
||||
sqlx::query_as(&sql_q).fetch_all(&mut *tx).await?
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let running_jobs: Vec<UnifiedJob> =
|
||||
if lq.success.is_none() && lq.resolved != Some(true) && lq.system_error != Some(true) {
|
||||
sqlx::query_as(&sql_q).fetch_all(&mut *tx).await?
|
||||
} else {
|
||||
vec![]
|
||||
};
|
||||
let completed_jobs: Vec<UnifiedJob> = if lq.running.is_none() {
|
||||
sqlx::query_as(&sql_c).fetch_all(&mut *tx).await?
|
||||
} else {
|
||||
|
||||
@@ -333,7 +333,7 @@ pub struct UnifiedJob {
|
||||
macro_rules! system_error_sql {
|
||||
() => {
|
||||
"COALESCE(v2_job_completed.status = 'failure' AND v2_job_completed.result->'error'->>'name' \
|
||||
IN ('InternalErr', 'SqlErr', 'ConnectingToDatabase', 'WorkerLost', 'OutOfMemory'), false)"
|
||||
IN ('SqlErr', 'ConnectingToDatabase', 'WorkerLost', 'OutOfMemory'), false)"
|
||||
};
|
||||
}
|
||||
pub const SYSTEM_ERROR_SQL: &str = system_error_sql!();
|
||||
|
||||
@@ -17586,9 +17586,9 @@ paths:
|
||||
type: boolean
|
||||
- name: system_error
|
||||
description: >-
|
||||
filter on whether a failed run failed because of the platform (internal or
|
||||
database error, lost worker, out of memory) rather than its code. true keeps only
|
||||
those runs, false hides them
|
||||
filter on whether a failed run failed because of the platform (database error,
|
||||
lost worker, out of memory) rather than its code. true keeps only those runs,
|
||||
false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -17906,9 +17906,9 @@ paths:
|
||||
type: boolean
|
||||
- name: system_error
|
||||
description: >-
|
||||
filter on whether a failed run failed because of the platform (internal or
|
||||
database error, lost worker, out of memory) rather than its code. true keeps only
|
||||
those runs, false hides them
|
||||
filter on whether a failed run failed because of the platform (database error,
|
||||
lost worker, out of memory) rather than its code. true keeps only those runs,
|
||||
false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -18196,9 +18196,9 @@ paths:
|
||||
type: boolean
|
||||
- name: system_error
|
||||
description: >-
|
||||
filter on whether a failed run failed because of the platform (internal or
|
||||
database error, lost worker, out of memory) rather than its code. true keeps only
|
||||
those runs, false hides them
|
||||
filter on whether a failed run failed because of the platform (database error,
|
||||
lost worker, out of memory) rather than its code. true keeps only those runs,
|
||||
false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -27117,9 +27117,9 @@ paths:
|
||||
type: boolean
|
||||
- name: system_error
|
||||
description: >-
|
||||
filter on whether a failed run failed because of the platform (internal or
|
||||
database error, lost worker, out of memory) rather than its code. true keeps only
|
||||
those runs, false hides them
|
||||
filter on whether a failed run failed because of the platform (database error,
|
||||
lost worker, out of memory) rather than its code. true keeps only those runs,
|
||||
false hides them
|
||||
in: query
|
||||
schema:
|
||||
type: boolean
|
||||
@@ -32237,8 +32237,8 @@ components:
|
||||
type: boolean
|
||||
description: >-
|
||||
true when this failed run failed because of the platform rather than its code,
|
||||
derived from its error name: InternalErr, SqlErr, ConnectingToDatabase,
|
||||
WorkerLost or OutOfMemory
|
||||
derived from its error name: SqlErr, ConnectingToDatabase, WorkerLost or
|
||||
OutOfMemory
|
||||
trigger_kind:
|
||||
$ref: "#/components/schemas/JobTriggerKind"
|
||||
worker:
|
||||
|
||||
@@ -4678,7 +4678,8 @@ async fn list_filtered_job_uuids(
|
||||
// Same reasoning as the runs-list union gate: "resolved only" is a completed-jobs
|
||||
// concept, so unioning the queue would feed queued jobs into bulk actions taken
|
||||
// under that filter. "hide resolved" must still keep them.
|
||||
let query = if lq.status.is_some() || lq.resolved == Some(true) {
|
||||
let query = if lq.status.is_some() || lq.resolved == Some(true) || lq.system_error == Some(true)
|
||||
{
|
||||
sqlb.subquery()?
|
||||
} else {
|
||||
let sqlb2 = list_queue_jobs_query(
|
||||
|
||||
@@ -99,12 +99,12 @@ pub enum Error {
|
||||
WorkerLost(String),
|
||||
}
|
||||
|
||||
/// The `error.name`s of a job that the platform failed rather than its own code: an internal or
|
||||
/// database error while handling it, its worker lost mid-run (no ping, worker gone, restarts
|
||||
/// exhausted), or its process killed for memory. The runs list derives `system_error` from these,
|
||||
/// in SQL that must list the same names (`windmill-api-jobs`, `system_error_sql!`).
|
||||
/// The `error.name`s of a job that the platform failed rather than its own code: a database error
|
||||
/// while handling it, its worker lost mid-run (no ping, worker gone, restarts exhausted), or its
|
||||
/// process killed for memory. Not `InternalErr`: the worker also raises it for a job's own bad
|
||||
/// inputs. The runs list derives `system_error` from these, in SQL that must list the same names
|
||||
/// (`windmill-api-jobs`, `system_error_sql!`).
|
||||
pub const SYSTEM_ERROR_NAMES: &[&str] = &[
|
||||
"InternalErr",
|
||||
"SqlErr",
|
||||
"ConnectingToDatabase",
|
||||
"WorkerLost",
|
||||
|
||||
@@ -662,9 +662,14 @@ pub async fn process_result(
|
||||
job.flow_step_id.clone(),
|
||||
)
|
||||
}
|
||||
Connection::Http(_) => {
|
||||
to_raw_value(&"See logs for more details".to_string())
|
||||
}
|
||||
// An agent worker cannot read the logs back, but the error keeps its
|
||||
// name and exit code, which is what classifies an OOM kill.
|
||||
Connection::Http(_) => extract_error_value(
|
||||
&program,
|
||||
"See logs for more details",
|
||||
i,
|
||||
job.flow_step_id.clone(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2206,6 +2211,21 @@ pub fn extract_error_value(
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod exit_error_tests {
|
||||
#[test]
|
||||
fn only_exit_137_is_out_of_memory() {
|
||||
let name = |code| {
|
||||
let v: serde_json::Value =
|
||||
serde_json::from_str(super::extract_error_value("p", "", code, None).get())
|
||||
.unwrap();
|
||||
v["name"].as_str().unwrap().to_string()
|
||||
};
|
||||
assert_eq!(name(137), "OutOfMemory");
|
||||
assert_eq!(name(1), "ExecutionErr");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, feature = "enterprise", feature = "private"))]
|
||||
mod git_sync_pr_tests {
|
||||
use super::{git_sync_deploy_pr_head_branch, git_sync_push_result_pushed};
|
||||
|
||||
Reference in New Issue
Block a user