aboutsummaryrefslogtreecommitdiff
path: root/monitor/monitor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'monitor/monitor.cxx')
-rw-r--r--monitor/monitor.cxx196
1 files changed, 143 insertions, 53 deletions
diff --git a/monitor/monitor.cxx b/monitor/monitor.cxx
index 7dab2a0..42d481d 100644
--- a/monitor/monitor.cxx
+++ b/monitor/monitor.cxx
@@ -95,7 +95,7 @@ namespace brep
// not.
//
void
- add_delay (shared_ptr<build_delay>, bool report);
+ add_delay (shared_ptr<build_delay>, bool custom_bot, bool report);
bool
empty () const {return reported_delay_count_ == 0;}
@@ -108,19 +108,39 @@ namespace brep
print (const char* header, bool total, bool full) const;
private:
- // Maps delays to the report flag.
+ // Maps delays to the custom bot and report flag.
//
- map<shared_ptr<const build_delay>, bool, compare_delay> delays_;
+ struct delay_info
+ {
+ bool custom_bot;
+ bool report;
+ };
+
+ map<shared_ptr<const build_delay>, delay_info, compare_delay> delays_;
size_t reported_delay_count_ = 0;
+
+ // Number of reported/total delayed package configurations which need to
+ // be built with the custom build bots.
+ //
+ size_t custom_total_delay_count_ = 0;
+ size_t custom_reported_delay_count_ = 0;
};
void delay_report::
- add_delay (shared_ptr<build_delay> delay, bool report)
+ add_delay (shared_ptr<build_delay> delay, bool custom_bot, bool report)
{
- delays_.emplace (move (delay), report);
+ delays_.emplace (move (delay), delay_info {custom_bot, report});
+
+ if (custom_bot)
+ ++custom_total_delay_count_;
if (report)
+ {
++reported_delay_count_;
+
+ if (custom_bot)
+ ++custom_reported_delay_count_;
+ }
}
void delay_report::
@@ -134,6 +154,17 @@ namespace brep
if (total)
cerr << '/' << delays_.size ();
+ if (custom_reported_delay_count_ != 0 ||
+ (total && custom_total_delay_count_ != 0))
+ {
+ cerr << " including " << custom_reported_delay_count_;
+
+ if (total)
+ cerr << '/' << custom_total_delay_count_;
+
+ cerr << " custom";
+ }
+
cerr << "):" << endl;
// Group the printed delays by toolchain and target configuration.
@@ -146,10 +177,15 @@ namespace brep
size_t config_reported_delay_count (0);
size_t config_total_delay_count (0);
+ size_t config_custom_reported_delay_count (0);
+ size_t config_custom_total_delay_count (0);
+
auto brief_config = [&target_config_name,
&target,
&config_reported_delay_count,
&config_total_delay_count,
+ &config_custom_reported_delay_count,
+ &config_custom_total_delay_count,
total] ()
{
if (target_config_name != nullptr)
@@ -166,21 +202,36 @@ namespace brep
if (total)
cerr << '/' << config_total_delay_count;
+ if (config_custom_reported_delay_count != 0 ||
+ (total && config_custom_total_delay_count != 0))
+ {
+ cerr << " including " << config_custom_reported_delay_count;
+
+ if (total)
+ cerr << '/' << config_custom_total_delay_count;
+
+ cerr << " custom";
+ }
+
cerr << ')' << endl;
}
config_reported_delay_count = 0;
config_total_delay_count = 0;
+
+ config_custom_reported_delay_count = 0;
+ config_custom_total_delay_count = 0;
}
};
for (const auto& dr: delays_)
{
- bool report (dr.second);
+ bool report (dr.second.report);
if (full && !report)
continue;
+ bool custom_bot (dr.second.custom_bot);
const shared_ptr<const build_delay>& d (dr.first);
// Print the toolchain, if changed.
@@ -239,6 +290,9 @@ namespace brep
cerr << " " << d->package_name << '/' << d->package_version
<< ' ' << d->package_config_name;
+ if (custom_bot)
+ cerr << " (custom bot)";
+
if (!d->tenant.empty ())
cerr << ' ' << d->tenant;
@@ -247,9 +301,17 @@ namespace brep
else
{
if (report)
+ {
++config_reported_delay_count;
+ if (custom_bot)
+ ++config_custom_reported_delay_count;
+ }
+
++config_total_delay_count;
+
+ if (custom_bot)
+ ++config_custom_total_delay_count;
}
}
@@ -538,7 +600,7 @@ namespace brep
query::id.toolchain_name +
order_by_version (query::id.toolchain_version,
false /* first */) +
- "OFFSET" + query::_ref (offset) + "LIMIT 100");
+ "OFFSET" + query::_ref (offset) + "LIMIT 2000");
connection_ptr conn (db.connection ());
@@ -601,13 +663,18 @@ namespace brep
p->configs)
: nullptr);
- cleanup = (pc == nullptr ||
- !p->buildable ||
- exclude (*pc,
- p->builds,
- p->constraints,
- *ci->second,
- configs.class_inheritance_map));
+ cleanup = (pc == nullptr || !p->buildable);
+
+ if (!cleanup)
+ {
+ db.load (*p, p->constraints_section);
+
+ cleanup = exclude (*pc,
+ p->builds,
+ p->constraints,
+ *ci->second,
+ configs.class_inheritance_map);
+ }
}
if (cleanup)
@@ -650,8 +717,13 @@ namespace brep
conn->prepare_query<buildable_package> ("buildable-package-query",
pq));
- // Prepare the package configuration build prepared query.
+ // Prepare the package configuration build prepared queries.
//
+ using bquery = query<build>;
+ using prep_bquery = prepared_query<build>;
+
+ build_id id;
+
// This query will only be used for toolchains that have no version
// specified on the command line to obtain the latest completed build
// across all toolchain versions, if present, and the latest incomplete
@@ -662,28 +734,26 @@ namespace brep
// toolchain that built the package last and if there are none, pick the
// one for which the build task was issued last.
//
- using bquery = query<package_build>;
- using prep_bquery = prepared_query<package_build>;
-
- build_id id;
- string package_config_name;
-
- const auto& bid (bquery::build::id);
-
- bquery bq ((equal<package_build> (bid.package, id.package) &&
- bid.target == bquery::_ref (id.target) &&
- bid.target_config_name ==
- bquery::_ref (id.target_config_name) &&
- bid.package_config_name ==
- bquery::_ref (package_config_name) &&
- bid.toolchain_name == bquery::_ref (id.toolchain_name)) +
- "ORDER BY" +
- bquery::build::soft_timestamp + "DESC, " +
- bquery::build::timestamp + "DESC" +
- "LIMIT 1");
-
- prep_bquery pbq (
- conn->prepare_query<package_build> ("package-build-query", bq));
+ // @@ TMP Check if we can optimize this query by adding index for
+ // soft_timestamp and/or by setting enable_nestloop=off (or some
+ // such) as we do in mod/mod-builds.cxx.
+ //
+ bquery lbq ((equal<build> (bquery::id,
+ id,
+ false /* toolchain_version */) &&
+ bquery::state != "queued") +
+ "ORDER BY" +
+ bquery::soft_timestamp + "DESC, " +
+ bquery::timestamp + "DESC" +
+ "LIMIT 1");
+
+ prep_bquery plbq (
+ conn->prepare_query<build> ("package-latest-build-query", lbq));
+
+ // This query will only be used to retrieve a specific build by id.
+ //
+ bquery bq (equal<build> (bquery::id, id) && bquery::state != "queued");
+ prep_bquery pbq (conn->prepare_query<build> ("package-build-query", bq));
timestamp now (system_clock::now ());
@@ -816,12 +886,27 @@ namespace brep
for (auto& bp: bps)
{
- shared_ptr<build_package> p (db.load<build_package> (bp.id));
+ shared_ptr<build_package>& p (bp.package);
+
+ db.load (*p, p->constraints_section);
for (const build_package_config& pc: p->configs)
{
for (const build_target_config& tc: configs)
{
+ // Note that we also don't build a package configuration if we
+ // are unable to assign all the required auxiliary machines
+ // for the build (see mod/mod-build-task.cxx for details).
+ // That means that we will also report delays which happen due
+ // to such an inability, which can potentially be not only
+ // because of the infrastructural problem but also because of
+ // an error in the package manifest (build auxiliary
+ // configuration pattern doesn't match any machine
+ // configuration anymore, etc). It doesn't seem easy to
+ // distinguish here which type of problem causes a delay.
+ // Thus, for now let's wait and see if it ever becomes a
+ // problem.
+ //
if (exclude (pc,
p->builds,
p->constraints,
@@ -840,19 +925,9 @@ namespace brep
// the latest build across all toolchain versions and search
// for a specific build otherwise.
//
- shared_ptr<build> b;
-
- if (id.toolchain_version.empty ())
- {
- package_config_name = pc.name;
-
- auto pbs (pbq.execute ());
-
- if (!pbs.empty ())
- b = move (pbs.begin ()->build);
- }
- else
- b = db.find<build> (id);
+ shared_ptr<build> b (id.toolchain_version.empty ()
+ ? plbq.execute_one ()
+ : pbq.execute_one ());
// Note that we consider a build as delayed if it is not
// completed in the expected timeframe. So even if the build
@@ -940,6 +1015,21 @@ namespace brep
soft_delayed = false;
}
+ // If there is a delay, then deduce if this package
+ // configuration needs to be built with a custom build bot.
+ //
+ // Note: only meaningful if there is a delay.
+ //
+ bool custom_bot (false);
+
+ if (hard_delayed || soft_delayed)
+ {
+ if (!p->bot_keys_section.loaded ())
+ db.load (*p, p->bot_keys_section);
+
+ custom_bot = !pc.effective_bot_keys (p->bot_keys).empty ();
+ }
+
// Add hard/soft delays to the respective reports and
// collect the delay for update, if it is reported.
//
@@ -970,7 +1060,7 @@ namespace brep
reported = true;
}
- hard_delays_report.add_delay (d, report);
+ hard_delays_report.add_delay (d, custom_bot, report);
}
if (soft_delayed)
@@ -984,7 +1074,7 @@ namespace brep
reported = true;
}
- soft_delays_report.add_delay (d, report);
+ soft_delays_report.add_delay (d, custom_bot, report);
}
// If we don't consider the report timestamps for reporting