From 58e98949ad3dc27b8261688b99f920d106724252 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 20 Jul 2023 21:19:36 +0300 Subject: Log more info when issue warnings in build-result and build-force handlers --- mod/mod-build-force.cxx | 29 +++++++++++++++++++++-------- mod/mod-build-result.cxx | 16 +++++++++++++--- mod/mod-build-task.cxx | 6 +++--- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/mod/mod-build-force.cxx b/mod/mod-build-force.cxx index af4b8e9..04e1883 100644 --- a/mod/mod-build-force.cxx +++ b/mod/mod-build-force.cxx @@ -188,16 +188,29 @@ handle (request& rq, response& rs) if (b->force != force) { + // Log the force rebuild with the warning severity, truncating the + // reason if too long. + // + diag_record dr (warn); + dr << "force rebuild for "; + + if (!b->tenant.empty ()) + dr << b->tenant << ' '; + + dr << b->package_name << '/' << b->package_version << ' ' + << b->target_config_name << '/' << b->target << ' ' + << b->package_config_name << ' ' + << b->toolchain_name << '-' << b->toolchain_version + << " (state: " << to_string (b->state) << ' ' << to_string (b->force) + << "): "; + + if (reason.size () < 50) + dr << reason; + else + dr << string (reason, 0, 50) << "..."; + b->force = force; build_db_->update (b); - - l1 ([&]{trace << "force rebuild for " - << b->tenant << ' ' - << b->package_name << '/' << b->package_version << ' ' - << b->target_config_name << '/' << b->target << ' ' - << b->package_config_name << ' ' - << b->toolchain_name << '-' << b->toolchain_version - << ": " << reason;}); } t.commit (); diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx index 533921b..3e54d12 100644 --- a/mod/mod-build-result.cxx +++ b/mod/mod-build-result.cxx @@ -201,6 +201,14 @@ handle (request& rq, response&) package_build pb; shared_ptr b; + + auto build_timestamp = [&b] () + { + return to_string ( + chrono::duration_cast ( + b->timestamp.time_since_epoch ()).count ()); + }; + if (!build_db_->query_one ( query::build::id == id, pb)) { @@ -208,11 +216,13 @@ handle (request& rq, response&) } else if ((b = move (pb.build))->state != build_state::building) { - warn_expired ("package configuration state is " + to_string (b->state)); + warn_expired ("package configuration state is " + to_string (b->state) + + ", force state " + to_string (b->force) + + ", timestamp " + build_timestamp ()); } else if (b->timestamp != session.timestamp) { - warn_expired ("non-matching timestamp"); + warn_expired ("non-matching timestamp " + build_timestamp ()); } else if (authenticate_session (*options_, rqm.challenge, *b, rqm.session)) { @@ -303,7 +313,7 @@ handle (request& rq, response&) "dependency"); } - unforced = b->force == force_state::unforced; + unforced = (b->force == force_state::unforced); // Don't send email to the build-email address for the // success-to-success status change, unless the build was forced. diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index 3ab0ea8..390fe8e 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -876,7 +876,7 @@ handle (request& rq, response& rs) // // This is why we query the database for configurations that should not // be built (in the built state, or in the building state and not - // expired). Having such a list we will select the first build + // expired). Having such a list we will select the first build // configuration that is not in the list (if available) for the // response. // @@ -921,8 +921,8 @@ handle (request& rq, response& rs) return (b.force == force_state::forced && b.timestamp <= forced_rebuild_expiration) || - b.soft_timestamp <= soft_rebuild_expiration || - b.hard_timestamp <= hard_rebuild_expiration; + b.soft_timestamp <= soft_rebuild_expiration || + b.hard_timestamp <= hard_rebuild_expiration; }; // Convert a build to the hard rebuild, resetting the agent checksum. -- cgit v1.1