#Shell outside module
1 messages ยท Page 1 of 1 (latest)
on v0.15.4, if there was no module, it would do this:
โฏ pwd
/home/jedevc
โฏ dagger-v0.15.4 shell
Dagger interactive shell. Type ".help" for more information. Press Ctrl+D to exit.
โ
Which branch are you using?
on v0.16:
โฏ dagger-v0.16.1 shell
โ connect 0.2s
โ โ starting engine 0.0s
โ โ โ create 0.0s
โ โ โ โ exec docker ps -a --no-trunc --filter name=^/dagger-engine- --format {{.Names}} 0.0s
โ โ โ โ dagger-engine-v0.15.4
โ โ โ โ dagger-engine-v0.16.1
โ โ โ โ exec docker start dagger-engine-v0.16.1 0.0s
โ โ โ โ dagger-engine-v0.16.1
โ
โ โ connecting to engine 0.0s
โ โ โ moby.buildkit.v1.Control/Info 0.0s
โ โ โ moby.buildkit.v1.Control/Info 0.0s
โ
โ โ starting session 0.1s
โ โ subscribing to telemetry 0.0s
โ โ โ consuming /v1/traces 0.0s
โ โ โ consuming /v1/logs 0.0s
โ โ โ consuming /v1/metrics 0.0s
โ load module 2.1s
! failed to get configured module: Post "http://dagger/query": context canceled
โ โ finding module configuration 2.1s
โ ! Post "http://dagger/query": context canceled
โ โ โ moduleSource(refString: "."): ModuleSource! 2.1s
โ โ โ โ parseRefString: . 0.0s
โ โ โ
โ โ โ โ host: Host! 0.0s
โ โ โ โ .directory(path: "/home/jedevc"): Directory! 2.1s
โ โ โ โ โ upload /home/jedevc from b32t5hc5ezsulbudioavkyjil (client id: jjyd4o4c3ggeooqbsvq4i8cw7, session id: o08sruew63eklmkooxebeo3uh) 2.1s
โ โ โ โ โ โ filesync 2.1s
this is the just released v0.16
That must be because of the refactor on module loading then.
i imagine this is due to module loading changes - the cli isn't doing find-up to work it out
I'll look into it.
โค๏ธ yeah, also happy to look into it, but figured it probably has a wonderful overlap with the fs navigation work
Yeah, does dagger query have the same issue?
Dagger call is different. You need a module there.
In query, listen, and shell it's optional.
true! but it does hang trying to upload my entire home dir, while it used to error out quickly.
less weird, but still a bit unexpected for new dagger users i guess
Yeah
Ping @old stirrup
We could keep a very simple implementation of find up in the client, just looking for a dagger.json in a parent directory. If not found, no reason to request ModuleSource.
or maybe we could do find-up without needing to load the entire directory? feels like that might be somewhat possible, since find up works by stat-ing files
Does it really try to sync all files? Maybe the time it takes is because there's just too many directories?
i think it's trying to copy them all:
upload /home/jedevc from b32t5hc5ezsulbudioavkyjil (client id: jjyd4o4c3ggeooqbsvq4i8cw7, session id: o08sruew63eklmkooxebeo3uh) 2.1s
at least from this message
Ugh... how can we check on a controlled directory, which files are being uploaded?
it's that message Justin posted above, upload /home/jedevc means that whole dir is being uploaded (if there were includes/excludes then those would also be in the message)
Yeah we shouldn't upload the whole dir when just running dagger shell, it's coming from here: https://github.com/sipsma/dagger/blob/250b95a11a0a711badea8ea6391c5d045219e879/core/schema/modulesource.go#L342-L342
Which I definitely added in order to cover some corner case one or more integ tests were hitting
how are you seeing the behavior with dagger call? When I run dagger call in an empty dir with no dagger.json in parents or anything I actually get a panic lol which is its own problem obviously
Caught panic:
runtime error: invalid memory address or nil pointer dereference
Restoring terminal...
goroutine 15 [running]:
runtime/debug.Stack()
/usr/lib/go/src/runtime/debug/stack.go:26 +0x64
runtime/debug.PrintStack()
/usr/lib/go/src/runtime/debug/stack.go:18 +0x1c
github.com/charmbracelet/bubbletea.(*Program).recoverFromPanic(0x4000477a40)
/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.2.4/tea.go:705 +0x84
panic({0xf95ca0?, 0x24bc440?})
/usr/lib/go/src/runtime/panic.go:785 +0x124
main.(*FuncCommand).loadCommand(0x24e0a80, 0x4000431508, {0x2532800, 0x0, 0x0})
/app/cmd/dagger/functions.go:319 +0x29c
main.(*FuncCommand).execute(0x24e0a80, 0x4000431508, {0x2532800, 0x0, 0x0})
/app/cmd/dagger/functions.go:294 +0x114
main.(*FuncCommand).Command.func2.1({0x13f4398, 0x40002fd4d0}, 0x0?)
/app/cmd/dagger/functions.go:174 +0x188
main.(*FuncCommand).Command.func2.withEngine.2({0x13f43d0?, 0x4000405310?})
/app/cmd/dagger/engine.go:63 +0x3a0
github.com/dagger/dagger/dagql/idtui.(*frontendPretty).spawn(...)
/app/dagql/idtui/frontend_pretty.go:723
github.com/charmbracelet/bubbletea.(*Program).handleCommands.func1.1()
/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.2.4/tea.go:324 +0x64
created by github.com/charmbracelet/bubbletea.(*Program).handleCommands.func1 in goro
/go/pkg/mod/github.com/charmbracelet/bubbletea@v1.2.4/tea.go:318 +0x10c
problem is this line, guessing mod or MainObject is nil https://github.com/sipsma/dagger/blob/250b95a11a0a711badea8ea6391c5d045219e879/cmd/dagger/call.go#L69-L69
I'll look to see what happens when I remove that condition that falls back to uploading the whole source dir
That must be because of a change in behavior. Functions should have failed before hitting that if not in a module.
Yeah for sure, I gotta send out a PR to try removing that condition anyways to see what happens in CI. I'll include a fix for the panic there too
I expect call and functions to fail during module load if there's no module.
might be that it's hitting this line now after the adjustments to those functions: https://github.com/sipsma/dagger/blob/250b95a11a0a711badea8ea6391c5d045219e879/cmd/dagger/module_inspect.go#L82-L82
hmmm... initializeModule should fail if config doesn't exist. It's tryInitializeModule that shouldn't fail. That was the diff.
So basically initializeModule became tryInitializeModule but should be the other way around.
My feedback in https://github.com/dagger/dagger/pull/9505#discussion_r1959653835 was to keep both, but didn't insist because I refactored the shell to not need the "try" variation anymore.
one min, have to pivot to a different fire #1319379215849881631 message
are you updating all of that in your shell pr? I'm just wondering if it's worth refactoring in my pr to fix this or just doing a quick fix and letting your pr clean it up
I definitely misunderstood what you were suggesting, sorry, it was getting hard to keep all the details in my head at once towards the end there
You can just return an error when !configExists in initializeModule to fix call and functions. I'll either push the fix for shell in your PR (quicker merge) or integrate in mine. The shell has two behaviors on initial load. If a module isn't found, it should load the core api only. It's like "try dagger call, fallback to dagger core".
The thing with the shell PR is that i didn't realize initializeModule wasn't failing. So I'll need to revisit that.
Actually the shell PR should be ok (in my PR, not in main). Because on init I use the maybeInitializeDefaultModule which already shouldn't fail and still exists. During run I make specific ModuleSource(ref).ConfigExists() calls before calling initializeModule, so those shouldn't fail.
If that wasn't clear: need to fix initializeModule to return error if !configExists. That will fix call, functions, and the shell in main. My shell PR doesn't change initializeModule, so this quick fix won't be undone later. It's actually needed.
I'll send a separate one for the default load of dir when no dagger.json found
I suspect that one might be a bit more tricky since there's more weird corner cases there
To start, going to remove the condition and push to a draft PR and see what tests fail ๐ I know there was some weird case involving a dagger.json getting deleted or something, but can't remember which test
From there, I guess there's a few approaches:
- Can defer module loading until later in that case. Fortunately the new code make it easy to load context whenever you want. It was nice to centralize it in
moduleSourcebut implementation wise it can happen anywhere - Maybe worst case we could use an extra arg to
moduleSourceto control this behavior for different use cases, but hopefully can avoid that
Yeah, or even maybe compile a list of includes based on parent dir + dagger.json for a first sync. That's the sort of thing I tried with the .gitignore support.
https://github.com/dagger/dagger/pull/9659 No tests failed?
Highly possible that I added that to fix some test at some point and later fixed it in a different way. I later had to add some extra logic that reloads context whenever anything is changed that can impact it (withSourceSubpath, withIncludes, etc.)... I wonder if it's covered by those now?
uh
dagger v0.16.1, just in my homedir, fresh env, just running dagger call
i don't see the panic weirdly
woop, that fixes it ๐
hmmm, not strictly the same bug here, but also potential fallout from the same module loading:
echo "{version}" | dagger query
โ connect 0.2s
โ moduleSource(refString: "."): ModuleSource! 0.0s
! failed to unmarshal module config: unmarshal module config: unmarshal module config: unmarshal sdk as struct: json: cannot unmarshal number into Go value of type modules.alias
โ version: String! 0.0s
{
"version": "v0.16.1"
}
โฏ cat dagger.json
{
"name": "test",
"engineVersion": "v100.0.0",
"sdk": 123
}
i have an intentionally invalid dagger.json, and it seems like we see it's invalid, but then just fallback to no-module load - i think ideally we'd only skip to the fallback of no-module load if the dagger.json doesn't exist?
(again dagger v0.16.1)
Yep ๐
intentional?
No, it should fallback only when dagger.json doesn't exist.
okay cool ๐
Is that a thing that needs a separate fix or is it covered by your shell PRs @halcyon eagle
Needs a fix, not covered.
My PR doesn't touch ModuleSource besides adding the original subpath.
There's another issue that throws a big wrench in the shell. This wasn't introduced by your refactor, but for the shell now these become different modules:
โ .core | module-source github.com/dagger/dagger/sdk/php@v0.16.1 | as-string 8.0s
github.com/dagger/dagger/sdk/php@sdk/php/v0.16.1
โ .core | module-source github.com/dagger/dagger/sdk/php/src@v0.16.1 | as-string 2.1s
github.com/dagger/dagger/sdk/php@v0.16.1
Notice the tags, sdk/php/v0.16.1 vs v0.16.1. I could use the digest instead of the as-string value as cache keys, but that adds the need for more calls. Right now the full ref is more helpful to diagnose (e.g., .debug). Would have to change a bunch of things to change that.
I guess the problem is that we just do the fallback behavior for dagger query and friends when err != nil, but we more want to only have the fallback behavior for some errors.
Matching on error string contents is gonna be a shitshow (though we can do that if nothing else)... I know we have the special ExecError that SDKs are aware of, but if I wanted to add more special error types is that something I can just do on the schema level and have all the SDKs pick up through codegen, or do special error types require per-SDK work to handle right now?
They require SDK work, but that's going to change eventually with the centralization of codegen. It doesn't matter though because we can start with support for the CLI, meaning you need to add it only on the Go SDK. Shouldn't break anyone else.
I think it's only this case, so maybe possible to just check if the file exists first? Although, typed errors would be very cool honestly (although I think we might be able to use/abuse grpc error codes, like we do for checking if files exists or not over the attachables)
well we hit the error from an invalid config before we can even call .ConfigExists, so it's tricky. I'm going with the typed error because it's just mentally simpler and pretty easy to do
eh nevermind, I realized that the place I put the "find-up cwd for named dep" logic was a little weird and that if I moved it a little down then I could actually just use the AllowNotExists option and skip typed errors: https://github.com/dagger/dagger/pull/9681
previously that find-up for named dep didn't run if allowNotExists: true, which was incorrect, so that's also fixed now
(I think, we'll see if there's some corner case I missed)
there's still a corner case from these tests: https://github.com/sipsma/dagger/blob/91e3879633d6cdc50aea3ec6975a0aa7e36cdd34/core/integration/module_test.go#L2270-L2270
Since they fail due to host fs stat'ing not working at all when it's disabled....
Maybe I do also need a custom error still...