From da701337ca32a54682a0daddcd2ab85a2f886a18 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 9 Jun 2017 16:25:20 +0300 Subject: Get rid of package configuration unbuilt state --- mod/mod-build-force.cxx | 7 ------- mod/mod-build-log.cxx | 4 +--- mod/mod-build-task.cxx | 29 ++++++++++++++--------------- mod/mod-builds.cxx | 12 +++--------- 4 files changed, 18 insertions(+), 34 deletions(-) (limited to 'mod') diff --git a/mod/mod-build-force.cxx b/mod/mod-build-force.cxx index c0c3d2d..325a1c7 100644 --- a/mod/mod-build-force.cxx +++ b/mod/mod-build-force.cxx @@ -166,13 +166,6 @@ handle (request& rq, response& rs) if (b == nullptr) config_expired ("no package configuration"); - // Respond with 409 (conflict) if the package configuration is in - // inappropriate state for being rebuilt. - // - else if (b->state != build_state::built && - b->state != build_state::building) - throw invalid_request (409, "state is " + to_string (b->state)); - force_state force (b->state == build_state::built ? force_state::forced : force_state::forcing); diff --git a/mod/mod-build-log.cxx b/mod/mod-build-log.cxx index 3daa1e3..281eec6 100644 --- a/mod/mod-build-log.cxx +++ b/mod/mod-build-log.cxx @@ -206,14 +206,12 @@ handle (request& rq, response& rs) // ostream& os (rs.content (200, "text/plain;charset=utf-8", false)); - assert (b->machine && b->machine_summary); - os << "package: " << b->package_name << endl << "version: " << b->package_version << endl << "toolchain: " << b->toolchain_name << '-' << b->toolchain_version << endl << "config: " << b->configuration << endl - << "machine: " << *b->machine << " (" << *b->machine_summary << ")" + << "machine: " << b->machine << " (" << b->machine_summary << ")" << endl << "target: " << (b->target ? b->target->string () : "") << endl diff --git a/mod/mod-build-task.cxx b/mod/mod-build-task.cxx index dc9910f..a56d75b 100644 --- a/mod/mod-build-task.cxx +++ b/mod/mod-build-task.cxx @@ -158,11 +158,10 @@ handle (request& rq, response& rs) } // Go through packages until we find one that has no build configuration - // present in the database, or has the unbuilt one, or in the building state - // but expired (collectively called unbuilt). If such a package - // configuration is found then put it into the building state, set the - // current timestamp and respond with the task for building this package - // configuration. + // present in the database, or is in the building state but expired + // (collectively called unbuilt). If such a package configuration is found + // then put it into the building state, set the current timestamp and respond + // with the task for building this package configuration. // // While trying to find a non-built package configuration we will also // collect the list of the built package configurations which it's time to @@ -213,8 +212,8 @@ handle (request& rq, response& rs) move (task)); }; - // Calculate the expiration time for package configurations being in the - // building (build expiration) or the built (rebuild expiration) state. + // Calculate the build (building state) or rebuild (built state) expiration + // time for package configurations // timestamp now (timestamp::clock::now ()); @@ -385,11 +384,10 @@ handle (request& rq, response& rs) true) && (bld_query::state == "built" || - (bld_query::state == "building" && - ((bld_query::force == "forcing" && - bld_query::timestamp > forced_result_expiration_ns) || - (bld_query::force != "forcing" && // Unforced or forced. - bld_query::timestamp > normal_result_expiration_ns))))); + ((bld_query::force == "forcing" && + bld_query::timestamp > forced_result_expiration_ns) || + (bld_query::force != "forcing" && // Unforced or forced. + bld_query::timestamp > normal_result_expiration_ns)))); connection_ptr bld_conn (build_db_->connection ()); @@ -490,8 +488,8 @@ handle (request& rq, response& rs) } else { - // The package configuration can be in the building or unbuilt - // state, and there are no results. + // The package configuration is in the building state, and there + // are no results. // // Note that in both cases we keep the status intact to be able // to compare it with the final one in the result request @@ -503,7 +501,8 @@ handle (request& rq, response& rs) // build_db_->load (*b, b->results_section); - assert (b->state != build_state::built && b->results.empty ()); + assert (b->state == build_state::building && + b->results.empty ()); b->state = build_state::building; diff --git a/mod/mod-builds.cxx b/mod/mod-builds.cxx index 8bd6f88..da72e17 100644 --- a/mod/mod-builds.cxx +++ b/mod/mod-builds.cxx @@ -96,8 +96,7 @@ build_query (const C& configs, const brep::params::builds& params) }; query q ( - query::id.configuration.in_range (configs.begin (), configs.end ()) && - (query::state == "building" || query::state == "built")); + query::id.configuration.in_range (configs.begin (), configs.end ())); // Note that there is no error reported if the filter parameters parsing // fails. Instead, it is considered that no package builds match such a @@ -363,8 +362,6 @@ handle (request& rq, response& rs) "OFFSET" + to_string (page * page_configs) + "LIMIT" + to_string (page_configs))) { - assert (b.machine); - string ts (butl::to_string (b.timestamp, "%Y-%m-%d %H:%M:%S %Z", true, @@ -376,10 +373,9 @@ handle (request& rq, response& rs) << TR_NAME (b.package_name, string (), root) << TR_VERSION (b.package_name, b.package_version, root) << TR_VALUE ("toolchain", - b.toolchain_name + '-' + - b.toolchain_version.string ()) + b.toolchain_name + '-' + b.toolchain_version.string ()) << TR_VALUE ("config", b.configuration) - << TR_VALUE ("machine", *b.machine) + << TR_VALUE ("machine", b.machine) << TR_VALUE ("target", b.target ? b.target->string () : "") << TR_VALUE ("timestamp", ts) << TR(CLASS="result") @@ -391,8 +387,6 @@ handle (request& rq, response& rs) s << "building | "; else { - assert (b.state == build_state::built); - build_db_->load (b, b.results_section); // If no unsuccessful operations results available, then print the -- cgit v1.1