diff options
author | Alex Auvolat <alex@adnab.me> | 2023-12-07 11:50:00 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-12-07 11:56:14 +0100 |
commit | aa59059a910eb6e1e824b84413a66909d697ef8a (patch) | |
tree | 967e1ebbc2772b5d3edda68d28acc9f346a80ca8 /src/garage/cli/cmd.rs | |
parent | d90de365b3b30cb631b22fcd62c98bddb5a91549 (diff) | |
download | garage-aa59059a910eb6e1e824b84413a66909d697ef8a.tar.gz garage-aa59059a910eb6e1e824b84413a66909d697ef8a.zip |
layout cli: safer skip-dead-nodes command
Diffstat (limited to 'src/garage/cli/cmd.rs')
-rw-r--r-- | src/garage/cli/cmd.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/garage/cli/cmd.rs b/src/garage/cli/cmd.rs index c7f0ad2b..196c0cb3 100644 --- a/src/garage/cli/cmd.rs +++ b/src/garage/cli/cmd.rs @@ -49,13 +49,7 @@ pub async fn cli_command_dispatch( } pub async fn cmd_status(rpc_cli: &Endpoint<SystemRpc, ()>, rpc_host: NodeID) -> Result<(), Error> { - let status = match rpc_cli - .call(&rpc_host, SystemRpc::GetKnownNodes, PRIO_NORMAL) - .await?? - { - SystemRpc::ReturnKnownNodes(nodes) => nodes, - resp => return Err(Error::Message(format!("Invalid RPC response: {:?}", resp))), - }; + let status = fetch_status(rpc_cli, rpc_host).await?; let layout = fetch_layout(rpc_cli, rpc_host).await?; println!("==== HEALTHY NODES ===="); @@ -268,3 +262,18 @@ pub async fn cmd_admin( } Ok(()) } + +// ---- utility ---- + +pub async fn fetch_status( + rpc_cli: &Endpoint<SystemRpc, ()>, + rpc_host: NodeID, +) -> Result<Vec<KnownNodeInfo>, Error> { + match rpc_cli + .call(&rpc_host, SystemRpc::GetKnownNodes, PRIO_NORMAL) + .await?? + { + SystemRpc::ReturnKnownNodes(nodes) => Ok(nodes), + resp => Err(Error::Message(format!("Invalid RPC response: {:?}", resp))), + } +} |