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.
This commit is contained in:
Norman Feske 2018-02-15 11:06:02 +01:00
parent cb9a448fc9
commit 5286456e48
3 changed files with 30 additions and 3 deletions

View File

@ -61,6 +61,11 @@ class Depot_deploy::Child : public List_model<Child>::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<Child>::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<Child>::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", [&] () {

View File

@ -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)

View File

@ -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); }); }
});
});
}