Skip to content

Commit

Permalink
Add a status.json purge on daemon init, before running the boot action
Browse files Browse the repository at this point in the history
This is a safety net, in case the boot action fails before purging those
files.
  • Loading branch information
cvaroqui committed May 20, 2020
1 parent 7361f6b commit 0498a31
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/osvcd_mon.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,12 +721,22 @@ def service_thaw(self, path, slaves=False):
on_error_kwargs={"status": "idle"},
)

def services_purge_status(self, paths=None):
paths = paths or list_services()
for path in paths:
fpath = svc_pathvar(path, "status.json")
try:
os.unlink(fpath)
except Exception as exc:
pass

def services_init_status(self):
svcs = list_services()
if not svcs:
self.log.info("no objects to get an initial status from")
self.services_init_status_callback()
return
self.services_purge_status(paths=svcs)
proc = self.service_command(",".join(svcs), ["status", "--parallel", "--refresh"], local=False)
self.push_proc(
proc=proc,
Expand All @@ -735,7 +745,9 @@ def services_init_status(self):
)

def services_init_boot(self):
proc = self.service_command(",".join(list_services(kinds=["vol", "svc"])), ["boot", "--parallel"])
paths = list_services(kinds=["vol", "svc"])
self.services_purge_status(paths=paths)
proc = self.service_command(",".join(paths), ["boot", "--parallel"])
self.push_proc(
proc=proc,
on_success="services_init_status_callback",
Expand Down

0 comments on commit 0498a31

Please sign in to comment.