Repository navigation
Engine Image - #3647
Engine Image#3647
Conversation
|
This is awesome -- thanks for making a proof of concept so fast. Haven't read the code yet, preliminary comments based on the PR description:
Minor thing: @samalba expressed some concern about image size, etc. I was thinking of an alternative (not sure how good it is)
🎉
Shouldn't the local engine binary already know which image to use (e.g. it's own version)?
nit: rather than
Not that it matters that much actually -- SDK code is a little bit trickier to read from stdout and stream to a file rather than running a one-off
Especially to continue making this working on dev a breeze.
Just a small nit: we might want to use the "future" nomenclature right away and have these 2 binaries:
Oh, I get why it's Long term, do we want the SDKs run the engine OCI image themselves (once it's long running and there's no more local process to copy)? If that's the case -- wouldn't it make sense to rip off the bandaid and do it now? We can find ways to make it easier -- for instance, our bootstrapper creates a volume. Instead we could just declare a But there might be a ton of edge cases though -- in which case maybe it's fine to start with this. |
Yeah I think at least splitting this up by architecture makes sense. I suspect 99% of our users right now are just defaulting to running dagger in their local docker daemon, in which case the architecture will always match. Splitting also up by OS has some weirdness in terms of breaking the symmetry of the implementation (there's no base buildkitd for darwin), but we definitely can do that too. At that point we may be splitting hairs in terms of performance. I'll see how big the binaries are and go from there.
Yeah, and we could still rely on that, it just ties in to the "two-staged bootstrap" thing I mentioned, which gives me a headache to think about. It's conceptually easier to just have one version that gets passed from sdk->engine, but maybe I'll wake up tomorrow and this will make more sense and not be a big deal. I'll do whatever results in the simplest implementation for now.
My motivation was that you have to do a Either way,
Sounds good on both accounts 👍
Totally agree and that was my starting point point actually. But then I remembered we used I was planning on revisiting this on my next passthroughs of the code. I'll see if we can get the synchronization we want w/out flock or other weirdness while also not making the implementation really complicated. |
|
Here's a fun problem, completely independent of all the stuff about how we distribute/package the helper. Current world (before introduction of new SDKs and only depend on moby/buildkit image):
New world (where we support multiple SDKs, such as Go+Python, and depend on our own engine image):
Here's my current thinking in terms of how to tackle some of these problems (and the one place where it breaks down):
Pros:
Cons:
Another possible solution: don't care about this. Tell users that all the SDKs on a given machine must be updated to the latest release in order to work. This means that whenever we update the engine we need to update each of our SDKs with the new dependency in lockstep as much as possible. I might be okay with that in the short term, but in the longer term I think we need a better story than that. |
|
Talked to @aluzzardi about the above issue, there's no great solutions right now but for sake of time I'm just going to go with the "one container per version" approach and have the SDK remove any other engines it sees. Essentially always garbage collect anything besides your own container which you assume is the one and only true latest version. This means that:
This gives us more time to figure out better approaches and interfaces for solving this problem. It also can be layered on top of fairly easily (with various more "intelligent" garbage collection approaches) if we decide we are willing to pay the complexity cost of that. |
7df7d7c to
de192af
Compare
There was a problem hiding this comment.
nit: I was thinking of standardizing this to sdk:*:publish -- to avoid confusion with releasing (cutting the tag etc)
There was a problem hiding this comment.
I think this won't work on Mac
There was a problem hiding this comment.
It works, just double checked again on my mac directly. engineContainer always uses linux as the base OS (since that's all we support), specifying darwin as an os here only results in darwin helper binaries being include in the image.
There was a problem hiding this comment.
So this is going to be the dev process going forward right? Start this, export, and do your thing?
What happens to the rest of the CI code that uses the Go SDK? Do we need to do this as well? #3704
nit: Start? Dev?
There was a problem hiding this comment.
So this is going to be the dev process going forward right? Start this, export, and do your thing?
Yeah this is the baseline. I also included engine:test that does this and then runs all the core/integration tests as a convenience, but in general you can use this target and then export DAGGER_HOST and do whatever you want from there.
What happens to the rest of the CI code that uses the Go SDK? Do we need to do this as well? #3704
Here's what I'm imagining for CI in general, just as a barebones starting place:
- For our engine tests, we always build the local engine and run core/integration against that
- For each SDK we:
- Have a run that runs outside of dagger-in-dagger (i.e. the same ways users will actually run the SDK)
- This gives us coverage of their provisioner code and verifies they work against their current hardcoded engine dependency (i.e. the image ref+sha they use by default)
- Have a run that runs inside dagger-in-dagger, where dagger has been provisioned using the latest engine built from local code
- This lets us verify the SDKs against the latest engine without having to actually push it to a registry anywhere and without having to implement the extra
docker-containerengineconn in every SDK (only needed in go).
- This lets us verify the SDKs against the latest engine without having to actually push it to a registry anywhere and without having to implement the extra
- Have a run that runs outside of dagger-in-dagger (i.e. the same ways users will actually run the SDK)
I want to double check that there's no weird catch 22 cases where we might want to push engine updates that are backwards incompatible w/ SDKs without necessarily having updated the SDKs yet. I think worst case scenario we could make the test runs of SDKs against the latest engine "warning-only" if they fail.
nit: Start? Dev?
Sure I'll change to dev
There was a problem hiding this comment.
Just to capture discord discussions, the plan will be:
- Engine tests will run against
mainengine only - Each SDK will be tested via dagger-in-dagger against
mainengine only - There will be separate test suites that exercise the provisioning code of the SDKs.
- These can run dagger-in-dagger once we have support for mounting a docker socket in. In the meantime they may just be manually executed to start with.
- These tests will provision
mainengine which has been pushed to some local registry. This avoids catch 22s of incompatible api changes
- When we release an SDK we will also run those provisioner tests except against the actual engine dep in the SDKs, not
main. These tests will block the release if failed.
There was a problem hiding this comment.
Should we continue using ./...?
With this change we are not longer testing e.g. ./router/merge_test.go
There was a problem hiding this comment.
Oh I forgot that there were more tests under router.
Yeah I'll update to do ./... which will also include running the Go SDK tests against latest engine for now. See my other comment for the longer term idea on how to test each SDK. But there's no harm in ./... at the moment.
There was a problem hiding this comment.
Yeah I'll update to do ./... which will also include running the Go SDK tests against latest engine for now. See my other comment for the longer term idea on how to test each SDK. But there's no harm in ./... at the moment.
Since it's a different go module, ./... doesn't include that
There was a problem hiding this comment.
related to the other question. Should we either:
- Update all tests using the Go SDK to spin up a local engine. OR
- Leave as is and let the Go SDK use the embedded Engine (for now)
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Tested against Go SDK and Python so far (have since removed the Python related commits from here in order to disentangle).
This is currently a backwards compatible PR. Once all other SDKs (python+nodejs) have been updated with the new
docker-imageengineconn, we can removed the embedded engineconn from here and get rid of the replace stuff. That will be a follow up though.Approach
We now build a container image that includes buildkitd and dagger engine binaries. We build it for multiple arches and include binaries for each client OS as needed
mage engine:devwill build and run it from your local code in docker just for the os/arch needed to test locally.mage engine:publishwill build it for all arch/os combos and push it to a registry (just a placeholder registry until we have set up a real one)mage engine:testbuilds the local test engine and then runsgo test ./...against itNew engineconn implementations
docker-image://<image>This is going to be the default connector once all is said and done.
This one accepts a ref to an engine image *which must include an pinned
@sha256:digest). The SDK runs the image, copies out thedagger-sdk-helperbinary for the client os/arch to a local cache dir and then invokes it as a child processdagger-engine-<id>, where id is from the pinned sha of the image ref-<id>so that they can be re-used safely.docker cpto a temporary file in the same cache dir as the final binary. Then we do the rename syscall to atomically swap it to the final binary, which ensures consistent behavior when SDKs are running concurrently.docker-container://<container name>This one is only needed for our testing setup currently. It also only needs an implementation in Go; other SDKs can skip it.
It follows the same idea as
docker-imageexcept that:docker runanything, it just uses the container it's provided as isThe
mage:startlocaltarget mentioned above builds the local engine image, loads it into docker and then starts a docker container from it. It finally prints out the env var you need to set to run against that container (export DAGGER_HOST=docker-container://test-dagger-engine)test-so that it isn't picked up by the garbage collection of thedocker-imageengineconnHelper binary interface
This binary is internal only, should only be invoked as a subprocess of the SDK engineconn implementations.
It is it's own main func, completely separate from the existing
cloakcommands. It is packaged into the engine image at/usr/bin/dagger-sdk-helper-<os>-<arch>--workdirand--projectthe same as other previous commands--remotewhich tells it how to connect to the remote engine (e.g.docker-container://dagger-engine-abc123):0to tell the kernel to find an available one for it). It then writes the port number it found to stdout. This allows sdks to know which port to connect to.TODOs:
accept tcp 127.0.0.1:36089: use of closed network connectionshows up because the helper needs to ignore that error on shutdownFor follow up PRs:
stagingtag or somethingembeddedengineconn from the Go SDK and default to thedocker-imageengineconnbuildkitdprovisioning from the engine itself (though this will in turn require updates tocloak devunless the playground backend uses a different approach).dagger.Connect) and slightly increases startup time ofdagger.ConnectFAQ
docker execthe engine binary in the image?-v /:/hostalmost solves this but doesn't really work on MacOS and has other tradeoffs that make it not worth it.docker execit in the container image