aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-03-27 13:55:49 +0100
committerAlex Auvolat <alex@adnab.me>2024-03-27 13:55:49 +0100
commit25c196f34d958f4f61d50c89a1c5d40b96d7cd24 (patch)
tree97755273de588a04ed8d86cbe5e86d55f6af3759
parent4eba32f29fceea5ab19e44900f8d3a6864989d55 (diff)
downloadgarage-25c196f34d958f4f61d50c89a1c5d40b96d7cd24.tar.gz
garage-25c196f34d958f4f61d50c89a1c5d40b96d7cd24.zip
[next-0.10] admin api: fix logic in get cluster status
-rw-r--r--src/api/admin/cluster.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/api/admin/cluster.rs b/src/api/admin/cluster.rs
index e5877fcd..357ac600 100644
--- a/src/api/admin/cluster.rs
+++ b/src/api/admin/cluster.rs
@@ -70,9 +70,7 @@ pub async fn handle_get_cluster_status(garage: &Arc<Garage>) -> Result<Response<
);
}
Some(n) => {
- if n.role.is_none() {
- n.role = Some(role);
- }
+ n.role = Some(role);
}
}
}
@@ -81,15 +79,21 @@ pub async fn handle_get_cluster_status(garage: &Arc<Garage>) -> Result<Response<
for ver in layout.versions().iter().rev().skip(1) {
for (id, _, role) in ver.roles.items().iter() {
if let layout::NodeRoleV(Some(r)) = role {
- if !nodes.contains_key(id) && r.capacity.is_some() {
- nodes.insert(
- *id,
- NodeResp {
- id: hex::encode(id),
- draining: true,
- ..Default::default()
- },
- );
+ if r.capacity.is_some() {
+ if let Some(n) = nodes.get_mut(id) {
+ if n.role.is_none() {
+ n.draining = true;
+ }
+ } else {
+ nodes.insert(
+ *id,
+ NodeResp {
+ id: hex::encode(id),
+ draining: true,
+ ..Default::default()
+ },
+ );
+ }
}
}
}