Skip to content

Commit

Permalink
Only print warning about unknown allocation if a worker connects
Browse files Browse the repository at this point in the history
It isn't helpful to repeat it when it disconnects.
  • Loading branch information
Kobzol committed Nov 22, 2023
1 parent ced2f5d commit 38886a6
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 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,8 +491,16 @@ 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));
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::debug!("Worker {worker_id} connected to allocation {allocation_id}");

let allocation = get_or_return!(queue.get_allocation_mut(&allocation_id));
Expand Down

0 comments on commit 38886a6

Please sign in to comment.