refactor(#2352): quota enable/limit via daemon wire commands
This commit is contained in:
parent
9a39a54820
commit
53d4f5ca32
3 changed files with 49 additions and 13 deletions
|
|
@ -199,6 +199,8 @@ async fn dispatch(req: &HostRequest, coord: Arc<Coordinator>) -> HostResponse {
|
|||
HostRequest::SetAgentGithubToken { agent, token } => {
|
||||
handle_set_agent_github_token(agent, token).await?
|
||||
}
|
||||
HostRequest::QuotaEnable => handle_quota_enable().await?,
|
||||
HostRequest::QuotaLimit { name, limit } => handle_quota_limit(name, *limit).await?,
|
||||
})
|
||||
}
|
||||
.await;
|
||||
|
|
@ -408,6 +410,25 @@ async fn handle_set_agent_github_token(agent: &str, token: &str) -> Result<HostR
|
|||
)]))
|
||||
}
|
||||
|
||||
async fn handle_quota_enable() -> Result<HostResponse> {
|
||||
crate::priv_client::ensure_btrfs_quota()
|
||||
.await
|
||||
.context("enable btrfs qgroup accounting")?;
|
||||
Ok(HostResponse::messages(vec![
|
||||
"btrfs qgroup accounting enabled on the agent-state filesystem.".to_owned(),
|
||||
"(usage may read 0 until btrfs finishes its background rescan)".to_owned(),
|
||||
]))
|
||||
}
|
||||
|
||||
async fn handle_quota_limit(name: &str, limit: Option<u64>) -> Result<HostResponse> {
|
||||
crate::priv_client::set_subvolume_quota(name, limit)
|
||||
.await
|
||||
.with_context(|| format!("set quota for {name}"))?;
|
||||
// Bare success: the client prints the human-readable confirmation from
|
||||
// the value it sent (it holds the `human_bytes` formatter).
|
||||
Ok(HostResponse::success())
|
||||
}
|
||||
|
||||
async fn handle_matrix_sync_admin() -> Result<HostResponse> {
|
||||
require_matrix_present().await?;
|
||||
let register_token =
|
||||
|
|
|
|||
Loading…
Reference in a new issue