aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-07-20 21:19:36 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-07-20 21:19:36 +0300
commit58e98949ad3dc27b8261688b99f920d106724252 (patch)
treebcdbe7bf4ad102fd532e266bb838548087a85dd2
parentea6808cc41094b87f667705587fe2deea0437a1e (diff)
Log more info when issue warnings in build-result and build-force handlers
-rw-r--r--mod/mod-build-force.cxx29
-rw-r--r--mod/mod-build-result.cxx16
-rw-r--r--mod/mod-build-task.cxx6
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<build> b;
+
+ auto build_timestamp = [&b] ()
+ {
+ return to_string (
+ chrono::duration_cast<std::chrono::nanoseconds> (
+ b->timestamp.time_since_epoch ()).count ());
+ };
+
if (!build_db_->query_one<package_build> (
query<package_build>::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.