gpu: Update the logging around CDI

Removed a rogue printf and updated the logging to say
that we're waiting for CDI spec(s) to be generated rather
than saying there is an error, it's not we have a timeout
after that it is an error.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
Zvonko Kaiser 2025-02-13 19:40:48 +00:00
parent 2499d013bd
commit 908aacfa78

View File

@ -271,7 +271,7 @@ pub async fn handle_cdi_devices(
let options: Vec<CdiOption> = vec![with_auto_refresh(false), with_spec_dirs(&[spec_dir])];
let cache: Arc<std::sync::Mutex<cdi::cache::Cache>> = new_cache(options);
for _ in 0..=cdi_timeout.as_secs() {
for i in 0..=cdi_timeout.as_secs() {
let inject_result = {
// Lock cache within this scope, std::sync::Mutex has no Send
// and await will not work with time::sleep
@ -294,8 +294,13 @@ pub async fn handle_cdi_devices(
return Ok(());
}
Err(e) => {
info!(logger, "error injecting devices: {:?}", e);
println!("error injecting devices: {:?}", e);
info!(
logger,
"waiting for CDI spec(s) to be generated ({} of {} max tries) {:?}",
i,
cdi_timeout.as_secs(),
e
);
}
}
time::sleep(Duration::from_secs(1)).await;
@ -1245,8 +1250,13 @@ mod tests {
let cdi_timeout = Duration::from_secs(0);
let res =
handle_cdi_devices(&logger, &mut spec, temp_dir.path().to_str().unwrap(), cdi_timeout).await;
let res = handle_cdi_devices(
&logger,
&mut spec,
temp_dir.path().to_str().unwrap(),
cdi_timeout,
)
.await;
println!("modfied spec {:?}", spec);
assert!(res.is_ok(), "{}", res.err().unwrap());