(
socket_path: &Path,
child: &mut tokio::process::Child,
)
| 527 | |
| 528 | #[cfg(unix)] |
| 529 | async fn wait_for_compute_driver( |
| 530 | socket_path: &Path, |
| 531 | child: &mut tokio::process::Child, |
| 532 | ) -> Result<Channel> { |
| 533 | let mut last_error: Option<String> = None; |
| 534 | for _ in 0..100 { |
| 535 | let try_wait_result = child.try_wait().map_err(|e| { |
| 536 | Error::execution(format!("failed to poll vm compute driver process: {e}")) |
| 537 | })?; |
| 538 | if let Some(status) = try_wait_result { |
| 539 | return Err(Error::execution(format!( |
| 540 | "vm compute driver exited before becoming ready with status {status}" |
| 541 | ))); |
| 542 | } |
| 543 | |
| 544 | match connect_compute_driver(socket_path).await { |
| 545 | Ok(channel) => { |
| 546 | let mut client = ComputeDriverClient::new(channel.clone()); |
| 547 | match client |
| 548 | .get_capabilities(tonic::Request::new(GetCapabilitiesRequest {})) |
| 549 | .await |
| 550 | { |
| 551 | Ok(_) => return Ok(channel), |
| 552 | Err(status) => last_error = Some(status.to_string()), |
| 553 | } |
| 554 | } |
| 555 | Err(err) => last_error = Some(err.to_string()), |
| 556 | } |
| 557 | |
| 558 | tokio::time::sleep(Duration::from_millis(100)).await; |
| 559 | } |
| 560 | |
| 561 | Err(Error::execution(format!( |
| 562 | "timed out waiting for vm compute driver socket '{}': {}", |
| 563 | socket_path.display(), |
| 564 | last_error.unwrap_or_else(|| "unknown error".to_string()) |
| 565 | ))) |
| 566 | } |
| 567 | |
| 568 | #[cfg(unix)] |
| 569 | async fn connect_compute_driver(socket_path: &Path) -> Result<Channel> { |
no test coverage detected