From d61df0711585247ee4bd3b70325c37f95a684dd7 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Tue, 3 Sep 2024 09:43:32 -0400 Subject: [PATCH] commands: add retries to ctdb-must-have-nodes command Signed-off-by: John Mulligan --- sambacc/commands/ctdb.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sambacc/commands/ctdb.py b/sambacc/commands/ctdb.py index 1646983..e66d398 100644 --- a/sambacc/commands/ctdb.py +++ b/sambacc/commands/ctdb.py @@ -412,14 +412,16 @@ def ctdb_must_have_node(ctx: Context) -> None: expected_pnn = np.node_number or 0 waiter = np.cluster_meta_waiter() + limiter = ErrorLimiter("ctdb_must_have_node", 10, pause_func=waiter.wait) while True: - if ctdb.pnn_in_cluster_meta( - cmeta=np.cluster_meta(), - pnn=expected_pnn, - ): - break - _logger.info("node not yet ready") - waiter.wait() + with limiter.catch(): + if ctdb.pnn_in_cluster_meta( + cmeta=np.cluster_meta(), + pnn=expected_pnn, + ): + break + _logger.info("node not yet ready") + waiter.wait() if ctx.cli.write_nodes: _logger.info("Writing nodes file") ctdb.cluster_meta_to_nodes(np.cluster_meta(), dest=np.persistent_path)