|
|
7f4c2a |
From b6e94e46e4a44fe0bc73f60f2993c8151b91b33a Mon Sep 17 00:00:00 2001
|
|
|
7f4c2a |
From: Avra Sengupta <asengupt@redhat.com>
|
|
|
7f4c2a |
Date: Sun, 5 Jul 2015 12:57:39 +0530
|
|
|
7f4c2a |
Subject: [PATCH 215/234] 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
|
|
|
7f4c2a |
|
|
|
7f4c2a |
The reason for using this location is that it adheres to
|
|
|
7f4c2a |
the selinux policies.
|
|
|
7f4c2a |
|
|
|
7f4c2a |
Also moving the update of the current_scheduler file,
|
|
|
7f4c2a |
under the lock so as to avoid multiple writes
|
|
|
7f4c2a |
|
|
|
7f4c2a |
>Reviewed-on: http://review.gluster.org/11536
|
|
|
7f4c2a |
Change-Id: I61e62b5daf6f1bce2319f64f7b1dfb8b93726077
|
|
|
7f4c2a |
BUG: 1231647
|
|
|
7f4c2a |
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
|
|
|
7f4c2a |
Reviewed-on: https://code.engineering.redhat.com/gerrit/52559
|
|
|
7f4c2a |
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
7f4c2a |
Tested-by: Rajesh Joseph <rjoseph@redhat.com>
|
|
|
7f4c2a |
---
|
|
|
7f4c2a |
extras/snap_scheduler/snap_scheduler.py | 12 ++++++------
|
|
|
7f4c2a |
1 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
7f4c2a |
|
|
|
7f4c2a |
diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py
|
|
|
7f4c2a |
index 09015c5..ce808cf 100755
|
|
|
7f4c2a |
--- a/extras/snap_scheduler/snap_scheduler.py
|
|
|
7f4c2a |
+++ b/extras/snap_scheduler/snap_scheduler.py
|
|
|
7f4c2a |
@@ -423,7 +423,7 @@ def edit_schedules(jobname, schedule, volname):
|
|
|
7f4c2a |
|
|
|
7f4c2a |
def initialise_scheduler():
|
|
|
7f4c2a |
try:
|
|
|
7f4c2a |
- with open("/tmp/crontab", "w+", 0644) as f:
|
|
|
7f4c2a |
+ with open(TMP_FILE, "w+", 0644) as f:
|
|
|
7f4c2a |
updater = ("* * * * * root PATH=$PATH:/usr/local/sbin:"
|
|
|
7f4c2a |
"/usr/sbin gcron.py --update\n")
|
|
|
7f4c2a |
f.write("%s\n" % updater)
|
|
|
7f4c2a |
@@ -431,11 +431,11 @@ def initialise_scheduler():
|
|
|
7f4c2a |
os.fsync(f.fileno())
|
|
|
7f4c2a |
f.close()
|
|
|
7f4c2a |
except IOError as (errno, strerror):
|
|
|
7f4c2a |
- log.error("Failed to open /tmp/crontab. Error: %s.", strerror)
|
|
|
7f4c2a |
+ log.error("Failed to open %s. Error: %s.", TMP_FILE, strerror)
|
|
|
7f4c2a |
ret = INIT_FAILED
|
|
|
7f4c2a |
return ret
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- shutil.move("/tmp/crontab", GCRON_UPDATE_TASK)
|
|
|
7f4c2a |
+ shutil.move(TMP_FILE, GCRON_UPDATE_TASK)
|
|
|
7f4c2a |
|
|
|
7f4c2a |
if not os.path.lexists(GCRON_TASKS):
|
|
|
7f4c2a |
try:
|
|
|
7f4c2a |
@@ -491,6 +491,9 @@ def syntax_checker(args):
|
|
|
7f4c2a |
|
|
|
7f4c2a |
|
|
|
7f4c2a |
def perform_operation(args):
|
|
|
7f4c2a |
+ if not os.path.exists(CURRENT_SCHEDULER):
|
|
|
7f4c2a |
+ update_current_scheduler("none")
|
|
|
7f4c2a |
+
|
|
|
7f4c2a |
# Initialise snapshot scheduler on local node
|
|
|
7f4c2a |
if args.action == "init":
|
|
|
7f4c2a |
ret = initialise_scheduler()
|
|
|
7f4c2a |
@@ -651,9 +654,6 @@ def main(argv):
|
|
|
7f4c2a |
% (LOCK_FILE_DIR, strerror))
|
|
|
7f4c2a |
return INTERNAL_ERROR
|
|
|
7f4c2a |
|
|
|
7f4c2a |
- if not os.path.exists(CURRENT_SCHEDULER):
|
|
|
7f4c2a |
- update_current_scheduler("none")
|
|
|
7f4c2a |
-
|
|
|
7f4c2a |
try:
|
|
|
7f4c2a |
f = os.open(LOCK_FILE, os.O_CREAT | os.O_RDWR | os.O_NONBLOCK, 0644)
|
|
|
7f4c2a |
try:
|
|
|
7f4c2a |
--
|
|
|
7f4c2a |
1.7.1
|
|
|
7f4c2a |
|