Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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::<f64>()? as u32;
// Millicores -> MHz
server_entry.cpu +=
value.parse::<f64>()? as u32 * server_spec::LINODE_CPU_PER_CORE / 1000;
}
Comment on lines +80 to 82
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Potential loss of precision when converting f64 to u32 before multiplication. Consider reordering operations

Metric::Memory => {
// MHz
server_entry.memory +=
value.parse::<f64>()? as u32 * server_spec::LINODE_CPU_PER_CORE / 1000;
// MiB
server_entry.memory += value.parse::<f64>()? as u32;
}
}
} else {
Expand Down
13 changes: 7 additions & 6 deletions packages/edge/services/pegboard/src/workflows/actor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
36 changes: 26 additions & 10 deletions packages/edge/services/pegboard/src/workflows/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading