Skip to content

Commit

Permalink
Set the remote svc config mtime on the fetched copy
Browse files Browse the repository at this point in the history
To avoid a ping-pong if the fetcher has its time in the future from the
sender point of view.
  • Loading branch information
cvaroqui committed Feb 8, 2018
1 parent c40242c commit ddea3f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/osvcd_lsnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,11 @@ def action_get_service_config(self, nodename, **kwargs):
fpath = os.path.join(rcEnv.paths.pathetc, svcname+".conf")
if not os.path.exists(fpath):
return {"error": "%s does not exist" % fpath, "status": 3}
mtime = os.path.getmtime(fpath)
with codecs.open(fpath, "r", "utf8") as filep:
buff = filep.read()
self.log.info("serve service %s config to %s", svcname, nodename)
return {"status": 0, "data": buff}
return {"status": 0, "data": buff, "mtime": mtime}

def action_clear(self, nodename, **kwargs):
svcname = kwargs.get("svcname")
Expand Down
3 changes: 3 additions & 0 deletions lib/osvcd_mon.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ def fetch_service_config(self, svcname, nodename):
if results["errors"] == 0:
dst = os.path.join(rcEnv.paths.pathetc, svcname+".conf")
shutil.copy(filep.name, dst)
mtime = resp.get("mtime")
if mtime:
os.utime(dst, (mtime, mtime))
else:
self.log.error("the service %s config fetched from node %s is "
"not valid", svcname, nodename)
Expand Down

0 comments on commit ddea3f2

Please sign in to comment.