Skip to content

atelet: prepare images through an image provider plugin - #4028

Draft
yuekui2 wants to merge 11 commits into
agent-substrate:mainfrom
yuekui2:ipp-upstream/5-plugin
Draft

yuekui2 wants to merge 11 commits into
agent-substrate:mainfrom
yuekui2:ipp-upstream/5-plugin

Conversation

@yuekui2

@yuekui2 yuekui2 commented Nov 20, 2026 •

Copy link
Copy Markdown

Part of #4023. Includes #4025 (CachedImage) and #4026 (mount the lowerdirs). The commits from Nov 19 are as first reviewed, the next commit has the review fixes for this stack, and the last commit follows the revised plugin API (ai-on-gke/image-provider-plugin#1). To see the final code, use Files changed. #4027 was closed. Its metrics commit is here, so each metric lands with the code that records it.

Blocked on ai-on-gke/image-provider-plugin v0.1.0, which needs the API (ai-on-gke/image-provider-plugin#1) and the client. go-modules and licenses fail until it is tagged. The module is vendored, so build and tests run. Once it is tagged, go mod tidy adds its go.sum entries.

Stacked with #4029: this PR takes image provider leases, and #4029 releases and reconciles them. The two land back to back. The ImageProviderPlugin gate stays off by default until then.

go.mod depends on github.com/ai-on-gke/image-provider-plugin.
atelet asks the plugin on --image-provider-socket (default /run/ate/image-provider/plugin.sock) to prepare each image that the cache does not hold, and pulls into the cache when the plugin declines or fails. CanProvide times out after 5s and PrepareImage after 1 minute. Only PrepareImage gets registry credentials, and only node-level ones. Each lease's auth key is the image's repository, so leases from one repository share credentials. atelet rejects a prepared image whose digest does not match a digest-pinned ref.
The overlay spec records the image ref and the provider lease, so atelet can release leases after a restart.
ate.imageprovider.requests counts plugin requests by outcome (success, declined, error, with error.type). A node without a plugin socket records nothing.
The atelet DaemonSet mounts the node's /run/ate/image-provider read-only for the socket.
docs/guides/image-provider.md describes the plugin, including version skew. There is no version RPC.
All of it is behind the ImageProviderPlugin preview gate, off by default.

Testing: go test -race ./cmd/atelet/... against the client mock. E2E coverage needs a plugin; see the umbrella issue.

I used an AI agent to port these commits from our fork, address review comments, and draft this description. I reviewed the code and commit messages.

Comment thread cmd/atelet/oci.go Outdated
Comment on lines +111 to +118
ok, err := s.provider.CanProvide(ctx, req)
if err != nil {
return nil, err
}
if !ok {
return nil, errProviderDeclined
}
res, err := s.provider.PrepareImage(ctx, req)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CanProvide and PrepareImage run on the caller's ctx with no deadline of their own, and the fallback EnsureImage reuses that same ctx. If the plugin hangs, the activation times out instead of falling back to the cache. Have you considered bounding the plugin calls, like providerReleaseTimeout does for release, so the cache pull still has budget?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. CanProvide and PrepareImage now have their own timeouts, 5 seconds and 1 minute, derived from the caller's ctx. When either expires, atelet releases any lease the plugin took and falls back to the image cache with the rest of the caller's budget. Covered by TestImageSourceEnsure.

Comment thread cmd/atelet/oci.go Outdated
// serve ref.
func (s imageSource) prepare(ctx context.Context, ref, leaseID string) (*imagecache.Image, error) {
if s.keychain != nil {
ctx = providerclient.WithKeychainContext(ctx, s.keychain)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since CanProvide gets the keychain too, the plugin receives registry creds for every image, even the ones it declines. Have you considered attaching the keychain only for PrepareImage?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. atelet attaches the keychain only for PrepareImage. No plugin used the credentials in CanProvide, so I also dropped auth from CanProvideRequest in the v1alpha1 API.

Comment thread cmd/atelet/oci.go Outdated
Comment on lines +147 to +151
digest, err := v1.NewHash(res.ImageDigest)
if err != nil {
return nil, fmt.Errorf("the image provider plugin returned image digest %q: %w", res.ImageDigest, err)
}
return &imagecache.Image{Digest: digest, Config: *res.Config, ProviderDirs: res.LayerDirs, LeaseID: leaseID}, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should streamedImage reject layer dirs outside /var/lib/ate, and a digest that doesn't match a pinned ref? That way a bad plugin result falls back to the cache here instead of failing the overlay mount in the worker.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The rootfs check already exists: the client rejects a rootfs outside the mount root, /var/lib/ate/image-provider. The LayerDirs field is gone since the API moved to one rootfs per image. I added the digest check: a digest that doesn't match the pinned ref fails prepare, the lease is released, and atelet falls back to the cache.

Comment thread cmd/atelet/oci.go
Comment on lines +250 to +262
defer func() {
if err == nil {
return
}
if img != nil && img.LeaseID != "" {
images.release(ctx, img.LeaseID, img.Digest.String())
}
for _, v := range imageVolumes {
if v.LeaseID != "" {
images.release(ctx, v.LeaseID, v.ImageDigest)
}
}
}()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this PR alone, what releases a lease on checkpoint/terminate, or when a sibling container or resolveImageUser fails after prepareOCIDirectory returns? As far as I can tell that only comes in #4029. Can #4028 and #4029 land together, or the gate stay unadvertised until then?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right, release and reconcile come in #4029. The two are stacked and will land back to back. The ImageProviderPlugin gate is off by default meanwhile, and I've noted the dependency in both descriptions.

Comment thread manifests/ate-install/atelet.yaml Outdated
Comment on lines +371 to +372
- name: image-provider
mountPath: /run/ate

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does atelet need write access to all of /run/ate? A readOnly mount of a dedicated image-provider subdir looks like enough to dial the socket.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. Plugins now listen on /run/ate/image-provider/plugin.sock, and atelet mounts only /run/ate/image-provider, read-only. It's a directory mount so that a restarted plugin's new socket file shows up.

Comment thread go.mod
cloud.google.com/go/compute/metadata v0.9.0
cloud.google.com/go/storage v1.62.1
github.com/Masterminds/squirrel v1.5.4
github.com/ai-on-gke/image-provider-plugin v0.1.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What's the skew policy between atelet and the plugin while the API is v1alpha1? A version check that declines on mismatch would keep the fallback safe across independent rollouts.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

atelet and the plugin roll out independently. Within v1alpha1, changes only add fields and enum values. A breaking change gets a new proto package, and a plugin on another package answers Unimplemented, so atelet falls back to the image cache. The service name works as the version check. I wrote this down in the guide and the library overview, and added a client test for the fallback.

CachedImage returns a digest-pinned image that is complete in the store
without contacting the registry, and nil otherwise. A caller can then
serve such images locally and send the rest elsewhere.
An image provider plugin will prepare some images' layers under a lease
that atelet must release on checkpoint and terminate, also after an
atelet restart. The overlay spec now records the image ref and the
plugin's lease ID, for the rootfs and for each image volume.
Image.LeaseID carries the lease from the image lookup.
The worker derived each lowerdir as <layer>/fs, so only Store layers
could be mounted. The overlay spec now records each image's lowerdirs,
and its Store layers when it came from the Store. The worker mounts
the lowerdirs as they are, and finalizes and repairs only the Store
layers. GC roots only Store layers.

Image.ProviderDirs holds lowerdirs that an image provider plugin
returns. ReadFile reads such lowerdirs directly and treats 0:0
character devices as whiteouts. It cannot see their opaque dirs, since
reading trusted.* xattrs needs CAP_SYS_ADMIN.

A spec without lowerdirs stays at version 1, so older workers still
read it. A spec with lowerdirs is version 2, which older workers
reject. atelet writes only Store images for now, so it still writes
version 1.
atelet will ask an image provider plugin to prepare image layers and fall
back to the image cache when the plugin declines or fails, and will
refresh the registry credentials of plugin leases. Add the
ate.imageprovider.requests counter and the ate.imageprovider.duration
histogram, labeled by provider and outcome, and the
ate.imageprovider.auth_refresh.failures counter, labeled by provider, to
the registry, ateattr, atelet's instruments and the observability guide.
atelet will talk to image provider plugins through the client in
github.com/ai-on-gke/image-provider-plugin. Require v0.1.0 and vendor
its API package.

RegistryAuth carries registry credentials, so protoredact_test lists the
imageprovider proto and pins its debug_redact fields.
A node can run an image provider plugin that prepares image layers
itself, for example by lazy loading them. atelet now asks the plugin
behind --image-provider-socket for each container and image volume
image, and pulls into the image cache when the plugin declines or fails.
Digest refs already in the cache skip the plugin.

atelet names each lease after the actor, the container and, for an image
volume, the volume. The overlay spec records the image ref, the lease ID
and the plugin's directories as lowerdirs, so a plugin image gets a
version 2 spec. A failed bundle prepare releases the leases it took. A
failed PrepareImage releases its lease without a digest, since the
plugin may have taken it. Each request records
ate.imageprovider.requests and ate.imageprovider.duration.
atelet looks for the node's image provider plugin at
/run/ate/image-provider.sock, the --image-provider-socket default.
Mount the node's /run/ate into atelet so it can reach the socket.
Document --image-provider-socket, the fallback to the image cache, how
atelet releases, reconciles and refreshes leases, and the suspend of
actors while the plugin drains. Link to the plugin repository for the
API.
The plugin was on whenever its socket existed. It is a preview feature,
so atelet now prepares images through it only when the
ImageProviderPlugin preview gate is on. With the gate off, atelet pulls
every image into the image cache and takes no new plugin leases. It
still releases, reconciles and refreshes the leases its actors hold, and
suspends them when the plugin drains.

ateworker needs no gate. Its version 2 overlay spec reader only runs for
specs that a gated atelet writes. The guide says to turn the gate on
only after every WorkerPool has rolled, so no older worker sees a
version 2 spec, and that ate-setup rolls the WorkerPools when the gate
changes.

It also says to turn the gate off before rolling atelet back, since an
older atelet cannot read version 2 specs.
@yuekui2
yuekui2 force-pushed the ipp-upstream/5-plugin branch from 9697ce8 to ad08f8a Compare November 25, 2026 00:39
@yuekui2

yuekui2 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Rebased onto main to resolve a go.mod conflict. No other changes. The review fixes are still in the last commit.

The image provider plugin API changed in review. ReleaseImage takes only
a lease ID, and PrepareImage takes an auth key that names the registry
credentials.

Pass the image's repository as the auth key, so leases from one
repository share credentials. Release leases by ID. Vendor the revised
API and client.

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