Skip to content

Commit 9b454d7

Browse files
committed
fix(pegboard): fix allocation metrics (#2568)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 72c45a0 commit 9b454d7

File tree

3 files changed

+38
-21
lines changed
  • packages
    • core/services/cluster/src/ops/datacenter/topology_get
    • edge/services/pegboard/src/workflows

3 files changed

+38
-21
lines changed

packages/core/services/cluster/src/ops/datacenter/topology_get/pegboard.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ pub async fn pegboard_client_usage_get(ctx: &OperationCtx, input: &Input) -> Glo
7676
if let Some((_, value)) = row.value {
7777
match row.labels.metric {
7878
Metric::Cpu => {
79-
// MiB
80-
server_entry.cpu += value.parse::<f64>()? as u32;
79+
// Millicores -> MHz
80+
server_entry.cpu +=
81+
value.parse::<f64>()? as u32 * server_spec::LINODE_CPU_PER_CORE / 1000;
8182
}
8283
Metric::Memory => {
83-
// MHz
84-
server_entry.memory +=
85-
value.parse::<f64>()? as u32 * server_spec::LINODE_CPU_PER_CORE / 1000;
84+
// MiB
85+
server_entry.memory += value.parse::<f64>()? as u32;
8686
}
8787
}
8888
} else {

packages/edge/services/pegboard/src/workflows/actor/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,13 @@ pub async fn pegboard_actor(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResul
152152
return Ok(());
153153
};
154154

155-
ctx.v(2).msg(Allocated {
156-
client_id: res.client_id,
157-
})
158-
.tag("actor_id", input.actor_id)
159-
.send()
160-
.await?;
155+
ctx.v(2)
156+
.msg(Allocated {
157+
client_id: res.client_id,
158+
})
159+
.tag("actor_id", input.actor_id)
160+
.send()
161+
.await?;
161162

162163
let state_res = ctx
163164
.loope(

packages/edge/services/pegboard/src/workflows/client/mod.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,37 @@ pub async fn pegboard_client(ctx: &mut WorkflowCtx, input: &Input) -> GlobalResu
194194
Some(Main::Drain(sig)) => {
195195
state.drain_timeout_ts = Some(sig.drain_timeout_ts);
196196

197-
ctx.activity(SetDrainInput {
198-
client_id,
199-
flavor,
200-
draining: true,
201-
})
197+
ctx.join((
198+
activity(SetDrainInput {
199+
client_id,
200+
flavor,
201+
draining: true,
202+
}),
203+
v(2).activity(UpdateMetricsInput {
204+
client_id,
205+
flavor,
206+
draining: true,
207+
clear: false,
208+
}),
209+
))
202210
.await?;
203211
}
204212
Some(Main::Undrain(_)) => {
205213
state.drain_timeout_ts = None;
206214

207-
ctx.activity(SetDrainInput {
208-
client_id,
209-
flavor,
210-
draining: false,
211-
})
215+
ctx.join((
216+
activity(SetDrainInput {
217+
client_id,
218+
flavor,
219+
draining: false,
220+
}),
221+
v(2).activity(UpdateMetricsInput {
222+
client_id,
223+
flavor,
224+
draining: false,
225+
clear: false,
226+
}),
227+
))
212228
.await?;
213229

214230
let actor_ids = ctx

0 commit comments

Comments
 (0)