From b59017e344403bb9c2d5e6ea9289095c117f3ad6 Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Fri, 6 Jun 2025 20:44:21 +0000 Subject: [PATCH] fix(pegboard): fix allocation metrics --- .../ops/datacenter/topology_get/pegboard.rs | 10 +++--- .../pegboard/src/workflows/actor/mod.rs | 13 +++---- .../pegboard/src/workflows/client/mod.rs | 36 +++++++++++++------ 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/packages/core/services/cluster/src/ops/datacenter/topology_get/pegboard.rs b/packages/core/services/cluster/src/ops/datacenter/topology_get/pegboard.rs index 109e7e4fb8..d5bf1f3050 100644 --- a/packages/core/services/cluster/src/ops/datacenter/topology_get/pegboard.rs +++ b/packages/core/services/cluster/src/ops/datacenter/topology_get/pegboard.rs @@ -76,13 +76,13 @@ pub async fn pegboard_client_usage_get(ctx: &OperationCtx, input: &Input) -> Glo if let Some((_, value)) = row.value { match row.labels.metric { Metric::Cpu => { - // MiB - server_entry.cpu += value.parse::()? as u32; + // Millicores -> MHz + server_entry.cpu += + value.parse::()? as u32 * server_spec::LINODE_CPU_PER_CORE / 1000; } Metric::Memory => { - // MHz - server_entry.memory += - value.parse::()? as u32 * server_spec::LINODE_CPU_PER_CORE / 1000; + // MiB + server_entry.memory += value.parse::()? as u32; } } } else { diff --git a/packages/edge/services/pegboard/src/workflows/actor/mod.rs b/packages/edge/services/pegboard/src/workflows/actor/mod.rs index 3600e5b942..f3b0e99ccd 100644 --- a/packages/edge/services/pegboard/src/workflows/actor/mod.rs +++ b/packages/edge/services/pegboard/src/workflows/actor/mod.rs @@ -152,12 +152,13 @@ pub async fn pegboard_actor(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResul return Ok(()); }; - ctx.v(2).msg(Allocated { - client_id: res.client_id, - }) - .tag("actor_id", input.actor_id) - .send() - .await?; + ctx.v(2) + .msg(Allocated { + client_id: res.client_id, + }) + .tag("actor_id", input.actor_id) + .send() + .await?; let state_res = ctx .loope( diff --git a/packages/edge/services/pegboard/src/workflows/client/mod.rs b/packages/edge/services/pegboard/src/workflows/client/mod.rs index 238c732d24..62f25b3f56 100644 --- a/packages/edge/services/pegboard/src/workflows/client/mod.rs +++ b/packages/edge/services/pegboard/src/workflows/client/mod.rs @@ -194,21 +194,37 @@ pub async fn pegboard_client(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResu Some(Main::Drain(sig)) => { state.drain_timeout_ts = Some(sig.drain_timeout_ts); - ctx.activity(SetDrainInput { - client_id, - flavor, - draining: true, - }) + ctx.join(( + activity(SetDrainInput { + client_id, + flavor, + draining: true, + }), + v(2).activity(UpdateMetricsInput { + client_id, + flavor, + draining: true, + clear: false, + }), + )) .await?; } Some(Main::Undrain(_)) => { state.drain_timeout_ts = None; - ctx.activity(SetDrainInput { - client_id, - flavor, - draining: false, - }) + ctx.join(( + activity(SetDrainInput { + client_id, + flavor, + draining: false, + }), + v(2).activity(UpdateMetricsInput { + client_id, + flavor, + draining: false, + clear: false, + }), + )) .await?; let actor_ids = ctx