From 5286456e4840d17f04545a41422e0e8a6bb6623a Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 15 Feb 2018 11:06:02 +0100 Subject: [PATCH] depot_deploy: graceful handling of missing content This patch improves the error handling for the case where the depot lacks the content of the to-be-deployed pkg. Instead of infinitely reattempting to obtain blueprints for such content, the deploy tool prints a single message. --- repos/gems/src/app/depot_deploy/child.h | 25 ++++++++++++++++++++++++- repos/gems/src/app/depot_deploy/main.cc | 4 ++++ repos/gems/src/app/depot_query/main.cc | 4 ++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/repos/gems/src/app/depot_deploy/child.h b/repos/gems/src/app/depot_deploy/child.h index 08bfc9280a..03d18ff1f5 100644 --- a/repos/gems/src/app/depot_deploy/child.h +++ b/repos/gems/src/app/depot_deploy/child.h @@ -61,6 +61,11 @@ class Depot_deploy::Child : public List_model::Element Binary_name _binary_name { }; Config_name _config_name { }; + /* + * Set if the depot query for the child's blueprint failed. + */ + bool _pkg_incomplete = false; + bool _configured() const { return _pkg_xml.constructed() @@ -122,6 +127,9 @@ class Depot_deploy::Child : public List_model::Element /* import new start node */ _start_xml.construct(_alloc, start_node); + + /* reset error state, attempt to obtain the blueprint again */ + _pkg_incomplete = false; } void apply_blueprint(Xml_node pkg) @@ -144,9 +152,24 @@ class Depot_deploy::Child : public List_model::Element _pkg_xml.construct(_alloc, pkg); } + void mark_as_incomplete(Xml_node missing) + { + /* print error message only once */ + if(_pkg_incomplete) + return; + + Archive::Path const path = missing.attribute_value("path", Archive::Path()); + if (path != _blueprint_pkg_path) + return; + + error(path, " incomplete or missing"); + + _pkg_incomplete = true; + } + void gen_query(Xml_generator &xml) const { - if (_configured()) + if (_configured() || _pkg_incomplete) return; xml.node("blueprint", [&] () { diff --git a/repos/gems/src/app/depot_deploy/main.cc b/repos/gems/src/app/depot_deploy/main.cc index 5b947421d1..f7bf321fa8 100644 --- a/repos/gems/src/app/depot_deploy/main.cc +++ b/repos/gems/src/app/depot_deploy/main.cc @@ -73,6 +73,10 @@ class Depot_deploy::Children blueprint.for_each_sub_node("pkg", [&] (Xml_node pkg) { _children.for_each([&] (Child &child) { child.apply_blueprint(pkg); }); }); + + blueprint.for_each_sub_node("missing", [&] (Xml_node missing) { + _children.for_each([&] (Child &child) { + child.mark_as_incomplete(missing); }); }); } void gen_start_nodes(Xml_generator &xml, Xml_node common) diff --git a/repos/gems/src/app/depot_query/main.cc b/repos/gems/src/app/depot_query/main.cc index 0a4e78883e..030e59fb20 100644 --- a/repos/gems/src/app/depot_query/main.cc +++ b/repos/gems/src/app/depot_query/main.cc @@ -273,8 +273,8 @@ struct Depot_query::Main catch (Xml_generator::Buffer_exceeded) { throw; /* handled by 'generate' */ } catch (...) { - warning("could not obtain blueprint for '", pkg, "'"); - } + xml.node("missing", [&] () { + xml.attribute("path", pkg); }); } }); }); }