Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions coman/src/cscs/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,12 +859,20 @@ pub async fn cscs_job_start(
None
};
let image_meta = if let Some(docker_image) = docker_image {
match docker_image.inspect().await {
Ok(meta) => Some(meta),
Err(e) => {
println!("couldn't get image information: {e:?}");
None
if let Some(system_info) = config.values.cscs.systems.get(current_system) {
let mut meta = None;
for arch in system_info.architecture.iter() {
if let Ok(img_meta) = docker_image.inspect(arch).await {
meta = Some(img_meta);
break;
}
}
if meta.is_none() {
println!("couldn't get image information, skipping checks");
}
meta
} else {
None
}
} else {
None
Expand Down
24 changes: 21 additions & 3 deletions coman/src/util/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use oci_client::{
Client, Reference,
client::{ClientConfig, ClientProtocol},
config::ConfigFile,
manifest::OciManifest,
manifest::{ImageIndexEntry, OciManifest},
secrets::RegistryAuth,
};
use oci_spec::image::Arch;
use oci_spec::image::{Arch, Os};

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash, strum::Display)]
pub enum OciPlatform {
Expand Down Expand Up @@ -79,9 +79,27 @@ impl DockerImageUrl {
)
}

pub async fn inspect(&self) -> Result<DockerImageMeta> {
pub async fn inspect(&self, arch: &str) -> Result<DockerImageMeta> {
let arch = match arch {
"arm64" => Arch::ARM64,
"amd64" => Arch::Amd64,
_ => {
return Err(eyre!("unsupported architecture {}", arch));
}
};
let client = Client::new(ClientConfig {
protocol: ClientProtocol::Https,
platform_resolver: Some(Box::new(move |manifests: &[ImageIndexEntry]| {
manifests
.iter()
.find(|entry| {
entry
.platform
.as_ref()
.is_some_and(|platform| platform.os == Os::Linux && platform.architecture == arch)
})
.map(|entry| entry.digest.clone())
})),
..Default::default()
});
let reference = self.to_string().parse()?;
Expand Down