Repository navigation
Conversation
| s.providerAuth.setUnsupported() | ||
| return | ||
| case errors.Is(err, providerclient.ErrLeaseNotHeld): | ||
| s.providerAuth.set(l.LeaseID, imageprovider.AuthRefresh_AUTH_REFRESH_NOT_NEEDED) |
There was a problem hiding this comment.
This runs without providerLeaseMu, and lease IDs are reused across runs. If a checkpoint/restore lands while RefreshAuth is in flight, this NOT_NEEDED can overwrite the REQUIRED that prepare just set, and the lease stops being refreshed until the plugin restarts (the default branch can likewise re-add an entry after forget). Could set be conditional on the entry not having changed since the pass started?
There was a problem hiding this comment.
Fixed. The pass reads the entry and a reset counter before the RPC, and setIfUnchanged writes only if neither changed. A prepare, release or reconcile that ran meanwhile wins. Each pass also prunes entries for leases no longer on disk. Covered by TestRefreshProviderAuthKeepsNewerAnswers and TestRefreshProviderAuthForgetsReleasedLeases.
| slog.String("provider", s.imageProvider.Name()), slog.Any("err", err)) | ||
| s.providerAuth.setUnsupported() | ||
| return | ||
| case errors.Is(err, providerclient.ErrLeaseNotHeld): |
There was a problem hiding this comment.
What restores the lease if the plugin drops it without restarting? Reconcile only runs on a socket change, so this would stay NOT_NEEDED forever. Should this trigger a reconcile, or at least log?
There was a problem hiding this comment.
atelet now warns once and stops refreshing that lease until the next reconcile. I didn't add a reconcile here. A plugin restart changes the socket, and that reconcile restores the leases before refresh runs. So a running plugin that answers NotFound has a bug, and another reconcile from the refresh loop wouldn't fix it.
| } | ||
| last = info | ||
| if info != nil && time.Since(lastRefresh) >= providerAuthRefreshPeriod { | ||
| s.refreshProviderAuth(ctx, actorsDir) |
There was a problem hiding this comment.
With a wedged plugin this pass takes 10s per lease, serially, and it blocks the socket check above, so a plugin restart isn't reconciled until the pass finishes. Have you considered giving refresh its own ticker or goroutine under the same ctx, or giving the pass a total deadline that bails on the first timeout/Unavailable?
There was a problem hiding this comment.
Moved refresh into its own goroutine with its own 1-minute ticker. The monitor kicks it after each successful reconcile, so a slow RefreshAuth no longer delays socket checks or reconciles. Covered by TestRunProviderAuthRefreshKick.
| if s.imageKeychain != nil { | ||
| ctx = providerclient.WithKeychainContext(ctx, s.imageKeychain) | ||
| } | ||
| for _, l := range leases { |
There was a problem hiding this comment.
This is one RPC and one keychain lookup per lease each minute, which is fine for now. If many leases share an image, would grouping by ref or a small worker pool be worth it?
There was a problem hiding this comment.
Keeping per-lease calls. The API is per lease, the credential provider caches tokens for at least a minute, and the call is over a local socket. I'll revisit with a measurement if it shows up.
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.
…estore Each image the image provider plugin prepares holds a lease until atelet releases it. atelet now releases the leases that an actor's overlay specs record when the actor checkpoints or terminates, and when a Run or Restore fails. It removes each spec after releasing it, so a second call releases nothing. Run and Restore release them too before they reset an actor's dirs, since the reset deletes the specs of an earlier activation.
An image provider plugin keeps a lease per image use, and atelet may restart, or the plugin may restart, while actors still use their layers. Whenever the plugin socket appears or is replaced, at atelet startup or after a plugin restart, atelet sends ReconcileImages with the leases that the overlay specs on the node record. A failed reconcile is retried on the next check. An unreadable spec fails the reconcile, because the plugin would otherwise drop its leases and unmount layers that actors use. Bundle prepares and releases hold providerLeaseMu for reading, and the reconcile holds it for writing, so the plugin never learns a lease set that misses a lease taken but not yet recorded in a spec. Each ReconcileImages call is bounded by a 30s timeout, since it holds the lock that bundle prepares wait on.
A plugin that reads the registry lazily keeps using the credentials from PrepareImage, which can expire while the lease is held. It reports AUTH_REFRESH_REQUIRED for such a lease. atelet remembers what the plugin reported for each lease, and treats a lease it has no answer for as required. Every minute, and right after a reconcile, it resolves fresh credentials for those leases and sends them with RefreshAuth. A lease the plugin does not hold is skipped until the next reconcile.
See the review threads on agent-substrate#4026 through agent-substrate#4031.
310befd to
50b47fb
Compare
|
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. Credentials are named by an auth key, one RefreshAuth refreshes every lease with that key, and ReconcileImages returns the auth keys that need fresh credentials. Track the refresh mode per auth key and send one RefreshAuth per key. After a reconcile, refresh only the keys it returns, instead of every lease. Release and reconcile leases by ID, and log the leases the plugin lost. Vendor the revised API and client.
Part of #4023. Includes #4029. This PR's commit is from Nov 19, as first reviewed, the next commit has the review fixes for the whole 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.
Blocked on
ai-on-gke/image-provider-pluginv0.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.atelet gives each lease the image's repository as its auth key. While the
plugin reports
AUTH_REFRESH_REQUIREDfor an auth key, atelet sends freshregistry credentials once per key every minute, and right away for the keys
a reconcile returns in
auth_refresh_required. The credentials arenode-level only.
ate.imageprovider.auth_refresh.failures,moved here from #4027, counts the refreshes that fail.
Testing:
go test -race ./cmd/atelet/....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.