fix: error handler does not recover flow anymore and error handler is called only once up the flow

This commit is contained in:
Ruben Fiszel
2023-09-29 00:28:11 +02:00
parent 6d6383e366
commit 445bf965ed
3 changed files with 16 additions and 11 deletions
+15 -6
View File
@@ -70,6 +70,7 @@ pub async fn update_flow_status_after_job_completion<
same_worker_tx.clone(),
worker_dir,
stop_early_override,
false,
rsmq.clone(),
)
.await?;
@@ -87,6 +88,7 @@ pub async fn update_flow_status_after_job_completion<
same_worker_tx.clone(),
worker_dir,
nrec.stop_early_override,
nrec.skip_error_handler,
rsmq.clone(),
)
.await?;
@@ -99,6 +101,7 @@ pub struct RecUpdateFlowStatusAfterJobCompletion {
success: bool,
result: serde_json::Value,
stop_early_override: Option<bool>,
skip_error_handler: bool,
}
// #[instrument(level = "trace", skip_all)]
pub async fn update_flow_status_after_job_completion_internal<
@@ -116,9 +119,10 @@ pub async fn update_flow_status_after_job_completion_internal<
same_worker_tx: Sender<Uuid>,
worker_dir: &str,
stop_early_override: Option<bool>,
skip_error_handler: bool,
rsmq: Option<R>,
) -> error::Result<Option<RecUpdateFlowStatusAfterJobCompletion>> {
let (should_continue_flow, flow_job, stop_early, skip_if_stop_early, nresult) = {
let (should_continue_flow, flow_job, stop_early, skip_if_stop_early, nresult, is_failure_step) = {
// tracing::debug!("UPDATE FLOW STATUS: {flow:?} {success} {result:?} {w_id} {depth}");
let old_status_json = sqlx::query_scalar!(
@@ -204,8 +208,6 @@ pub async fn update_flow_status_after_job_completion_internal<
_ => false,
};
let skip_failure = skip_branch_failure || skip_loop_failures;
let mut tx: QueueTransaction<'_, _> = (rsmq.clone(), db.begin().await?).into();
let (inc_step_counter, new_status) = match module_status {
@@ -327,6 +329,7 @@ pub async fn update_flow_status_after_job_completion_internal<
_ => (None, None),
};
if success || (flow_jobs.is_some() && (skip_loop_failures || skip_branch_failure)) {
success = true;
(
true,
Some(FlowStatusModule::Success {
@@ -510,7 +513,7 @@ pub async fn update_flow_status_after_job_completion_internal<
_ if flow_job.canceled => false,
true => !is_last_step,
false if unrecoverable => false,
false if skip_failure => !is_last_step,
false if skip_branch_failure || skip_loop_failures => !is_last_step,
false
if next_retry(
&module.and_then(|m| m.retry.clone()).unwrap_or_default(),
@@ -520,7 +523,11 @@ pub async fn update_flow_status_after_job_completion_internal<
{
true
}
false if has_failure_module(flow, tx.transaction_mut()).await? && !is_failure_step => {
false
if !is_failure_step
&& !skip_error_handler
&& has_failure_module(flow, tx.transaction_mut()).await? =>
{
true
}
false => false,
@@ -548,6 +555,7 @@ pub async fn update_flow_status_after_job_completion_internal<
stop_early,
skip_if_stop_early,
nresult,
is_failure_step,
)
};
@@ -584,7 +592,7 @@ pub async fn update_flow_status_after_job_completion_internal<
add_completed_job(
db,
&flow_job,
success,
success && !is_failure_step && !skip_error_handler,
stop_early && skip_if_stop_early,
&nresult,
logs,
@@ -638,6 +646,7 @@ pub async fn update_flow_status_after_job_completion_internal<
} else {
None
},
skip_error_handler: skip_error_handler || is_failure_step,
}));
}
Ok(None)
@@ -1,8 +1,5 @@
export default `import os
# flow is considered recovered and a success unless an exception is raised
def main(message: str, name: str):
flow_id = os.environ.get("WM_FLOW_JOB_ID")
print("message", message)
+1 -2
View File
@@ -128,8 +128,7 @@ export async function main(x: string) {
}
`
export const DENO_FAILURE_MODULE_CODE = `// flow is considered recovered and a success unless an exception is thrown
export const DENO_FAILURE_MODULE_CODE = `
export async function main(message: string, name: string) {
const flow_id = Deno.env.get("WM_FLOW_JOB_ID")
console.log("message", message)