From 39a7404e6cddb2053a87f86935cda566c54bd4e6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 22 Mar 2024 18:00:37 +0300 Subject: Add tenant_service_hints --- mod/mod-build-force.cxx | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'mod/mod-build-force.cxx') diff --git a/mod/mod-build-force.cxx b/mod/mod-build-force.cxx index 2eddb10..bdae356 100644 --- a/mod/mod-build-force.cxx +++ b/mod/mod-build-force.cxx @@ -10,6 +10,8 @@ #include #include +#include +#include #include #include @@ -184,10 +186,11 @@ handle (request& rq, response& rs) // If the incomplete package build is being forced to rebuild and the // tenant_service_build_queued callback is associated with the package // tenant, then stash the state, the build object, and the callback pointer - // for the subsequent service `queued` notification. + // and calculate the hints for the subsequent service `queued` notification. // const tenant_service_build_queued* tsq (nullptr); optional>> tss; + tenant_service_build_queued::build_queued_hints qhs; connection_ptr conn (build_db_->connection ()); { @@ -244,13 +247,27 @@ handle (request& rq, response& rs) tsq = dynamic_cast ( i->second.get ()); + // If we ought to call the + // tenant_service_build_queued::build_queued() callback, then also + // set the package tenant's queued timestamp to the current time + // to prevent the notifications race (see tenant::queued_timestamp + // for details). + // if (tsq != nullptr) { - // If we ought to call the - // tenant_service_build_queued::build_queued() callback, then - // also set the package tenant's queued timestamp to the current - // time to prevent the notifications race (see - // tenant::queued_timestamp for details). + // Calculate the tenant service hints. + // + buildable_package_count tpc ( + build_db_->query_value ( + query::build_tenant::id == t->id)); + + shared_ptr p ( + build_db_->load (b->id.package)); + + qhs = tenant_service_build_queued::build_queued_hints { + tpc == 1, p->configs.size () == 1}; + + // Set the package tenant's queued timestamp. // t->queued_timestamp = system_clock::now (); build_db_->update (t); @@ -280,7 +297,11 @@ handle (request& rq, response& rs) vector qbs; qbs.push_back (move (b)); - if (auto f = tsq->build_queued (ss, qbs, build_state::building, log_writer_)) + if (auto f = tsq->build_queued (ss, + qbs, + build_state::building, + qhs, + log_writer_)) update_tenant_service_state (conn, qbs.back ().tenant, f); } -- cgit v1.1