Blob Blame History Raw
From 4814d5f44861960233faca91c3e2a612346511e8 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Tue, 28 Feb 2017 16:33:40 -0800
Subject: [PATCH] Duplicate jobs on 'died' as well as 'quit'

This is effectively similar to the previous reversion of commit
21307cdec3974c334ec5aac30f9508b19d5b6fb2 , but with the revised
stop_job code that makes straight reversion impossible. It ought
to duplicate jobs that die as well as those that quit on a
signal. Note that with this change to the condition that triggers
the block, we must adjust the `_stop_job_finish` callback inside
the duplication block to *not* make the worker process quit if
`$aborted` was 'died', only if it was 'quit' (the hardcoded '1'
value is safe for upstream, but it's not safe for us with this
change).
---
 lib/OpenQA/Worker/Jobs.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/OpenQA/Worker/Jobs.pm b/lib/OpenQA/Worker/Jobs.pm
index 57569f1c..c102ef29 100644
--- a/lib/OpenQA/Worker/Jobs.pm
+++ b/lib/OpenQA/Worker/Jobs.pm
@@ -474,14 +474,14 @@ sub _stop_job_2 {
     }
     if (!$job_done && $aborted ne 'api-failure') {
         log_debug(sprintf 'job %d incomplete', $job->{id});
-        if ($aborted eq 'quit') {
+        if ($aborted eq 'quit' || $aborted eq 'died') {
             log_debug(sprintf "duplicating job %d\n", $job->{id});
             api_call(
                 'post',
                 'jobs/' . $job->{id} . '/duplicate',
                 params   => {dup_type_auto => 1},
                 callback => sub {
-                    upload_status(1, sub { _stop_job_finish({result => 'incomplete'}, 1) });
+                    upload_status(1, sub { _stop_job_finish({result => 'incomplete'}, $aborted eq 'quit') });
                 });
         }
         else {
-- 
2.12.0