Blob Blame History Raw
From 44b0118984991c73e6552c267a35c4f0e2d4ea88 Mon Sep 17 00:00:00 2001
From: Avra Sengupta <asengupt@redhat.com>
Date: Thu, 4 Jun 2015 17:17:13 +0530
Subject: [PATCH 44/57] snapshot/scheduler: Handle OSError in os. callbacks

        Backport of http://review.gluster.org/#/c/11087/

Handle OSError and not IOError in os. callbacks.

Change-Id: I2b5bfb629bacbd2d2e410d96034b4e2c11c4931e
BUG: 1224249
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
(cherry picked from commit d835219a30327ede60e4ef28210914ab30bd0712)
Reviewed-on: https://code.engineering.redhat.com/gerrit/50512
Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Tested-by: Rajesh Joseph <rjoseph@redhat.com>
---
 extras/snap_scheduler/snap_scheduler.py |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py
index 1c5f938..b692980 100755
--- a/extras/snap_scheduler/snap_scheduler.py
+++ b/extras/snap_scheduler/snap_scheduler.py
@@ -129,7 +129,7 @@ def enable_scheduler():
                     f = os.open(GCRON_ENABLED, os.O_CREAT | os.O_NONBLOCK,
                                 0644)
                     os.close(f)
-                except IOError as (errno, strerror):
+                except OSError as (errno, strerror):
                     log.error("Failed to open %s. Error: %s.",
                               GCRON_ENABLED, strerror)
                     ret = INTERNAL_ERROR
@@ -139,7 +139,7 @@ def enable_scheduler():
                 log.info("Snapshot scheduling is enabled")
                 output("Snapshot scheduling is enabled")
                 ret = 0
-            except IOError as (errno, strerror):
+            except OSError as (errno, strerror):
                 print_str = "Failed to enable snapshot scheduling. Error: "+strerror
                 log.error(print_str)
                 output(print_str)
@@ -188,7 +188,7 @@ def disable_scheduler():
                 log.info("Snapshot scheduling is disabled")
                 output("Snapshot scheduling is disabled")
                 ret = 0
-            except IOError as (errno, strerror):
+            except OSError as (errno, strerror):
                 print_str = "Failed to disable snapshot scheduling. Error: "+strerror
                 log.error(print_str)
                 output(print_str)
@@ -343,7 +343,7 @@ def add_schedules(jobname, schedule, volname):
                 try:
                     f = os.open(job_lockfile, os.O_CREAT | os.O_NONBLOCK, 0644)
                     os.close(f)
-                except IOError as (errno, strerror):
+                except OSError as (errno, strerror):
                     log.error("Failed to open %s. Error: %s.",
                               job_lockfile, strerror)
                     ret = INTERNAL_ERROR
@@ -372,7 +372,7 @@ def delete_schedules(jobname):
                 job_lockfile = LOCK_FILE_DIR+jobname
                 try:
                     os.remove(job_lockfile)
-                except IOError as (errno, strerror):
+                except OSError as (errno, strerror):
                     log.error("Failed to open %s. Error: %s.",
                               job_lockfile, strerror)
                     ret = INTERNAL_ERROR
@@ -630,7 +630,7 @@ def main():
     if not os.path.exists(SHARED_STORAGE_DIR+"/snaps/"):
         try:
             os.makedirs(SHARED_STORAGE_DIR+"/snaps/")
-        except IOError as (errno, strerror):
+        except OSError as (errno, strerror):
             if errno != EEXIST:
                 log.error("Failed to create %s : %s", SHARED_STORAGE_DIR+"/snaps/", strerror)
                 output("Failed to create %s. Error: %s"
@@ -644,7 +644,7 @@ def main():
     if not os.path.exists(LOCK_FILE_DIR):
         try:
             os.makedirs(LOCK_FILE_DIR)
-        except IOError as (errno, strerror):
+        except OSError as (errno, strerror):
             if errno != EEXIST:
                 log.error("Failed to create %s : %s", LOCK_FILE_DIR, strerror)
                 output("Failed to create %s. Error: %s"
@@ -666,7 +666,7 @@ def main():
                    "Please try again after some time.")
             return ANOTHER_TRANSACTION_IN_PROGRESS
         os.close(f)
-    except IOError as (errno, strerror):
+    except OSError as (errno, strerror):
         log.error("Failed to open %s : %s", LOCK_FILE, strerror)
         output("Failed to open %s. Error: %s" % (LOCK_FILE, strerror))
         return INTERNAL_ERROR
-- 
1.7.1