Skip to content

Commit 52741d1

Browse files
author
Tim Vaillancourt
committed
fixing more decision logic
1 parent 43c2aca commit 52741d1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

MongoBackup/Replset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ def find_secondary(self):
116116
log_data['score'] = int(score)
117117
logging.info("%s: %s" % (log_msg, str(log_data)))
118118
if self.secondary is None or (self.secondary['count'] + 1) < quorum_count:
119+
secondary_count = self.secondary['count'] + 1 if self.secondary else 0
119120
logging.fatal("Not enough secondaries in replset %s to take backup! Num replset members: %i, required quorum: %i" % (
120121
rs_name,
121-
self.secondary['count'] + 1,
122+
secondary_count,
122123
quorum_count
123124
))
124125
raise Exception, "Not enough secondaries in replset %s to safely take backup!" % rs_name, None

MongoBackup/Sharding.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,10 @@ def get_configserver(self, force=False):
113113
except Exception:
114114
config_list = [config_string]
115115

116+
config_server = config_list[0]
116117
config_replset = False
117118
try:
118-
config_host, config_port = config_list[0].split(":")
119+
config_host, config_port = config_server.split(":")
119120
db = DB(config_host, config_port, self.user, self.password, self.authdb)
120121
rs = Replset(db, self.user, self.password, self.authdb)
121122
try:
@@ -126,7 +127,10 @@ def get_configserver(self, force=False):
126127
except Exception, e:
127128
raise e
128129

129-
self.config_server = {'host': config_list[0], 'is_replset': config_replset}
130+
if config_replset:
131+
config_server = rs.find_secondary()
132+
133+
self.config_server = {'host': config_server, 'is_replset': config_replset}
130134
else:
131135
logging.fatal("Unable to locate config servers for %s:%i!" % (self.host, self.port))
132136
raise Exception, "Unable to locate config servers for %s:%i!" % (self.host, self.port), None

0 commit comments

Comments
 (0)