Skip to content

Add strict layout loading under a chosen name and a create overload for external rootfs - #1024

Open
realrajaryan wants to merge 1 commit into
apple:mainfrom
realrajaryan:strict-layout-load
Open

realrajaryan wants to merge 1 commit into
apple:mainfrom
realrajaryan:strict-layout-load

Conversation

@realrajaryan

Copy link
Copy Markdown
Member

Add ImageStore.load(from:as:platform:) so callers can load an untrusted OCI layout under a name they pick. It ignores the layout's names and takes every blob from the layout, so a layout can't replace another image or use another image's layers from the store.

Make imports fetch a blob from the source when a garbage collection removes it from the content store mid-import, instead of failing.

Add ContainerManager.create(_:image:rootfs:writableLayerSizeInBytes:) so callers with a rootfs outside the container's directory, like an NBD export, get a writable layer without building it themselves.

Comment on lines +212 to +219
} catch {
// A garbage collection of the content store can delete the blob after the lookup.
// Then fetch it from the source like any blob the store does not have.
guard !FileManager.default.fileExists(atPath: found.path.path) else {
throw error
}
try? FileManager.default.removeItem(at: destination)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? Should we keep the old behavior and throw? Does this mess up the progress counter?

throw ContainerizationError(.invalidArgument, message: "OCI layout at \(directory.path) holds \(manifests.count) images, not 1")
}
return try await self.load(
[(root, reference)], from: client, matcher: createPlatformMatcher(for: platform), reusesStoredContent: false, progress: progress

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add resuseStoreContent as a function param to this new method?

@adityaramani adityaramani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a couple Q's

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants