diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-30 23:07:26 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-04-01 13:13:23 +0300 |
commit | 2b2f2dc54856b679e8fd42b053f7361241c0f836 (patch) | |
tree | cdba437bf14b65d729ed027869c9ad8041dbe4fd /monitor | |
parent | 8dec2ac658d78d58437d77be08c9f2614c259cc6 (diff) |
Invent alternative package rebuild timeout
Diffstat (limited to 'monitor')
-rw-r--r-- | monitor/monitor.cli | 27 | ||||
-rw-r--r-- | monitor/monitor.cxx | 72 |
2 files changed, 80 insertions, 19 deletions
diff --git a/monitor/monitor.cli b/monitor/monitor.cli index e4d228f..b3687a9 100644 --- a/monitor/monitor.cli +++ b/monitor/monitor.cli @@ -32,10 +32,10 @@ namespace brep \cb{brep-monitor} analyzes the \cb{brep} internal state and reports the infrastructure issues printing their descriptions to \cb{stderr}. - The specified \cb{brep} configuration file (<brep-config>) is used to - retrieve information required to access the databases and deduce the - expected behavior. Most of this information can be overridden via the - command line options. + The specified \cb{brep} module configuration file (<brep-config>) is + used to retrieve information required to access the databases and + deduce the expected behavior. Most of this information can be + overridden via the command line options. Currently, only delayed package builds for the specified toolchains are reported. If toolchain version is omitted then all package builds with @@ -64,10 +64,21 @@ namespace brep { "<seconds>", "Time to wait (in seconds) before considering a package build as - delayed. If unspecified, the sum of \cb{brep}'s - \cb{build-normal-rebuild-timeout} and \cb{build-result-timeout} - configuration option values is used. Note also that an archived - package that is unbuilt is always considered delayed." + delayed. If unspecified, it is the sum of the package rebuild timeout + (normal rebuild timeout if the alternative timeout is unspecified and + the maximum of two otherwise) and the build result timeout (see the + \cb{build-normal-rebuild-timeout}, \cb{build-alt-rebuild-*}, and + \cb{build-result-timeout} \c{brep} module configuration options + for details). + + Note that a package that was not built before it was archived is + always considered as delayed. However, to distinguish this case from + a situation where a package was archived before a configuration have + been added, \cb{brep-monitor} needs to observe the package as + buildable for this configuration before it is archived. As result, if + you run \cb{brep-monitor} periodically (for example, as a cron job), + then make sure its running period is less than the tenant archive + timeout." } std::size_t --report-timeout diff --git a/monitor/monitor.cxx b/monitor/monitor.cxx index d1442d5..bbab0a5 100644 --- a/monitor/monitor.cxx +++ b/monitor/monitor.cxx @@ -140,12 +140,15 @@ namespace brep << "': " << e << endl; return 1; } - } - if (!mod_ops.build_config_specified ()) - { - cerr << "warning: package building functionality is disabled" << endl; - return 0; + if (mod_ops.build_alt_rebuild_start_specified () != + mod_ops.build_alt_rebuild_stop_specified ()) + { + cerr << "build-alt-rebuild-start and build-alt-rebuild-stop " + << "configuration options must both be either specified or not " + << "in '" << f << "'" << endl; + return 1; + } } // Parse the toolchains suppressing duplicates. @@ -212,6 +215,12 @@ namespace brep // Parse buildtab. // + if (!mod_ops.build_config_specified ()) + { + cerr << "warning: package building functionality is disabled" << endl; + return 0; + } + build_configs configs; try @@ -471,14 +480,55 @@ namespace brep prep_bquery pbq ( conn->prepare_query<package_build> ("package-build-query", bq)); - timestamp::duration build_timeout ( - ops.build_timeout_specified () - ? chrono::seconds (ops.build_timeout ()) - : chrono::seconds (mod_ops.build_normal_rebuild_timeout () + - mod_ops.build_result_timeout ())); + duration build_timeout; - timestamp now (system_clock::now ()); + // If the build timeout is not specified explicitly, then calculate it + // as the sum of the package rebuild timeout (normal rebuild timeout if + // the alternative timeout is unspecified and the maximum of two + // otherwise) and the build result timeout. + // + if (!ops.build_timeout_specified ()) + { + duration normal_rebuild_timeout ( + chrono::seconds (mod_ops.build_normal_rebuild_timeout ())); + if (mod_ops.build_alt_rebuild_start_specified ()) + { + // Calculate the alternative rebuild timeout as the time interval + // lenght, unless it is specified explicitly. + // + if (!mod_ops.build_alt_rebuild_timeout_specified ()) + { + const duration& start (mod_ops.build_alt_rebuild_start ()); + const duration& stop (mod_ops.build_alt_rebuild_stop ()); + + // Note that if the stop time is less than the start time then the + // interval extends through the midnight. + // + build_timeout = start <= stop + ? stop - start + : (24h - start) + stop; + } + else + build_timeout = + chrono::seconds (mod_ops.build_alt_rebuild_timeout ()); + + // Take the maximum of the alternative and normal rebuild timeouts. + // + if (build_timeout < normal_rebuild_timeout) + build_timeout = normal_rebuild_timeout; + } + else + build_timeout = normal_rebuild_timeout; + + // Summarize the rebuild and build result timeouts. + // + build_timeout += chrono::seconds (mod_ops.build_result_timeout ()); + } + else + build_timeout = chrono::seconds (ops.build_timeout ()); + + timestamp now (system_clock::now ()); timestamp build_expiration (now - build_timeout); timestamp report_expiration ( |