aboutsummaryrefslogtreecommitdiff
path: root/src/api/admin
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-12-11 18:41:15 +0100
committerAlex Auvolat <alex@adnab.me>2022-12-11 18:41:15 +0100
commit2c2e65ad8b37128612ba47a777eacbae5e43f3ab (patch)
treea6e224afbb35e2baa88091731870ff575d118664 /src/api/admin
parentdefd7d9e6353e10b0b9d58b66aad4f04e7d50c41 (diff)
parentec12d6c8ddde0f1dc908e43fef0ecc88d1e5406b (diff)
downloadgarage-2c2e65ad8b37128612ba47a777eacbae5e43f3ab.tar.gz
garage-2c2e65ad8b37128612ba47a777eacbae5e43f3ab.zip
Merge commit 'ec12d6c' into next
Diffstat (limited to 'src/api/admin')
-rw-r--r--src/api/admin/cluster.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/api/admin/cluster.rs b/src/api/admin/cluster.rs
index 182a4f6f..540c6009 100644
--- a/src/api/admin/cluster.rs
+++ b/src/api/admin/cluster.rs
@@ -91,7 +91,7 @@ fn get_cluster_layout(garage: &Arc<Garage>) -> GetClusterLayoutResponse {
.map(|(k, _, v)| (hex::encode(k), v.0.clone()))
.collect(),
staged_role_changes: layout
- .staging
+ .staging_roles
.items()
.iter()
.filter(|(k, _, v)| layout.roles.get(k) != Some(v))
@@ -142,14 +142,14 @@ pub async fn handle_update_cluster_layout(
let mut layout = garage.system.get_cluster_layout();
let mut roles = layout.roles.clone();
- roles.merge(&layout.staging);
+ roles.merge(&layout.staging_roles);
for (node, role) in updates {
let node = hex::decode(node).ok_or_bad_request("Invalid node identifier")?;
let node = Uuid::try_from(&node).ok_or_bad_request("Invalid node identifier")?;
layout
- .staging
+ .staging_roles
.merge(&roles.update_mutator(node, NodeRoleV(role)));
}
@@ -167,12 +167,14 @@ pub async fn handle_apply_cluster_layout(
let param = parse_json_body::<ApplyRevertLayoutRequest>(req).await?;
let layout = garage.system.get_cluster_layout();
- let layout = layout.apply_staged_changes(Some(param.version))?;
+ let (layout, msg) = layout.apply_staged_changes(Some(param.version))?;
+
garage.system.update_cluster_layout(&layout).await?;
Ok(Response::builder()
- .status(StatusCode::NO_CONTENT)
- .body(Body::empty())?)
+ .status(StatusCode::OK)
+ .header(http::header::CONTENT_TYPE, "text/plain")
+ .body(Body::from(msg.join("\n")))?)
}
pub async fn handle_revert_cluster_layout(