Commit 13fcd193 authored by Łukasz Nowak's avatar Łukasz Nowak

slapos.cookbook: Fix publish_failsafe

Do not return installed files in order to avoid endless Uninstall/Install of
the part and instead use the uninstall hook to handle the file when part is
uinstalled.

Also re-install during update if there was a problem with publishing during
install; note that checking for file presence on each update is very fast, so
the speed gain is preserved.
parent 74822133
......@@ -166,6 +166,10 @@ setup(name=name,
'zero-knowledge.read = slapos.recipe.zero_knowledge:ReadRecipe',
'zero-knowledge.write = slapos.recipe.zero_knowledge:WriteRecipe'
],
'zc.buildout.uninstall': [
'publish_failsafe = slapos.recipe.publish:RecipeFailsafe.uninstall',
'publish.serialised_failsafe = slapos.recipe.publish:SerialisedFailsafe.uninstall',
]
},
extras_require=extras_require,
test_suite='slapos.test',
......
......@@ -71,9 +71,9 @@ class Serialised(Recipe):
class Failsafe(object):
def _setConnectionDict(self, publish_dict, slave_reference):
error_status_file = self.options.get('-error-status-file')
if error_status_file:
self.return_list = [error_status_file]
else:
# Note: We can't put -error-status-file in return list as by default it is
# not present, and buildout wants the section to have it, so it
# Uninstalls/Installs the part instead of just Updating it
self.return_list = []
try:
super(Failsafe, self)._setConnectionDict(publish_dict, slave_reference)
......@@ -86,6 +86,19 @@ class Failsafe(object):
if os.path.exists(error_status_file):
os.unlink(error_status_file)
def update(self):
error_status_file = self.options.get('-error-status-file')
if error_status_file is not None:
if os.path.exists(error_status_file):
# last run failed, so need to reinstall
self.install()
def uninstall(name, options):
error_status_file = options.get('-error-status-file')
if error_status_file is not None:
if os.path.exists(error_status_file):
os.unlink(error_status_file)
class RecipeFailsafe(Failsafe, Recipe):
pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment