Repository navigation
Add Container { withMountedDirectory } - #3205
Conversation
meta isn't really like other mounts: we need to access it specifically in exitCode/stdout/stderr, and we don't want it propagating from one container to the next. having it separate makes most of the code cleaner, at the cost of an extra return value from Decode. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
👷 Deploy request for cloak-docs pending review.Visit the deploys page to approve it
|
this was actually fine and it failed again This reverts commit ce678e8. Signed-off-by: Alex Suraci <[email protected]>
* refactor away from Container.Decode and its 4 return values * move behavior from container schema to Container model Signed-off-by: Alex Suraci <[email protected]>
24b33e2 to
52f2776
Compare
linter was complaining about code being too similar, which is kind of nonsense imo. I switched it to use a scratch directory which surfaced some issues, so I refactored scratch directories to work more like scratch containers and added a helper for handling a marshaled llb.Scratch. Signed-off-by: Alex Suraci <[email protected]>
this should probably be done everywhere, but it's a start Signed-off-by: Alex Suraci <[email protected]>
|
@sipsma @aluzzardi @shykes This is finally ready, though it ended up with more churn than I would have liked. (One linter led to another.) I would recommend doing split diff view instead of unified. 😄 |
sipsma
left a comment
There was a problem hiding this comment.
I think we should fix the comment about amd64 in the test before merging (unless it's not actually an issue) but overall looks great!
|
|
||
| // propagate any changes to the mounts to subsequent containers | ||
| for i, mnt := range mounts { | ||
| execMountDef, err := execSt.GetMount(mnt.Target).Marshal(ctx, llb.Platform(platform)) |
There was a problem hiding this comment.
If you specify multiple mounts at the same location, I think this will not error out but you'll start getting the wrong mount here.
This gets into all the corner cases around overlapping mounts that we are just ignoring for the first iterations here, so fixing this isn't a blocker at all, but worth a followup issue.
One solution is to get the modified mount state by calling execSt.AddMount instead of GetMount, but we may want to handle this situation entirely differently, so can figure it out later.
There was a problem hiding this comment.
I see - so the issue is that we always append to containerIDPayload.Mounts which almost does what the user wants, since later ones override, but GetMount always gets the first mount from the list, i.e. the one that is going to be mounted over by the later ones.
One solution is to get the modified mount state by calling
execSt.AddMountinstead ofGetMount, but we may want to handle this situation entirely differently, so can figure it out later.
I'm not sure I follow, but I guess another way could be to replace any mounts at or beneath the same target when adding a mount point, rather than just appending?
There was a problem hiding this comment.
I'll save the fix here for after #3217 is merged since it adds a bunch of other mount APIs that'll need to be updated. Thanks for noticing it!
There was a problem hiding this comment.
Yeah we need to decide what we want the behavior to be in overlapping mount cases, including once we support withoutMount. My default assumption is that we just mirror the behavior of how mounts work in Linux where if you make multiple mounts over the same point then they "stack" in that if you unmount one you will reveal the one below it.
In that case, the problem is that in this loop all the mounts at a given point will be set to the same one, so if you later unmount you will no longer have the mount you were expecting.
The suggestion to use AddMount is that in LLB instead of providing mounts as run options you can also do this:
execState := llb.Image(...).Run(...)
mountA := execState.AddMount(foo, "/foo")
mountB := execState.AddMount(bar, "/bar")in which case mountA and mountB will be the state of the mounts after the exec occurred. Basically a different way of accomplishing what GetMount accomplishes, but in such a way that I think this case of overlapping mounts will be handled.
Either way, yeah this will be important to get right someday for consistency but it's getting far beyond what we need to implement right now, saving for after #3217 sounds good to me.
There was a problem hiding this comment.
Oh nice, yeah that's a much cleaner fix! Just confirmed locally with a test I wrote for the other fix I attempted and it also makes it pass. I like the idea of just deferring to the platform's native mount layering semantics.
Here's the fix: 522b11f
Signed-off-by: Alex Suraci <[email protected]>
|
@sipsma Ready for another look! |
part of #3183
/dagger) in a separate field withinContainerIDsince its lifecycle differs from regular mountsContainer { withMountedDirectory }and propagate changes to mounts from parentContainerto childDirectoryIDContainer { stdout, stderr }nullable (same reasonexitCodeis nullable)container { from }to propagate mounts