From 531943d795a2a01e7293af6fd724e626b91156c9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 13 Apr 2023 19:36:23 +0300 Subject: Add support for interrupt build result status --- mod/mod-build-task.cxx | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'mod/mod-build-task.cxx') diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index bd5034b..9ce2520 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -720,25 +720,19 @@ handle (request& rq, response& rs) b.hard_timestamp <= hard_rebuild_expiration; }; - // Convert a build to the hard rebuild, resetting the agent checksum and - // dropping the previous build task result. + // Convert a build to the hard rebuild, resetting the agent checksum. // // Note that since the checksums are hierarchical, the agent checksum // reset will trigger resets of the "subordinate" checksums up to the // dependency checksum and so the package will be rebuilt. // - // Also note that there is no sense to keep the build task result since we - // don't accept the skip result for the hard rebuild task. We, however, - // keep the status intact (see below for the reasoning). + // Also note that we keep the previous build task result and status + // intact since we may still need to revert the build into the built + // state if the task execution is interrupted. // auto convert_to_hard = [] (const shared_ptr& b) { b->agent_checksum = nullopt; - - // Mark the section as loaded, so results are updated. - // - b->results_section.load (); - b->results.clear (); }; // Return SHA256 checksum of the controller logic and the configuration @@ -1051,8 +1045,9 @@ handle (request& rq, response& rs) // Note that in both cases we keep the status intact to be // able to compare it with the final one in the result // request handling in order to decide if to send the - // email. The same is true for the forced flag (in the sense - // that we don't set the force state to unforced). + // notification email or to revert it to the built state if + // interrupted. The same is true for the forced flag (in + // the sense that we don't set the force state to unforced). // assert (b->state == build_state::building); @@ -1139,7 +1134,13 @@ handle (request& rq, response& rs) if (x->status != y->status) return x->status > y->status; // Larger status goes first. - return x->timestamp < y->timestamp; // Older goes first. + // Older build completion goes first. + // + // Note that a completed build can have the state change timestamp + // (timestamp member) newer than the completion timestamp + // (soft_timestamp member) if the build was interrupted. + // + return x->soft_timestamp < y->soft_timestamp; }; sort (rebuilds.begin (), rebuilds.end (), cmp); -- cgit v1.1