You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# If the primary isn't in the target region by the timeout,
304
-
# log the cluster state every 5 seconds for the next 30
305
-
# minutes to help us understand confusing behavior with the
306
-
# cluster state. After logging the cluster state for 30
307
-
# minutes, raise an exception.
308
-
#
309
-
# See https://jira.mongodb.org/browse/PRODTRIAGE-1232 for
310
-
# more context.
311
-
ifnotok:
312
-
msg=f"Primary node ({mc.primary}) not in expected region '{region}' within {timeout}s (current region: '{member_region}'; all members: {members})"
313
-
LOGGER.error(msg)
303
+
# If the primary isn't in the target region by the
304
+
# timeout, log the cluster state every 5 seconds for the
305
+
# next 30 minutes to help us understand confusing
306
+
# behavior with the cluster state. After logging the
307
+
# cluster state for 30 minutes, check if the primary is
308
+
# in the target region again. If it still isn't in the
309
+
# target region, raise an exception.
310
+
#
311
+
# See https://jira.mongodb.org/browse/PRODTRIAGE-1232
312
+
# and https://jira.mongodb.org/browse/DRIVERS-2964 for
313
+
# more context.
314
+
#
315
+
# TODO: Figure out a more reliable way to check for
316
+
# cluster updates, or figure out why cluster state is
317
+
# unreliable, then remove this extra logging and extra
318
+
# region check.
319
+
ifnotok:
320
+
LOGGER.error(
321
+
f"Primary node ({mc.primary}) not in expected region '{region}' within {timeout}s. (current region: '{member_region}'; all members: {members})"
322
+
)
323
+
LOGGER.info("Logging cluster state for 30m after assertPrimaryRegion failure, then checking primary region again.")
324
+
self.log_cluster_status(timeout=1800)
314
325
315
-
LOGGER.info("Logging cluster state for 30m after assertPrimaryRegion failure.")
316
-
self.log_cluster_status(timeout=1800)
326
+
rsc=mc.admin.command("replSetGetConfig")
327
+
members=rsc["config"]["members"]
328
+
member=next(
329
+
m
330
+
forminmembers
331
+
ifm["horizons"]["PUBLIC"] =="%s:%s"%mc.primary
332
+
)
333
+
member_region=member["tags"]["region"]
317
334
318
-
raiseException(msg)
335
+
ifregion!=member_region:
336
+
raiseException(
337
+
f"Primary node ({mc.primary}) still not in expected region '{region}' after waiting an extra 30m. (current region: '{member_region}'; all members: {members})"
338
+
)
319
339
320
-
LOGGER.debug(
340
+
LOGGER.info(
321
341
f"Waited for {timer.elapsed}s for primary node to be in region '{region}'"
0 commit comments