Skip to content

Building shim can cause rate limit errors from dockerhub #3733

Closed

Description

@sipsma

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:

  1. Pull the image from a different registry that doesn't have the same ratelimiting
  2. 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:

  1. save us from managing another image.
  2. 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)
  3. 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:

  1. Fairly easy
  2. Robust enough - just reuses existing well defined mechanisms for hooking into container runtimes
  3. Doesn't require any upstream changes to buildkitd afaict
  4. 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:

  1. 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

  1. added
    kind/bug
    area/engine
    on Nov 8, 2022
  2. noiseoverip commented on Nov 14, 2022

    @noiseoverip

    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.

  3. self-assigned this
    on Nov 17, 2022
  4. aluzzardi commented on Nov 17, 2022

    @aluzzardi
    Contributor

    Alternative, very hacky solution for Option 2 (just putting it on the table):

    • We go:embed the shims for all architectures
      • To inject the shim, we WriteFile it directly
    • To keep things easy enough
      • The shims are gitignored
      • The engine build process would start first by building shims, then the engine

    Pros:

    • As stupid simple as it gets

    Cons:

    • Increased binary size for the engine
    • Large LLB payload
    • LLB payload limit (it will stop working eventually if the shim outgrows max gRPC buffer size)
    • More complicated build process
  5. sipsma commented on Nov 17, 2022

    @sipsma
    ContributorAuthor

    Cons:

    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 :-)

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

Metadata

Metadata

Assignees

Labels

area/enginekind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions