(
&self,
sandbox_id: &str,
client: &OciClient,
reference: &Reference,
auth: &RegistryAuth,
image_ref: &str,
staging_dir: &Path,
rootfs:
| 3494 | impl VmDriver { |
| 3495 | #[allow(clippy::too_many_arguments)] |
| 3496 | async fn pull_registry_image_rootfs( |
| 3497 | &self, |
| 3498 | sandbox_id: &str, |
| 3499 | client: &OciClient, |
| 3500 | reference: &Reference, |
| 3501 | auth: &RegistryAuth, |
| 3502 | image_ref: &str, |
| 3503 | staging_dir: &Path, |
| 3504 | rootfs: &Path, |
| 3505 | ) -> Result<(), Status> { |
| 3506 | client |
| 3507 | .auth(reference, auth, RegistryOperation::Pull) |
| 3508 | .await |
| 3509 | .map_err(|err| { |
| 3510 | Status::failed_precondition(format!( |
| 3511 | "failed to authenticate registry access for vm sandbox image '{image_ref}': {err}" |
| 3512 | )) |
| 3513 | })?; |
| 3514 | let (manifest, _) = client |
| 3515 | .pull_image_manifest(reference, auth) |
| 3516 | .await |
| 3517 | .map_err(|err| { |
| 3518 | Status::failed_precondition(format!( |
| 3519 | "failed to pull vm sandbox image manifest '{image_ref}': {err}" |
| 3520 | )) |
| 3521 | })?; |
| 3522 | |
| 3523 | tokio::fs::create_dir_all(rootfs) |
| 3524 | .await |
| 3525 | .map_err(|err| Status::internal(format!("create rootfs dir failed: {err}")))?; |
| 3526 | tokio::fs::create_dir_all(staging_dir.join("layers")) |
| 3527 | .await |
| 3528 | .map_err(|err| Status::internal(format!("create layer staging dir failed: {err}")))?; |
| 3529 | |
| 3530 | let total_layers = manifest.layers.len(); |
| 3531 | let total_bytes: i64 = manifest.layers.iter().map(|layer| layer.size.max(0)).sum(); |
| 3532 | let mut layers = futures::stream::iter(manifest.layers.iter().cloned().enumerate()) |
| 3533 | .map(|(index, layer)| async move { |
| 3534 | self.publish_registry_layer_progress( |
| 3535 | sandbox_id, |
| 3536 | image_ref, |
| 3537 | &layer, |
| 3538 | index, |
| 3539 | total_layers, |
| 3540 | total_bytes, |
| 3541 | ); |
| 3542 | download_registry_layer_blob( |
| 3543 | client, |
| 3544 | reference, |
| 3545 | image_ref, |
| 3546 | staging_dir, |
| 3547 | layer, |
| 3548 | index, |
| 3549 | ) |
| 3550 | .await |
| 3551 | }) |
| 3552 | .buffer_unordered(registry_layer_download_concurrency()) |
| 3553 | .try_collect::<Vec<_>>() |
no test coverage detected