Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify logging in autoallocator #641

Merged
merged 2 commits into from
Nov 30, 2023
Merged
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
33 changes: 19 additions & 14 deletions crates/hyperqueue/src/server/autoalloc/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,19 +406,16 @@ async fn process_queue(

fn get_data_from_worker<'a>(
state: &'a mut AutoAllocState,
id: WorkerId,
manager_info: &ManagerInfo,
) -> Option<(&'a mut AllocationQueue, QueueId, AllocationId)> {
let allocation_id = &manager_info.allocation_id;
match state.get_queue_id_by_allocation(allocation_id) {
Some(queue_id) => state
.get_queue_mut(queue_id)
.map(|queue| (queue, queue_id, allocation_id.clone())),
None => {
log::warn!("Worker {id} belongs to an unknown allocation {allocation_id}");
None
}
}
state
.get_queue_id_by_allocation(allocation_id)
.and_then(|queue_id| {
state
.get_queue_mut(queue_id)
.map(|queue| (queue, queue_id, allocation_id.clone()))
})
}

/// Synchronize the state of allocations with the external job manager.
Expand Down Expand Up @@ -494,9 +491,17 @@ fn on_worker_connected(
worker_id: WorkerId,
manager_info: &ManagerInfo,
) {
let (queue, queue_id, allocation_id) =
get_or_return!(get_data_from_worker(state, worker_id, manager_info));
log::debug!("Worker {worker_id} connected to allocation {allocation_id}");
let (queue, queue_id, allocation_id) = match get_data_from_worker(state, manager_info) {
Some(ret) => ret,
None => {
log::warn!(
"Worker {worker_id} belongs to an unknown allocation {}",
manager_info.allocation_id
);
return;
}
};
log::info!("Worker {worker_id} connected from allocation {allocation_id}");

let allocation = get_or_return!(queue.get_allocation_mut(&allocation_id));
match allocation.status {
Expand Down Expand Up @@ -539,7 +544,7 @@ fn on_worker_lost(
worker_details: LostWorkerDetails,
) {
let (queue, queue_id, allocation_id) =
get_or_return!(get_data_from_worker(state, worker_id, manager_info));
get_or_return!(get_data_from_worker(state, manager_info));
let allocation = get_or_return!(queue.get_allocation_mut(&allocation_id));

match allocation.status {
Expand Down
Loading