From f3c1965896d1a5ba24c225631d73b4d3f5a440f4 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Sun, 18 Jun 2017 20:43:46 +0200 Subject: [PATCH 1/2] Fix disabling of oplog tailer --- mongodb_consistent_backup/Main.py | 2 +- mongodb_consistent_backup/Oplog/Tailer/Tailer.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mongodb_consistent_backup/Main.py b/mongodb_consistent_backup/Main.py index 66e9fa56..a36424b1 100644 --- a/mongodb_consistent_backup/Main.py +++ b/mongodb_consistent_backup/Main.py @@ -414,7 +414,7 @@ def run(self): self.db.close() # resolve/merge tailed oplog into mongodump oplog.bson to a consistent point for all shards - if self.backup.task.lower() == "mongodump" and self.oplogtailer: + if self.backup.task.lower() == "mongodump" and self.oplogtailer.enabled(): self.resolver = Resolver( self.manager, self.config, diff --git a/mongodb_consistent_backup/Oplog/Tailer/Tailer.py b/mongodb_consistent_backup/Oplog/Tailer/Tailer.py index 18164b26..681aed48 100644 --- a/mongodb_consistent_backup/Oplog/Tailer/Tailer.py +++ b/mongodb_consistent_backup/Oplog/Tailer/Tailer.py @@ -30,7 +30,9 @@ def __init__(self, manager, config, timer, base_dir, backup_dir, replsets, backu self._summary = {} def enabled(self): - if self._enabled.lower().strip() != 'false': + if isinstance(self._enabled, bool): + return self._enabled + elif isinstance(self._enabled, str) and self._enabled.strip().lower() != 'false': return True return False From 93f8938c254b7fb504d3d53a99b63ddb088a4a21 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Mon, 19 Jun 2017 16:10:19 +0200 Subject: [PATCH 2/2] Handle mongodump's "Failed: ..." messages as a proper error --- .../Backup/Mongodump/MongodumpThread.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py b/mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py index e3eb7f35..184cace5 100644 --- a/mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py +++ b/mongodb_consistent_backup/Backup/Mongodump/MongodumpThread.py @@ -32,6 +32,7 @@ def __init__(self, state, uri, timer, config, base_dir, version, threads=0, dump self.timer_name = "%s-%s" % (self.__class__.__name__, self.uri.replset) self.exit_code = 1 + self.error_message = None self._command = None self.do_stdin_passwd = False self.stdin_passwd_sent = False @@ -76,6 +77,17 @@ def handle_password_prompt(self): self._process.stdin.flush() self.stdin_passwd_sent = True + def is_failed_line(self, line): + if line and line.startswith("Failed: "): + return True + return False + + def handle_failure(self, line): + self.error_message = line.replace("Failed: ", "").capitalize() + logging.error("Mongodump error: %s" % self.error_message) + self.exit_code = 1 + self.close() + def wait(self): try: while self._process.stderr: @@ -88,6 +100,9 @@ def wait(self): continue elif self.is_password_prompt(read): self.handle_password_prompt() + elif self.is_failed_line(read): + self.handle_failure(read) + break else: logging.info(line) if self._process.poll() != None: