Repository navigation
Description
We build our shim binary on the fly, which requires we pull an image. We currently pull from dockerhub, which can result in 429 throttling errors, which is surprising to users since they never even requested that image be pulled.
Two options:
- Pull the image from a different registry that doesn't have the same ratelimiting
- Don't build the shim like that anymore; maybe pre-build it and include it in our engine image now that that's an option
Current preference is 2. That approach would:
- save us from managing another image.
- make it easier for users to customize the engine image in the future or to mirror it on their own registries (i.e. an internal company one)
- be more performant (pull everything at once)
Option 2 is easier said than done unfortunately. There's not really a built-in way to just mount a binary from the buildkitd's host filesystem into arbitrary execs. Execs are supposed to be fully specified by LLB and LLB alone, and LLB can only include references to the client's host filesystem (which is not the same buildkitd's).
There are bunch of possible approaches, but there's one that sticks out to me as being not that hacky and also relatively easy: hook into the runc executor.
Right now, our buildkitd uses runc to start containers. We can use oci runtime hooks to modify the spec of those containers to include a mount of our shim binary into each container.
- I know of this existing tool for accomplishing this pretty easily, but it's also not even that hard to roll our own if a compelling need arises.
In the future if we decide to switch to the containerd backend then that same approach will probably still work because the default containerd runtime uses runc. But at that point we could also have our own runtime (containerd coincidentally also uses the terminology "shim"...) too, so there will be lots of options.
Pros:
- Fairly easy
- Robust enough - just reuses existing well defined mechanisms for hooking into container runtimes
- Doesn't require any upstream changes to buildkitd afaict
- A nice re-usable mechanism in the future in case we ever need to mount anything else from the buildkitd host direct into the container
Cons:
- The shim binary will no longer be part of LLB and thus won't count towards the cache key. Changing the shim won't invalidate cache
- Actually, as I write this, that might just make sense... the shim is a component of the runner, so just like changing buildkitd doesn't invalidate cache, neither should the shim? Sort of a gray area, but this isn't actually an obvious con I suppose.
Activity
noiseoverip commentedon Nov 14, 2022
Option 2 would be great because I am failing(without forking) to run this behind companies proxy. It should not be pulling anything from global docker namespace unless i explicitly specify it in my application configs or i should have a way to override the image name.
aluzzardi commentedon Nov 17, 2022
Alternative, very hacky solution for Option 2 (just putting it on the table):
go:embedthe shims for all architecturesPros:
Cons:
sipsma commentedon Nov 17, 2022
Even worse, the LLB is in our IDs that we send back and forth between clients, so we'll be transferring the binary back and forth on every single ID that includes an Exec in its DAG :-)