summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2015-07-05 12:57:39 +0530
committerRajesh Joseph <rjoseph@redhat.com>2015-07-08 02:39:31 -0700
commita2e041458cbdf7b758e1af5d1e0c897f34bbc7c0 (patch)
treebdebad36a306f614366d209c858d8409371a8ea5 /extras
parent3f9dae11173475d759adb16dd64bea9cef0bf1c4 (diff)
snapshot/scheduler: Use /var/run/gluster/shared_storage/snaps/tmp_file for writing data into tmp file and then making an atomic rename to the required filename
The reason for using this location is that it adheres to the selinux policies. Also moving the update of the current_scheduler file, under the lock so as to avoid multiple writes Change-Id: I61e62b5daf6f1bce2319f64f7b1dfb8b93726077 BUG: 1239270 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/11536 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'extras')
-rwxr-xr-xextras/snap_scheduler/snap_scheduler.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py
index 09015c52f79..ce808cf16ba 100755
--- a/extras/snap_scheduler/snap_scheduler.py
+++ b/extras/snap_scheduler/snap_scheduler.py
@@ -423,7 +423,7 @@ def edit_schedules(jobname, schedule, volname):
def initialise_scheduler():
try:
- with open("/tmp/crontab", "w+", 0644) as f:
+ with open(TMP_FILE, "w+", 0644) as f:
updater = ("* * * * * root PATH=$PATH:/usr/local/sbin:"
"/usr/sbin gcron.py --update\n")
f.write("%s\n" % updater)
@@ -431,11 +431,11 @@ def initialise_scheduler():
os.fsync(f.fileno())
f.close()
except IOError as (errno, strerror):
- log.error("Failed to open /tmp/crontab. Error: %s.", strerror)
+ log.error("Failed to open %s. Error: %s.", TMP_FILE, strerror)
ret = INIT_FAILED
return ret
- shutil.move("/tmp/crontab", GCRON_UPDATE_TASK)
+ shutil.move(TMP_FILE, GCRON_UPDATE_TASK)
if not os.path.lexists(GCRON_TASKS):
try:
@@ -491,6 +491,9 @@ def syntax_checker(args):
def perform_operation(args):
+ if not os.path.exists(CURRENT_SCHEDULER):
+ update_current_scheduler("none")
+
# Initialise snapshot scheduler on local node
if args.action == "init":
ret = initialise_scheduler()
@@ -651,9 +654,6 @@ def main(argv):
% (LOCK_FILE_DIR, strerror))
return INTERNAL_ERROR
- if not os.path.exists(CURRENT_SCHEDULER):
- update_current_scheduler("none")
-
try:
f = os.open(LOCK_FILE, os.O_CREAT | os.O_RDWR | os.O_NONBLOCK, 0644)
try: