fix: handle agent completed/cancelled statuses in job executor
Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 10m23s
CI Pipeline / Clippy Lints (push) Successful in 1m22s
CI Pipeline / Rust Unit Tests (push) Successful in 1m2s
CI Pipeline / Security Audit (push) Successful in 4s
CI Pipeline / Frontend Lint & Type Check (push) Successful in 12s
CI Pipeline / Build .deb & Release (push) Has been skipped
Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 10m23s
CI Pipeline / Clippy Lints (push) Successful in 1m22s
CI Pipeline / Rust Unit Tests (push) Successful in 1m2s
CI Pipeline / Security Audit (push) Successful in 4s
CI Pipeline / Frontend Lint & Type Check (push) Successful in 12s
CI Pipeline / Build .deb & Release (push) Has been skipped
The linux_patch_api agent returns "completed" as its terminal success status, but the worker only recognized "succeeded". This caused the worker to log "unexpected agent status — ignoring" every 60 seconds and never mark patch jobs as finished. Changes: - job_executor.rs: match "completed" alongside "succeeded" as terminal success status, mapping both to patch_job_hosts.status = succeeded - job_executor.rs: match "cancelled" as a terminal failure status, routing to handle_host_failure with appropriate error message - pm-agent-client types.rs: updated AgentJobStatus doc comment to list all valid agent statuses: queued, running, succeeded, completed, failed, cancelled
This commit is contained in:
@ -184,7 +184,7 @@ pub struct ApplyPatchesResponse {
|
|||||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct AgentJobStatus {
|
pub struct AgentJobStatus {
|
||||||
pub job_id: String,
|
pub job_id: String,
|
||||||
/// Current status: `"running"`, `"succeeded"`, `"failed"`, or `"cancelled"`.
|
/// Current status: `"queued"`, `"running"`, `"succeeded"`, `"completed"`, `"failed"`, or `"cancelled"`.
|
||||||
pub status: String,
|
pub status: String,
|
||||||
pub progress_percent: Option<u8>,
|
pub progress_percent: Option<u8>,
|
||||||
pub output: Option<String>,
|
pub output: Option<String>,
|
||||||
|
|||||||
@ -552,7 +552,7 @@ async fn poll_single_host(pool: PgPool, config: Arc<AppConfig>, row: PatchJobHos
|
|||||||
};
|
};
|
||||||
|
|
||||||
match status.status.as_str() {
|
match status.status.as_str() {
|
||||||
"succeeded" => {
|
"succeeded" | "completed" => {
|
||||||
tracing::info!(pjh_id = %row.id, "poll_single_host: agent job succeeded");
|
tracing::info!(pjh_id = %row.id, "poll_single_host: agent job succeeded");
|
||||||
if let Err(e) = sqlx::query(
|
if let Err(e) = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
@ -587,6 +587,13 @@ async fn poll_single_host(pool: PgPool, config: Arc<AppConfig>, row: PatchJobHos
|
|||||||
"poll_single_host: job still in progress"
|
"poll_single_host: job still in progress"
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
"cancelled" => {
|
||||||
|
tracing::info!(pjh_id = %row.id, "poll_single_host: agent job cancelled");
|
||||||
|
let err_msg = status
|
||||||
|
.error
|
||||||
|
.unwrap_or_else(|| "Agent job was cancelled".to_string());
|
||||||
|
handle_host_failure(pool, row.id, err_msg).await;
|
||||||
|
},
|
||||||
other => {
|
other => {
|
||||||
tracing::warn!(
|
tracing::warn!(
|
||||||
pjh_id = %row.id,
|
pjh_id = %row.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user