Skip to content

Commit

Permalink
Save the resource consuming part of on_nodes_info_change() when data …
Browse files Browse the repository at this point in the history
…unchanged
  • Loading branch information
cvaroqui committed Oct 26, 2020
1 parent 680a96a commit a4b1f61
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions opensvc/daemon/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ def dump_nodes_info(self):
continue
new_data[node] = ndata
if new_data == data:
return
return False
try:
tmpf = tempfile.NamedTemporaryFile(delete=False, dir=Env.paths.pathtmp)
fpath = tmpf.name
Expand All @@ -1433,6 +1433,7 @@ def dump_nodes_info(self):
except Exception as exc:
self.alert("warning", "failed to refresh %s: %s", Env.paths.nodes_info, exc)
self.log.info("%s updated", Env.paths.nodes_info)
return True

def on_nodes_info_change(self):
"""
Expand All @@ -1448,7 +1449,9 @@ def on_nodes_info_change(self):
flex_target={#nodes}
"""
NODE.unset_lazy("nodes_info")
self.dump_nodes_info()
changed = self.dump_nodes_info()
if not changed:
return
for path in [p for p in SERVICES]:
try:
svc = SERVICES[path]
Expand Down

0 comments on commit a4b1f61

Please sign in to comment.