Skip to content

Commit

Permalink
fix: check if image is present before pulling (#1302)
Browse files Browse the repository at this point in the history
Fixes #1007

Signed-off-by: Jeff MAURY <[email protected]>
  • Loading branch information
jeffmaury authored Jun 28, 2024
1 parent c560335 commit b4ff2e4
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions packages/backend/src/utils/inferenceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,26 @@ export async function getImageInfo(
callback: (event: PullEvent) => void,
): Promise<ImageInfo> {
let imageInfo: ImageInfo | undefined;
try {
// Pull image
await containerEngine.pullImage(connection, image, callback);
// Get image inspect
imageInfo = (
await containerEngine.listImages({
provider: connection,
} as ListImagesOptions)
).find(imageInfo => imageInfo.RepoTags?.some(tag => tag === image));
} catch (err: unknown) {
console.warn('Something went wrong while trying to get image inspect', err);
throw err;
// Get image inspect
imageInfo = (
await containerEngine.listImages({
provider: connection,
} as ListImagesOptions)
).find(imageInfo => imageInfo.RepoTags?.some(tag => tag === image));
if (!imageInfo) {
try {
// Pull image
await containerEngine.pullImage(connection, image, callback);
// Get image inspect
imageInfo = (
await containerEngine.listImages({
provider: connection,
} as ListImagesOptions)
).find(imageInfo => imageInfo.RepoTags?.some(tag => tag === image));
} catch (err: unknown) {
console.warn('Something went wrong while trying to get image inspect', err);
throw err;
}
}

if (imageInfo === undefined) throw new Error(`image ${image} not found.`);
Expand Down

0 comments on commit b4ff2e4

Please sign in to comment.