From c0096f6f2ea374fe161bbd32ae7d5a622f91b18b Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Fri, 22 Dec 2023 11:19:29 +0000 Subject: [PATCH] fix(upgrade-job): avoid infinite loop when no unhealthy vols have a target Signed-off-by: Niladri Halder --- k8s/upgrade/src/bin/upgrade-job/upgrade/utils.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/k8s/upgrade/src/bin/upgrade-job/upgrade/utils.rs b/k8s/upgrade/src/bin/upgrade-job/upgrade/utils.rs index 1fddf112c..1e283da8c 100644 --- a/k8s/upgrade/src/bin/upgrade-job/upgrade/utils.rs +++ b/k8s/upgrade/src/bin/upgrade-job/upgrade/utils.rs @@ -33,14 +33,13 @@ pub(crate) async fn rebuild_result( break; } + let mut volume_over_nodes = HashSet::new(); for volume in unhealthy_volumes.iter() { - let target = if let Some(target) = volume.state.target.as_ref() { - target - } else { - continue; + let target = match volume.state.target.as_ref() { + Some(t) => t, + None => continue, }; - let mut volume_over_nodes = HashSet::new(); volume_over_nodes.insert(target.node.as_str()); for (_, topology) in volume.state.replica_topology.iter() { @@ -74,6 +73,9 @@ pub(crate) async fn rebuild_result( } } } + if volume_over_nodes.is_empty() { + break; + } } Ok(RebuildResult { rebuilding: false,