Skip to content

Commit

Permalink
fix(core-manager): add logging info (#2109)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurinderu committed Feb 23, 2024
1 parent 3d68c85 commit 06f253b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
13 changes: 8 additions & 5 deletions crates/core-manager/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cpu_utils::CPUTopologyError;
use ccp_shared::types::CUID;
use cpu_utils::{CPUTopologyError, PhysicalCoreId};
use std::str::Utf8Error;
use thiserror::Error;

Expand Down Expand Up @@ -59,8 +60,10 @@ pub enum PersistError {

#[derive(Debug, Error)]
pub enum AcquireError {
#[error("Couldn't assign core: no free cores left")]
NotFoundAvailableCores,
#[error("Unexpected state")]
UnexpectedState,
#[error(
"Couldn't assign core: no free cores left. Current assignment: {current_assignment:?}"
)]
NotFoundAvailableCores {
current_assignment: Vec<(PhysicalCoreId, CUID)>,
},
}
9 changes: 5 additions & 4 deletions crates/core-manager/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,11 @@ impl CoreManagerFunctions for PersistentCoreManager {
let physical_core_id = lock.unit_id_mapping.get_by_right(&unit_id).cloned();
let physical_core_id = match physical_core_id {
None => {
let core_id = lock
.available_cores
.pop_last()
.ok_or(AcquireError::NotFoundAvailableCores)?;
let core_id = lock.available_cores.pop_last().ok_or({
let current_assignment: Vec<(PhysicalCoreId, CUID)> =
lock.unit_id_mapping.iter().map(|(k, v)| (*k, *v)).collect();
AcquireError::NotFoundAvailableCores { current_assignment }
})?;
lock.unit_id_mapping.insert(core_id, unit_id);
lock.work_type_mapping
.insert(unit_id, worker_unit_type.clone());
Expand Down

0 comments on commit 06f253b

Please sign in to comment.