depot_deploy: support lazy pkg installation

This patch enhances the 'Child' interface with the ability to retry the
deployment after an initial attempt failed. This way, packages can be
installed on demand based on the error feedback of deployment attempts.
This commit is contained in:
Norman Feske 2018-05-20 00:45:03 +02:00 committed by Christian Helmuth
parent a4b94dad41
commit 6f0a727aee
2 changed files with 40 additions and 1 deletions

View File

@ -140,6 +140,9 @@ class Depot_deploy::Child : public List_model<Child>::Element
if (pkg.attribute_value("path", Archive::Path()) != _blueprint_pkg_path)
return;
/* package was missing but is installed now */
_pkg_incomplete = false;
Xml_node const runtime = pkg.sub_node("runtime");
Number_of_bytes const ram { runtime.attribute_value("ram", Number_of_bytes()) };
@ -165,11 +168,22 @@ class Depot_deploy::Child : public List_model<Child>::Element
if (path != _blueprint_pkg_path)
return;
error(path, " incomplete or missing");
log(path, " incomplete or missing");
_pkg_incomplete = true;
}
/**
* Reconsider deployment of child after installing missing archives
*/
void reset_incomplete()
{
if (_pkg_incomplete) {
_pkg_incomplete = false;
_pkg_xml.destruct();
}
}
void gen_query(Xml_generator &xml) const
{
if (_configured() || _pkg_incomplete)
@ -190,6 +204,19 @@ class Depot_deploy::Child : public List_model<Child>::Element
*/
inline void gen_start_node(Xml_generator &, Xml_node common,
Depot_rom_server const &depot_rom) const;
/**
* Generate installation entry needed for the completion of the child
*/
void gen_installation_entry(Xml_generator &xml) const
{
if (!_pkg_incomplete) return;
xml.node("archive", [&] () {
xml.attribute("path", _config_pkg_path());
xml.attribute("source", "no");
});
}
};

View File

@ -78,6 +78,12 @@ class Depot_deploy::Children
child.mark_as_incomplete(missing); }); });
}
void reset_incomplete()
{
_children.for_each([&] (Child &child) {
child.reset_incomplete(); });
}
void gen_start_nodes(Xml_generator &xml, Xml_node common,
Child::Depot_rom_server const &depot_rom) const
{
@ -90,6 +96,12 @@ class Depot_deploy::Children
_children.for_each([&] (Child const &child) {
child.gen_query(xml); });
}
void gen_installation_entries(Xml_generator &xml) const
{
_children.for_each([&] (Child const &child) {
child.gen_installation_entry(xml); });
}
};
#endif /* _CHILDREN_H_ */