Repository navigation
add hack/ helpers for bootstrapping engine image using stable SDK - #3755
Conversation
sipsma
left a comment
There was a problem hiding this comment.
Had some more ideas about approaches here, just kind of spitballing.
Given the setup from this PR: #3756
What do you think about a slightly different approach like this:
./hack/devis a script that builds dev dagger using the bootstrap sdk- If you provide no args, all it does is build dev dagger, run it in docker and print out the
DAGGER_HOSTto use to connect to it - If you do provide args it executes whatever they are with the
DAGGER_HOSTenv set./hack/dev make ...would let you run any other automation with your dev engine (this might also require that ./hack/dev adds thehackdir to $PATH before exec'ing the args)./hack/dev bashwould open a shell where all your commands run against the dev engine
- If you provide no args, all it does is build dev dagger, run it in docker and print out the
- Rather than symlinking go.mod,
./hack/devjust does acdinto the directory where the other go.mod exists and doesgo runfrom there to build and deploy the dev engine.- I just suspect this might be simpler and possible in this different approach, but could be missing something
I think that might be more flexible than the original idea of fork/exec'ing mage.
The biggest downside I can think of is that it still means users would have to remember to do ./hack/dev ... in order to run against the dev engine rather than it being the default (and running against not dev being the exception), which I think was one of @aluzzardi's general concerns around all this stuff too.
./hack/dev bashhelps with this I suppose. Maybe we could view./hack/devas the general entrypoint to doing any sort of local dev? Or maybe that's really limiting, not sure.
Just curious to get your initial thoughts on this, not so strongly opinionated that I think it's worth blocking this for a long time bikeshedding the DX of our ./hack dir :-)
|
@sipsma Makes sense, yeah this feels like a good time for just a bit of Bash glue instead. I'll play around with the new setup. I'll likely introduce a |
|
Something is bothering me, but I can't quite put my finger on it. Maybe that's just the price to pay to test dagger with dagger, I can't find a simpler approach. My main concern is our tests go through 3 different DAGGER_HOST -- 1) bootstrap with release engine 2) run pipeline with bootstrapped engine 3) dagger-in-dagger for tests running in a ctr.Exec() Even though I know how this works, I keep getting confused ("where am I?") Trying to find an alternative but I'm empty handed for now |
|
@aluzzardi I hear ya. It does get really confusing really quickly. @sipsma I wonder if we should just bootstrap with a plain old |
Yeah, I was thinking something along those lines.
That would get the number of layers down to 1. Downsides:
|
@aluzzardi I think this is just what happens when you dogfood and bootstrap though. In my experience, the bootstrap builds for compilers and distributions is always confusing+mindblowing. Honestly even more so than what we're doing since it'll often involve even more stages. So while yeah I agree that building dagger w/ dagger and testing dagger in dagger gets meta+confusing at times, it's not necessarily indicative that we're doing anything wrong. I think it's par for the course. The alternative is what @vito said, use something else to build and test dagger. We can of course, I just personally think we'd be resigning to that too soon and missing out on great dogfooding opportunities.
In terms of the build, I really think we can isolate the complication entirely to just the first part where you build a dev dagger. The |
|
@sipsma @aluzzardi I'm good to carry on with the dogfooding. I went through similar confusion with Bass (see The part where it was most helpful was being able to configure IP address ranges for CNI so the inner test Buildkit instance didn't conflict with the outer one (here). My case was a little different since I'm actually running another Buildkit as a service with Bass and then running tests against it, whereas our Dagger-in-Dagger just forwards the outer engine through. But the principle still stands that our engine image will likely beef up someday and it'll be nice to have Dagger at that point. Latest changes should be ready to review. I ended up having to keep the restructure ( Happy to take another swing at it though if I missed something. |
There was a problem hiding this comment.
Revisiting this now, one last tweak I think might make sense is something like this:
./hack/make engine:test- results in the dev engine being bootstrapped and running the provided target- basically,
./hack/makealways implicitly wraps itself with./hack/dev(or the end effect of doing that)
- basically,
./hack/make-prod engine:testresults in the tests running against the actual prod release, basically just skip the dev bootstrap
We can still retain ./hack/dev too to support wrapping arbitrary commands.
There was a problem hiding this comment.
Ran into a bunch of problems recently (catch 22): #3928 (comment)
Brainstorming here, but would this be simpler:
- We write our pipelines targeting stable entirely
- separate
go.mod, there's no multiple version of dagger in the same codebase competing against each other
- separate
- In our pipelines, we bootstrap dagger and run tests with dagger-in-dagger-main
internal/mage-> stablecore/integration,sdk/*/*test-> main
There was a problem hiding this comment.
While we're talking about this, I'd also really like the ability to run the tests against a native local engine. Having to rebuild the image all the time for engine changes (even just log.Println) is a pretty gnarly hit to the feedback loop. 😕
I'm still for testing against the engine image since that's what actually ships now, and maybe we do that in CI where the feedback loop doesn't matter, but at least for local dev it'd be awesome to optimize.
otherwise Dockerfile was hitting skipped errors Signed-off-by: Alex Suraci <[email protected]>
* track bootstrap SDK version in separate Go module * move mage code under magefiles/ so it can be optionally run with its own go.mod/go.sum without clashing with the root go.mod * run mage boot:run TARGET to run a target using bootstrap SDK version * run mage boot:dev engine:test to run engine:test target against dev engine built using bootstrap SDK version Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
|
@vito @aluzzardi I got hard blocked by a need for bootstrapping in this PR: #3983 So I went ahead and rebased this and applied the simplifications discussed in comments:
There's also docs for all this in Open to bikeshedding on the various name choices, I have no attachment to the choices I went with. |
|
Okay after writing my last comment I went back to use this on #3983 and realized there was still a catch 22. Fortunately I found a fix that's relatively painless thanks to go workspaces (arguably simpler than before), pushed as a separate commit. Explanation below. The problem is that PR changes engine session to communicate over unix sockets, which means that engine-session binary (and thus the engine image) changes AND the Go SDK needs to change in order communicate with it. With the change I made here earlier, I could successfully bootstrap the dev engine despite those backwards incompatible changes because we now used stable engine to build dev engine. But then when I went to actually run the tests it failed because it was trying to use the old go sdk with the new dev engine-session. Basically, this situation called for something like the original approach of symlinking in go.mod opportunistically so that we could switch between running the CI first with stable go sdk and then later with dev go sdk. However, I found a pretty nice hack to avoid that:
The above gives us the ability to switch back and forth between use of the stable go sdk and the local dev go sdk by just switching
So if you look at the ./hack scripts now, when we need to do something that requires use of the stable engine, we just prefix the command with @vito @aluzzardi Provided there isn't any functional issue with this approach I think we should merge it as an incremental improvement:
|
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
👍 I'll write something and send a PR targeting this branch as base. |
|
Nice, I like the use of Go workspaces for this, the
Not quite, I still have to run |
Signed-off-by: Alex Suraci <[email protected]>
|
@vito thanks for the rebase, was just about to do that and saw it was already done :-) @aluzzardi let me know if you have any concerns with this approach |
|
I think I suggested this in another PR but can't find the link: Wouldn't it be simpler and solve all the issues if we just always write our internal pipelines using stable? As in, we put a
I don't fully understand when we'd use one rather than the other. For instance, I got recently stuck with |
That's what I did at first too in this commit but realized it doesn't work in every case. Using the example of my other PR where I am updating SDKs to communicate with engine session over unix sockets, this is what happens if you just have a separate
The go.work approach fixes this by allowing us to use stable sdk + stable engine to bootstrap and then switch to dev sdk + dev engine after the bootstrap. There are other possible fixes but they are much more involved:
Yeah true, this PR fixes the problem where we have an internal backwards incompatible change (unix sockets in my case) but it won't work if we ever need to make another fully backwards-incompatible API change like that (though @aluzzardi What do you think of this plan:
If there's other approaches for unblocking my PR I'm all ears. I just really want to avoid that PR needing to introduce a way of supporting both localhost and unix sockets at the same time, but if others think making that change is better than the go.work approach (and associated api backcompat issues) then I can go that route instead. |
Yes, that makes sense! Whatever unblocks us right away. Long term, I think a separate
One cool but annoying side effect of
Not sure I fully understand this part. I would have assumed that mage uses stable (sdk and engine) all the way up until |
That's what would be ideal, but in practice we can't do that yet. In order to test against the dev engine we have to set That's why support for mounting |
In the "new world" approach (#3830 (comment)), we could just set |
Yeah exactly, we wouldn't actually be testing the engine we want to test. Once all the changes in #3830 are through and docker.sock mounting is available, engine tests can be updated to do this:
|
|
Makes sense! |
|
(I just saw that the merge commit from before seems to have undone some new logic in the nodejs publish step, fixing, then will merge once I have an approval) EDIT: nevermind, was getting confused by rebase diffs, this should be good to go |
|
lol, weird. np! there must be some JS in there somewhere. 😄 |
fixes #3739
mageCLI when you don't care about bootstrappingmage boot:run TARGETto run a target using bootstrap SDK versionmage boot:run engine:devmage boot:dev TARGETto run a target using dev engine image built using bootstrap SDK versionmage boot:dev engine:test