Skip to content

Commit a907e13

Browse files
committed
examples: Add a thingy to fetch container to devnull
To aid in trying to reproduce the broken pipe errors we see sometimes in bootc. Signed-off-by: Colin Walters <[email protected]>
1 parent 918bfab commit a907e13

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

examples/client.rs

+19
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct GetBlobOpts {
2929
enum Opt {
3030
GetMetadata(GetMetadataOpts),
3131
GetBlob(GetBlobOpts),
32+
FetchContainerToDevNull(GetMetadataOpts),
3233
}
3334

3435
#[derive(serde::Serialize, Debug)]
@@ -69,10 +70,28 @@ async fn get_blob(o: GetBlobOpts) -> Result<()> {
6970
Ok(())
7071
}
7172

73+
async fn fetch_container_to_devnull(o: GetMetadataOpts) -> Result<()> {
74+
let proxy = containers_image_proxy::ImageProxy::new().await?;
75+
let img = &proxy.open_image(&o.reference).await?;
76+
let manifest = proxy.fetch_manifest(img).await?.1;
77+
for layer in manifest.layers() {
78+
let (mut blob, driver) = proxy.get_descriptor(img, layer).await?;
79+
let mut devnull = tokio::io::sink();
80+
let copier = tokio::io::copy(&mut blob, &mut devnull);
81+
let (copier, driver) = tokio::join!(copier, driver);
82+
dbg!(&copier);
83+
dbg!(&driver);
84+
copier?;
85+
driver?;
86+
}
87+
Ok(())
88+
}
89+
7290
async fn run() -> Result<()> {
7391
match Opt::parse() {
7492
Opt::GetMetadata(o) => get_metadata(o).await,
7593
Opt::GetBlob(o) => get_blob(o).await,
94+
Opt::FetchContainerToDevNull(o) => fetch_container_to_devnull(o).await,
7695
}
7796
}
7897

0 commit comments

Comments
 (0)