status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
โŒ€
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
dagger/dagger
https://github.com/dagger/dagger
6,162
Go SDK Modules: enable general type annotation support via comments
Discord discussion: https://discord.com/channels/707636530424053791/1177373379255349248 As we need to add more support in Go for things like marking a field as private, setting default values, etc. The most obvious option was to require use of structs (including the `Opts` struct idea, the "inline anonymous struct for args", etc.) and annotate more information via struct tags. However, after discussion we realized a better general solution would be to not rely on struct tags but instead add support for the equivalent functionality via specially formatted comments. The reasoning being that: 1. Struct tags are essentially just glorified comments (strings that get interpreted by reflection/ast parsing), so there's not much of a practical difference in that respect 2. Comments are more general in that they can be applied equivalently not only to fields of a struct but also to function args (similar to how we support doc strings on args today), functions as a whole, structs as a whole, etc. There's prior art for this: 1. Go's support for pragmas: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas 2. K8s support for annotations: https://github.com/kubernetes-sigs/controller-tools/blob/881ffb4682cb5882f5764aca5a56fe9865bc9ed6/pkg/crd/testdata/cronjob_types.go#L105-L125 TBD the exact format of comments (i.e. use of a special prefix `//dagger: default=abc` vs something simpler like `//+default abc`). We should use this to support at least: 1. Optional (can co-exist w/ existing `Optional` type) 2. Default values (will be limited to what can be represented as a string, but that's ok) 3. Marking object fields as private (so not included in public API but still included in serialization of object) cc @vito @jedevc
https://github.com/dagger/dagger/issues/6162
https://github.com/dagger/dagger/pull/6179
e8097f5798af7f8b22f2a1be94a27c9800185053
a499195df3de436969c4477bb1e9f074aa586eb6
2023-11-27T16:51:18Z
go
2023-12-06T14:29:35Z
core/integration/module_test.go
t.Helper() out, err := ctr.With(daggerQuery(introspection.Query)).Stdout(ctx) require.NoError(t, err) var schemaResp introspection.Response err = json.Unmarshal([]byte(out), &schemaResp) require.NoError(t, err) return schemaResp.Schema } func goGitBase(t *testing.T, c *dagger.Client) *dagger.Container { t.Helper() return c.Container().From(golangImage). WithExec([]string{"apk", "add", "git"}). WithExec([]string{"git", "config", "--global", "user.email", "dagger@example.com"}). WithExec([]string{"git", "config", "--global", "user.name", "Dagger Tests"}). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithExec([]string{"git", "init"}) } func logGen(ctx context.Context, t *testing.T, modSrc *dagger.Directory) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,162
Go SDK Modules: enable general type annotation support via comments
Discord discussion: https://discord.com/channels/707636530424053791/1177373379255349248 As we need to add more support in Go for things like marking a field as private, setting default values, etc. The most obvious option was to require use of structs (including the `Opts` struct idea, the "inline anonymous struct for args", etc.) and annotate more information via struct tags. However, after discussion we realized a better general solution would be to not rely on struct tags but instead add support for the equivalent functionality via specially formatted comments. The reasoning being that: 1. Struct tags are essentially just glorified comments (strings that get interpreted by reflection/ast parsing), so there's not much of a practical difference in that respect 2. Comments are more general in that they can be applied equivalently not only to fields of a struct but also to function args (similar to how we support doc strings on args today), functions as a whole, structs as a whole, etc. There's prior art for this: 1. Go's support for pragmas: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas 2. K8s support for annotations: https://github.com/kubernetes-sigs/controller-tools/blob/881ffb4682cb5882f5764aca5a56fe9865bc9ed6/pkg/crd/testdata/cronjob_types.go#L105-L125 TBD the exact format of comments (i.e. use of a special prefix `//dagger: default=abc` vs something simpler like `//+default abc`). We should use this to support at least: 1. Optional (can co-exist w/ existing `Optional` type) 2. Default values (will be limited to what can be represented as a string, but that's ok) 3. Marking object fields as private (so not included in public API but still included in serialization of object) cc @vito @jedevc
https://github.com/dagger/dagger/issues/6162
https://github.com/dagger/dagger/pull/6179
e8097f5798af7f8b22f2a1be94a27c9800185053
a499195df3de436969c4477bb1e9f074aa586eb6
2023-11-27T16:51:18Z
go
2023-12-06T14:29:35Z
core/integration/module_test.go
t.Helper() generated, err := modSrc.File("dagger.gen.go").Contents(ctx) require.NoError(t, err) t.Cleanup(func() { t.Name() fileName := filepath.Join( os.TempDir(), t.Name(), fmt.Sprintf("dagger.gen.%d.go", time.Now().Unix()), ) if err := os.MkdirAll(filepath.Dir(fileName), 0o755); err != nil { t.Logf("failed to create temp dir for generated code: %v", err) return } if err := os.WriteFile(fileName, []byte(generated), 0644); err != nil { t.Logf("failed to write generated code to %s: %v", fileName, err) } else { t.Logf("wrote generated code to %s", fileName) } }) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,162
Go SDK Modules: enable general type annotation support via comments
Discord discussion: https://discord.com/channels/707636530424053791/1177373379255349248 As we need to add more support in Go for things like marking a field as private, setting default values, etc. The most obvious option was to require use of structs (including the `Opts` struct idea, the "inline anonymous struct for args", etc.) and annotate more information via struct tags. However, after discussion we realized a better general solution would be to not rely on struct tags but instead add support for the equivalent functionality via specially formatted comments. The reasoning being that: 1. Struct tags are essentially just glorified comments (strings that get interpreted by reflection/ast parsing), so there's not much of a practical difference in that respect 2. Comments are more general in that they can be applied equivalently not only to fields of a struct but also to function args (similar to how we support doc strings on args today), functions as a whole, structs as a whole, etc. There's prior art for this: 1. Go's support for pragmas: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas 2. K8s support for annotations: https://github.com/kubernetes-sigs/controller-tools/blob/881ffb4682cb5882f5764aca5a56fe9865bc9ed6/pkg/crd/testdata/cronjob_types.go#L105-L125 TBD the exact format of comments (i.e. use of a special prefix `//dagger: default=abc` vs something simpler like `//+default abc`). We should use this to support at least: 1. Optional (can co-exist w/ existing `Optional` type) 2. Default values (will be limited to what can be represented as a string, but that's ok) 3. Marking object fields as private (so not included in public API but still included in serialization of object) cc @vito @jedevc
https://github.com/dagger/dagger/issues/6162
https://github.com/dagger/dagger/pull/6179
e8097f5798af7f8b22f2a1be94a27c9800185053
a499195df3de436969c4477bb1e9f074aa586eb6
2023-11-27T16:51:18Z
go
2023-12-06T14:29:35Z
core/integration/testdata/modules/go/minimal/main.go
package main import ( "context" "strings" ) type Minimal struct{} func (m *Minimal) Hello() string { return "hello" } func (m *Minimal) Echo(msg string) string { return m.EchoOpts(msg, Opt("..."), Opt(3)) } func (m *Minimal) EchoPointer(msg *string) *string { v := m.Echo(*msg) return &v } func (m *Minimal) EchoPointerPointer(msg **string) **string { v := m.Echo(**msg)
closed
dagger/dagger
https://github.com/dagger/dagger
6,162
Go SDK Modules: enable general type annotation support via comments
Discord discussion: https://discord.com/channels/707636530424053791/1177373379255349248 As we need to add more support in Go for things like marking a field as private, setting default values, etc. The most obvious option was to require use of structs (including the `Opts` struct idea, the "inline anonymous struct for args", etc.) and annotate more information via struct tags. However, after discussion we realized a better general solution would be to not rely on struct tags but instead add support for the equivalent functionality via specially formatted comments. The reasoning being that: 1. Struct tags are essentially just glorified comments (strings that get interpreted by reflection/ast parsing), so there's not much of a practical difference in that respect 2. Comments are more general in that they can be applied equivalently not only to fields of a struct but also to function args (similar to how we support doc strings on args today), functions as a whole, structs as a whole, etc. There's prior art for this: 1. Go's support for pragmas: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas 2. K8s support for annotations: https://github.com/kubernetes-sigs/controller-tools/blob/881ffb4682cb5882f5764aca5a56fe9865bc9ed6/pkg/crd/testdata/cronjob_types.go#L105-L125 TBD the exact format of comments (i.e. use of a special prefix `//dagger: default=abc` vs something simpler like `//+default abc`). We should use this to support at least: 1. Optional (can co-exist w/ existing `Optional` type) 2. Default values (will be limited to what can be represented as a string, but that's ok) 3. Marking object fields as private (so not included in public API but still included in serialization of object) cc @vito @jedevc
https://github.com/dagger/dagger/issues/6162
https://github.com/dagger/dagger/pull/6179
e8097f5798af7f8b22f2a1be94a27c9800185053
a499195df3de436969c4477bb1e9f074aa586eb6
2023-11-27T16:51:18Z
go
2023-12-06T14:29:35Z
core/integration/testdata/modules/go/minimal/main.go
v2 := &v return &v2 } func (m *Minimal) EchoOptional(msg Optional[string]) string { v, ok := msg.Get() if !ok { v = "default" } return m.Echo(v) } func (m *Minimal) EchoOptionalPointer(msg **Optional[**string]) string { v, ok := (*msg).Get() if !ok { v = ptr(ptr("default")) } return m.Echo(**v) } func (m *Minimal) EchoOptionalSlice(msg Optional[[]string]) string { v := msg.GetOr([]string{"foobar"}) return m.Echo(strings.Join(v, "+")) } func (m *Minimal) Echoes(msgs []string) []string { return []string{m.Echo(strings.Join(msgs, " "))} } func (m *Minimal) EchoesVariadic(msgs ...string) string { return m.Echo(strings.Join(msgs, " ")) } func (m *Minimal) HelloContext(ctx context.Context) string { return "hello context" }
closed
dagger/dagger
https://github.com/dagger/dagger
6,162
Go SDK Modules: enable general type annotation support via comments
Discord discussion: https://discord.com/channels/707636530424053791/1177373379255349248 As we need to add more support in Go for things like marking a field as private, setting default values, etc. The most obvious option was to require use of structs (including the `Opts` struct idea, the "inline anonymous struct for args", etc.) and annotate more information via struct tags. However, after discussion we realized a better general solution would be to not rely on struct tags but instead add support for the equivalent functionality via specially formatted comments. The reasoning being that: 1. Struct tags are essentially just glorified comments (strings that get interpreted by reflection/ast parsing), so there's not much of a practical difference in that respect 2. Comments are more general in that they can be applied equivalently not only to fields of a struct but also to function args (similar to how we support doc strings on args today), functions as a whole, structs as a whole, etc. There's prior art for this: 1. Go's support for pragmas: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas 2. K8s support for annotations: https://github.com/kubernetes-sigs/controller-tools/blob/881ffb4682cb5882f5764aca5a56fe9865bc9ed6/pkg/crd/testdata/cronjob_types.go#L105-L125 TBD the exact format of comments (i.e. use of a special prefix `//dagger: default=abc` vs something simpler like `//+default abc`). We should use this to support at least: 1. Optional (can co-exist w/ existing `Optional` type) 2. Default values (will be limited to what can be represented as a string, but that's ok) 3. Marking object fields as private (so not included in public API but still included in serialization of object) cc @vito @jedevc
https://github.com/dagger/dagger/issues/6162
https://github.com/dagger/dagger/pull/6179
e8097f5798af7f8b22f2a1be94a27c9800185053
a499195df3de436969c4477bb1e9f074aa586eb6
2023-11-27T16:51:18Z
go
2023-12-06T14:29:35Z
core/integration/testdata/modules/go/minimal/main.go
func (m *Minimal) EchoContext(ctx context.Context, msg string) string { return m.Echo("ctx." + msg) } func (m *Minimal) HelloStringError(ctx context.Context) (string, error) { return "hello i worked", nil } func (m *Minimal) HelloVoid() {} func (m *Minimal) HelloVoidError() error { return nil } func (m *Minimal) EchoOpts( msg string, suffix Optional[string], times Optional[int], ) string { msg += suffix.GetOr("") return strings.Repeat(msg, times.GetOr(1)) } func (m *Minimal) EchoOptsInline(opts struct { Msg string Suffix Optional[string] Times Optional[int] }) string { return m.EchoOpts(opts.Msg, opts.Suffix, opts.Times) } func (m *Minimal) EchoOptsInlinePointer(opts *struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,162
Go SDK Modules: enable general type annotation support via comments
Discord discussion: https://discord.com/channels/707636530424053791/1177373379255349248 As we need to add more support in Go for things like marking a field as private, setting default values, etc. The most obvious option was to require use of structs (including the `Opts` struct idea, the "inline anonymous struct for args", etc.) and annotate more information via struct tags. However, after discussion we realized a better general solution would be to not rely on struct tags but instead add support for the equivalent functionality via specially formatted comments. The reasoning being that: 1. Struct tags are essentially just glorified comments (strings that get interpreted by reflection/ast parsing), so there's not much of a practical difference in that respect 2. Comments are more general in that they can be applied equivalently not only to fields of a struct but also to function args (similar to how we support doc strings on args today), functions as a whole, structs as a whole, etc. There's prior art for this: 1. Go's support for pragmas: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas 2. K8s support for annotations: https://github.com/kubernetes-sigs/controller-tools/blob/881ffb4682cb5882f5764aca5a56fe9865bc9ed6/pkg/crd/testdata/cronjob_types.go#L105-L125 TBD the exact format of comments (i.e. use of a special prefix `//dagger: default=abc` vs something simpler like `//+default abc`). We should use this to support at least: 1. Optional (can co-exist w/ existing `Optional` type) 2. Default values (will be limited to what can be represented as a string, but that's ok) 3. Marking object fields as private (so not included in public API but still included in serialization of object) cc @vito @jedevc
https://github.com/dagger/dagger/issues/6162
https://github.com/dagger/dagger/pull/6179
e8097f5798af7f8b22f2a1be94a27c9800185053
a499195df3de436969c4477bb1e9f074aa586eb6
2023-11-27T16:51:18Z
go
2023-12-06T14:29:35Z
core/integration/testdata/modules/go/minimal/main.go
Msg string Suffix Optional[string] Times Optional[int] }) string { return m.EchoOptsInline(*opts) } func (m *Minimal) EchoOptsInlineCtx(ctx context.Context, opts struct { Msg string Suffix Optional[string] Times Optional[int] }) string { return m.EchoOpts(opts.Msg, opts.Suffix, opts.Times) } func (m *Minimal) EchoOptsInlineTags(ctx context.Context, opts struct { Msg string Suffix Optional[string] `tag:"hello"` Times Optional[int] `tag:"hello again"` }) string { return m.EchoOpts(opts.Msg, opts.Suffix, opts.Times) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
package core import ( "context" "fmt" "strings" "testing" "dagger.io/dagger" "github.com/moby/buildkit/identity" "github.com/stretchr/testify/require" "github.com/tidwall/gjson" ) const cliBinPath = "/.dagger-cli" func getDevEngineForRemoteCache(ctx context.Context, c *dagger.Client, cache *dagger.Service, cacheName string, index uint8) (devEngineSvc *dagger.Service, endpoint string, err error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
id := identity.NewID() networkCIDR := fmt.Sprintf("10.%d.0.0/16", 100+index) devEngineSvc = devEngineContainer(c). WithServiceBinding(cacheName, cache). WithExposedPort(1234, dagger.ContainerWithExposedPortOpts{Protocol: dagger.Tcp}). WithEnvVariable("ENGINE_ID", id). WithMountedCache("/var/lib/dagger", c.CacheVolume("dagger-dev-engine-state-"+identity.NewID())). WithExec([]string{ "--network-name", fmt.Sprintf("remotecache%d", index), "--network-cidr", networkCIDR, }, dagger.ContainerWithExecOpts{ InsecureRootCapabilities: true, }). AsService() endpoint, err = devEngineSvc.Endpoint(ctx, dagger.ServiceEndpointOpts{ Port: 1234, Scheme: "tcp", }) return devEngineSvc, endpoint, err } func TestRemoteCacheRegistry(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
t.Parallel() c, ctx := connect(t) registry := c.Pipeline("registry").Container().From("registry:2"). WithMountedCache("/var/lib/registry/", c.CacheVolume("remote-cache-registry-"+identity.NewID())). WithExposedPort(5000, dagger.ContainerWithExposedPortOpts{Protocol: dagger.Tcp}). AsService() cacheEnv := "type=registry,ref=registry:5000/test-cache,mode=max" devEngineA, endpointA, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 0) require.NoError(t, err) daggerCli := daggerCliFile(t, c)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
outputA, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineA). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointA). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", cacheEnv). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx) require.NoError(t, err) shaA := strings.TrimSpace(gjson.Get(outputA, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaA, "shaA is empty") devEngineB, endpointB, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 1) require.NoError(t, err) outputB, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineB). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointB).
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", cacheEnv). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + " query --doc .dagger-query.txt", }).Stdout(ctx) require.NoError(t, err) shaB := strings.TrimSpace(gjson.Get(outputB, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaB, "shaB is empty") require.Equal(t, shaA, shaB) } /* Regression test for https://github.com/dagger/dagger/pull/5885 Idea is to: 1. Load in a local dir, use it to force evaluation 2. Export remote cache for the load 3. Load exact same local dir in a new engine that imports the cache 4. Make sure that works and there's no errors about lazy blobs missing The linked PR description above has more details. */ func TestRemoteCacheLazyBlobs(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
t.Parallel() c, ctx := connect(t) registry := c.Pipeline("registry").Container().From("registry:2"). WithMountedCache("/var/lib/registry/", c.CacheVolume("remote-cache-registry-"+identity.NewID())). WithExposedPort(5000, dagger.ContainerWithExposedPortOpts{Protocol: dagger.Tcp}). AsService() cacheEnv := "type=registry,ref=registry:5000/test-cache,mode=max" devEngineA, endpointA, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 10) require.NoError(t, err) daggerCli := daggerCliFile(t, c) outputA, err := c.Container().From(alpineImage). WithDirectory("/foo", c.Directory().WithDirectory("bar", c.Directory().WithNewFile("baz", "blah")).WithTimestamps(0)). WithServiceBinding("dev-engine", devEngineA). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointA). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", cacheEnv). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ host { directory(path: "/foo/bar") { entries } }
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
}`, }). WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx) require.NoErrorf(t, err, "outputA: %s", outputA) devEngineB, endpointB, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 11) require.NoError(t, err) outputB, err := c.Container().From(alpineImage). WithDirectory("/foo", c.Directory().WithDirectory("bar", c.Directory().WithNewFile("baz", "blah")).WithTimestamps(0)). WithServiceBinding("dev-engine", devEngineB). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointB). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", cacheEnv). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ host { directory(path: "/foo/bar") { entries } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + " query --doc .dagger-query.txt", }).Stdout(ctx) require.NoErrorf(t, err, "outputB: %s", outputB) } func TestRemoteCacheS3(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
t.Parallel() t.Run("buildkit s3 caching", func(t *testing.T) { c, ctx := connect(t) bucket := "dagger-test-remote-cache-s3-" + identity.NewID() s3 := c.Pipeline("s3").Container().From("minio/minio"). WithMountedCache("/data", c.CacheVolume("minio-cache")). WithExposedPort(9000, dagger.ContainerWithExposedPortOpts{Protocol: dagger.Tcp}). WithExec([]string{"server", "/data"}). AsService() s3Endpoint, err := s3.Endpoint(ctx, dagger.ServiceEndpointOpts{Port: 9000, Scheme: "http"}) require.NoError(t, err) minioStdout, err := c.Container().From("minio/mc"). WithServiceBinding("s3", s3). WithEntrypoint([]string{"sh"}). WithExec([]string{"-c", "mc alias set minio http://s3:9000 minioadmin minioadmin && mc mb minio/" + bucket}). Stdout(ctx) require.NoError(t, err) require.Contains(t, minioStdout, "Bucket created successfully") s3Env := "type=s3,mode=max,endpoint_url=" + s3Endpoint + ",access_key_id=minioadmin,secret_access_key=minioadmin,region=mars,use_path_style=true,bucket=" + bucket devEngineA, endpointA, err := getDevEngineForRemoteCache(ctx, c, s3, "s3", 0) require.NoError(t, err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
daggerCli := c.Host().Directory("/dagger-dev/", dagger.HostDirectoryOpts{Include: []string{"dagger"}}).File("dagger") outputA, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineA). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointA). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", s3Env). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx) require.NoError(t, err) shaA := strings.TrimSpace(gjson.Get(outputA, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaA, "shaA is empty") devEngineB, endpointB, err := getDevEngineForRemoteCache(ctx, c, s3, "s3", 1) require.NoError(t, err) outputB, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineB). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath).
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointB). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", s3Env). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + " query --doc .dagger-query.txt", }).Stdout(ctx) require.NoError(t, err) shaB := strings.TrimSpace(gjson.Get(outputB, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaB, "shaB is empty") require.Equal(t, shaA, shaB) }) } func TestRemoteCacheRegistryMultipleConfigs(t *testing.T) { t.Parallel() c, ctx := connect(t) defer c.Close() registry := c.Pipeline("registry").Container().From("registry:2"). WithMountedCache("/var/lib/registry/", c.CacheVolume("remote-cache-registry-"+identity.NewID())). WithExposedPort(5000, dagger.ContainerWithExposedPortOpts{Protocol: dagger.Tcp}). AsService()
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
cacheConfigEnv1 := "type=registry,ref=registry:5000/test-cache:latest,mode=max" cacheConfigEnv2 := "type=registry,ref=registry:5000/test-cache-b:latest,mode=max" cacheEnv := strings.Join([]string{cacheConfigEnv1, cacheConfigEnv2}, ";") devEngineA, endpointA, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 20) require.NoError(t, err) daggerCli := daggerCliFile(t, c) outputA, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineA). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointA). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", cacheEnv). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx) require.NoError(t, err) shaA := strings.TrimSpace(gjson.Get(outputA, "container.from.withExec.stdout").String())
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
require.NotEmpty(t, shaA, "shaA is empty") devEngineB, endpointB, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 21) require.NoError(t, err) outputB, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineB). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointB). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", cacheConfigEnv1). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + " query --doc .dagger-query.txt", }).Stdout(ctx) require.NoError(t, err) shaB := strings.TrimSpace(gjson.Get(outputB, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaB, "shaB is empty") require.Equal(t, shaA, shaB) devEngineC, endpointC, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 22) require.NoError(t, err) outputC, err := c.Container().From(alpineImage).
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
WithServiceBinding("dev-engine", devEngineC). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointC). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_CONFIG", cacheConfigEnv2). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + " query --doc .dagger-query.txt", }).Stdout(ctx) require.NoError(t, err) shaC := strings.TrimSpace(gjson.Get(outputC, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaC, "shaC is empty") require.Equal(t, shaA, shaC) } func TestRemoteCacheRegistrySeparateImportExport(t *testing.T) { t.Parallel() c, ctx := connect(t) defer c.Close() registry := c.Pipeline("registry").Container().From("registry:2"). WithMountedCache("/var/lib/registry/", c.CacheVolume("remote-cache-registry-"+identity.NewID())).
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
WithExposedPort(5000, dagger.ContainerWithExposedPortOpts{Protocol: dagger.Tcp}). AsService() daggerCli := daggerCliFile(t, c) cacheEnvA := "type=registry,ref=registry:5000/test-cache-a:latest,mode=max" cacheEnvB := "type=registry,ref=registry:5000/test-cache-b:latest,mode=max" cacheEnvC := "type=registry,ref=registry:5000/test-cache-c:latest,mode=max" devEngineA, endpointA, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 0) require.NoError(t, err) outputA, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineA). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointA). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_EXPORT_CONFIG", cacheEnvA). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "echo A >/dev/null; head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
require.NoError(t, err) shaA := strings.TrimSpace(gjson.Get(outputA, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaA, "shaA is empty") devEngineB, endpointB, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 1) require.NoError(t, err) outputB, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineB). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointB). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_EXPORT_CONFIG", cacheEnvB). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { withExec(args: ["sh", "-c", "echo B >/dev/null; head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx) require.NoError(t, err) shaB := strings.TrimSpace(gjson.Get(outputB, "container.from.withExec.stdout").String()) require.NotEmpty(t, shaB, "shaB is empty") devEngineC, endpointC, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 2) require.NoError(t, err)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
ctrC := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineC). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointC). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_IMPORT_CONFIG", strings.Join([]string{cacheEnvA, cacheEnvB}, ";")). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_EXPORT_CONFIG", cacheEnvC) outputC, err := ctrC.WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { outputA: withExec(args: ["sh", "-c", "echo A >/dev/null; head -c 128 /dev/random | sha256sum"]) { stdout } outputB: withExec(args: ["sh", "-c", "echo B >/dev/null; head -c 128 /dev/random | sha256sum"]) { stdout } outputC: withExec(args: ["sh", "-c", "echo C >/dev/null; head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }).WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx) require.NoError(t, err) newA := strings.TrimSpace(gjson.Get(outputC, "container.from.outputA.stdout").String()) require.Equal(t, shaA, newA) newB := strings.TrimSpace(gjson.Get(outputC, "container.from.outputB.stdout").String())
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
core/integration/remotecache_test.go
require.Equal(t, shaB, newB) shaC := strings.TrimSpace(gjson.Get(outputC, "container.from.outputC.stdout").String()) require.NotEmpty(t, shaC, "shaC is empty") devEngineD, endpointD, err := getDevEngineForRemoteCache(ctx, c, registry, "registry", 3) require.NoError(t, err) outputD, err := c.Container().From(alpineImage). WithServiceBinding("dev-engine", devEngineD). WithMountedFile(cliBinPath, daggerCli). WithEnvVariable("_EXPERIMENTAL_DAGGER_CLI_BIN", cliBinPath). WithEnvVariable("_EXPERIMENTAL_DAGGER_RUNNER_HOST", endpointD). WithEnvVariable("_EXPERIMENTAL_DAGGER_CACHE_IMPORT_CONFIG", cacheEnvC). WithNewFile("/.dagger-query.txt", dagger.ContainerWithNewFileOpts{ Contents: `{ container { from(address: "` + alpineImage + `") { outputC: withExec(args: ["sh", "-c", "echo C >/dev/null; head -c 128 /dev/random | sha256sum"]) { stdout } } } }`, }). WithExec([]string{ "sh", "-c", cliBinPath + ` query --doc .dagger-query.txt`, }).Stdout(ctx) require.NoError(t, err) newC := strings.TrimSpace(gjson.Get(outputD, "container.from.outputC.stdout").String()) require.Equal(t, shaC, newC) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
package buildkit import ( "bytes" "context" "errors" "fmt" "io" "os" "path" "path/filepath" "strings" "github.com/containerd/continuity/fs" "github.com/dagger/dagger/engine" "github.com/dagger/dagger/engine/sources/blob" cacheconfig "github.com/moby/buildkit/cache/config" bkclient "github.com/moby/buildkit/client" "github.com/moby/buildkit/client/llb" bkgw "github.com/moby/buildkit/frontend/gateway/client" "github.com/moby/buildkit/session/filesync" "github.com/moby/buildkit/snapshot" bksolverpb "github.com/moby/buildkit/solver/pb" "github.com/moby/buildkit/util/bklog" "github.com/moby/buildkit/util/compression" bkworker "github.com/moby/buildkit/worker" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/vito/progrock" )
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
func (c *Client) LocalImport( ctx context.Context, recorder *progrock.Recorder, platform specs.Platform, srcPath string, excludePatterns []string, includePatterns []string, ) (*bksolverpb.Definition, error) { srcPath = path.Clean(srcPath) if srcPath == ".." || strings.HasPrefix(srcPath, "../") { return nil, fmt.Errorf("path %q escapes workdir; use an absolute path instead", srcPath) } clientMetadata, err := engine.ClientMetadataFromContext(ctx) if err != nil { return nil, err } localOpts := []llb.LocalOption{ llb.SessionID(clientMetadata.ClientID), llb.SharedKeyHint(strings.Join([]string{clientMetadata.ClientHostname, srcPath}, " ")), } localName := fmt.Sprintf("upload %s from %s (client id: %s)", srcPath, clientMetadata.ClientHostname, clientMetadata.ClientID) if len(excludePatterns) > 0 { localName += fmt.Sprintf(" (exclude: %s)", strings.Join(excludePatterns, ", ")) localOpts = append(localOpts, llb.ExcludePatterns(excludePatterns)) } if len(includePatterns) > 0 { localName += fmt.Sprintf(" (include: %s)", strings.Join(includePatterns, ", ")) localOpts = append(localOpts, llb.IncludePatterns(includePatterns)) } localOpts = append(localOpts, llb.WithCustomName(localName))
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
localLLB := llb.Local(srcPath, localOpts...) copyLLB := llb.Scratch().File( llb.Copy(localLLB, "/", "/"), llb.WithCustomNamef(localName), ) copyDef, err := copyLLB.Marshal(ctx, llb.Platform(platform)) if err != nil { return nil, err } copyPB := copyDef.ToPB() RecordVertexes(recorder, copyPB) res, err := c.Solve(ctx, bkgw.SolveRequest{ Definition: copyPB, Evaluate: true, }) if err != nil { return nil, err } resultProxy, err := res.SingleRef() if err != nil { return nil, fmt.Errorf("failed to get single ref: %s", err) } cachedRes, err := resultProxy.Result(ctx) if err != nil { return nil, wrapError(ctx, err, c.ID()) } workerRef, ok := cachedRes.Sys().(*bkworker.WorkerRef) if !ok {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
return nil, fmt.Errorf("invalid ref: %T", cachedRes.Sys()) } ref := workerRef.ImmutableRef err = ref.Extract(ctx, nil) if err != nil { return nil, fmt.Errorf("failed to extract ref: %s", err) } remotes, err := ref.GetRemotes(ctx, true, cacheconfig.RefConfig{ Compression: compression.Config{ Type: compression.Zstd, }, }, false, nil) if err != nil { return nil, fmt.Errorf("failed to get remotes: %s", err) } if len(remotes) != 1 { return nil, fmt.Errorf("expected 1 remote, got %d", len(remotes)) } remote := remotes[0] if len(remote.Descriptors) != 1 { return nil, fmt.Errorf("expected 1 descriptor, got %d", len(remote.Descriptors))
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
} desc := remote.Descriptors[0] blobDef, err := blob.LLB(desc).Marshal(ctx) if err != nil { return nil, fmt.Errorf("failed to marshal blob source: %s", err) } blobPB := blobDef.ToPB() _, err = c.Solve(ctx, bkgw.SolveRequest{ Definition: blobPB, Evaluate: true, }) if err != nil { return nil, fmt.Errorf("failed to solve blobsource: %w", wrapError(ctx, err, c.ID())) } return blobPB, nil } func (c *Client) EngineContainerLocalImport( ctx context.Context, recorder *progrock.Recorder, platform specs.Platform, srcPath string, excludePatterns []string, includePatterns []string, ) (*bksolverpb.Definition, error) { hostname, err := os.Hostname() if err != nil { return nil, fmt.Errorf("failed to get hostname for engine local import: %s", err) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
ctx = engine.ContextWithClientMetadata(ctx, &engine.ClientMetadata{ ClientID: c.ID(), ClientHostname: hostname, }) return c.LocalImport(ctx, recorder, platform, srcPath, excludePatterns, includePatterns) } func (c *Client) ReadCallerHostFile(ctx context.Context, path string) ([]byte, error) { ctx, cancel, err := c.withClientCloseCancel(ctx) if err != nil { return nil, err } defer cancel() clientMetadata, err := engine.ClientMetadataFromContext(ctx) if err != nil { return nil, fmt.Errorf("failed to get requester session ID: %s", err) } ctx = engine.LocalImportOpts{ OwnerClientID: clientMetadata.ClientID, Path: path, ReadSingleFileOnly: true, MaxFileSize: MaxFileContentsChunkSize, }.AppendToOutgoingContext(ctx) clientCaller, err := c.SessionManager.Get(ctx, clientMetadata.ClientID, false) if err != nil { return nil, fmt.Errorf("failed to get requester session: %s", err) } diffCopyClient, err := filesync.NewFileSyncClient(clientCaller.Conn()).DiffCopy(ctx) if err != nil { return nil, fmt.Errorf("failed to create diff copy client: %s", err) }
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
defer diffCopyClient.CloseSend() msg := filesync.BytesMessage{} err = diffCopyClient.RecvMsg(&msg) if err != nil { return nil, fmt.Errorf("failed to receive file bytes message: %s", err) } return msg.Data, nil } func (c *Client) LocalDirExport( ctx context.Context, def *bksolverpb.Definition, destPath string, ) (rerr error) { ctx = bklog.WithLogger(ctx, bklog.G(ctx).WithField("export_path", destPath)) bklog.G(ctx).Debug("exporting local dir") defer func() { lg := bklog.G(ctx) if rerr != nil { lg = lg.WithError(rerr) } lg.Debug("finished exporting local dir") }() ctx, cancel, err := c.withClientCloseCancel(ctx) if err != nil { return err } defer cancel() destPath = path.Clean(destPath) if destPath == ".." || strings.HasPrefix(destPath, "../") { return fmt.Errorf("path %q escapes workdir; use an absolute path instead", destPath)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
} res, err := c.Solve(ctx, bkgw.SolveRequest{Definition: def}) if err != nil { return fmt.Errorf("failed to solve for local export: %s", err) } cacheRes, err := ConvertToWorkerCacheResult(ctx, res) if err != nil { return fmt.Errorf("failed to convert result: %s", err) } exporter, err := c.Worker.Exporter(bkclient.ExporterLocal, c.SessionManager) if err != nil { return err } expInstance, err := exporter.Resolve(ctx, nil) if err != nil { return fmt.Errorf("failed to resolve exporter: %s", err) } clientMetadata, err := engine.ClientMetadataFromContext(ctx) if err != nil { return fmt.Errorf("failed to get requester session ID: %s", err) } ctx = engine.LocalExportOpts{ DestClientID: clientMetadata.ClientID, Path: destPath, }.AppendToOutgoingContext(ctx) _, descRef, err := expInstance.Export(ctx, cacheRes, clientMetadata.ClientID) if err != nil { return fmt.Errorf("failed to export: %s", err) } if descRef != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
descRef.Release() } return nil } func (c *Client) LocalFileExport( ctx context.Context, def *bksolverpb.Definition, destPath string, filePath string, allowParentDirPath bool, ) (rerr error) { ctx = bklog.WithLogger(ctx, bklog.G(ctx). WithField("export_path", destPath). WithField("file_path", filePath). WithField("allow_parent_dir_path", allowParentDirPath), ) bklog.G(ctx).Debug("exporting local file") defer func() { lg := bklog.G(ctx) if rerr != nil { lg = lg.WithError(rerr) } lg.Debug("finished exporting local file") }() ctx, cancel, err := c.withClientCloseCancel(ctx) if err != nil { return err } defer cancel() destPath = path.Clean(destPath)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
if destPath == ".." || strings.HasPrefix(destPath, "../") { return fmt.Errorf("path %q escapes workdir; use an absolute path instead", destPath) } res, err := c.Solve(ctx, bkgw.SolveRequest{Definition: def, Evaluate: true}) if err != nil { return fmt.Errorf("failed to solve for local export: %s", err) } ref, err := res.SingleRef() if err != nil { return fmt.Errorf("failed to get single ref: %s", err) } mountable, err := ref.getMountable(ctx) if err != nil { return fmt.Errorf("failed to get mountable: %s", err) } mounter := snapshot.LocalMounter(mountable) mountPath, err := mounter.Mount() if err != nil { return fmt.Errorf("failed to mount: %s", err) } defer mounter.Unmount() mntFilePath, err := fs.RootPath(mountPath, filePath) if err != nil { return fmt.Errorf("failed to get root path: %s", err) } file, err := os.Open(mntFilePath) if err != nil { return fmt.Errorf("failed to open file: %s", err) } defer file.Close()
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
stat, err := file.Stat() if err != nil { return fmt.Errorf("failed to stat file: %s", err) } clientMetadata, err := engine.ClientMetadataFromContext(ctx) if err != nil { return fmt.Errorf("failed to get requester session ID: %s", err) } ctx = engine.LocalExportOpts{ DestClientID: clientMetadata.ClientID, Path: destPath, IsFileStream: true, FileOriginalName: filepath.Base(filePath), AllowParentDirPath: allowParentDirPath, FileMode: stat.Mode().Perm(), }.AppendToOutgoingContext(ctx) clientCaller, err := c.SessionManager.Get(ctx, clientMetadata.ClientID, false) if err != nil { return fmt.Errorf("failed to get requester session: %s", err) } diffCopyClient, err := filesync.NewFileSendClient(clientCaller.Conn()).DiffCopy(ctx) if err != nil { return fmt.Errorf("failed to create diff copy client: %s", err) } defer diffCopyClient.CloseSend() fileSizeLeft := stat.Size() chunkSize := int64(MaxFileContentsChunkSize) for fileSizeLeft > 0 { buf := new(bytes.Buffer) n, err := io.CopyN(buf, file, chunkSize)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
if errors.Is(err, io.EOF) { err = nil } if err != nil { return fmt.Errorf("failed to read file: %s", err) } fileSizeLeft -= n err = diffCopyClient.SendMsg(&filesync.BytesMessage{Data: buf.Bytes()}) if errors.Is(err, io.EOF) { err := diffCopyClient.RecvMsg(struct{}{}) if err != nil { return fmt.Errorf("diff copy client error: %s", err) } } else if err != nil { return fmt.Errorf("failed to send file chunk: %s", err) } } if err := diffCopyClient.CloseSend(); err != nil { return fmt.Errorf("failed to close send: %s", err) } var msg filesync.BytesMessage if err := diffCopyClient.RecvMsg(&msg); err != io.EOF { return fmt.Errorf("unexpected closing recv msg: %s", err) } return nil } func (c *Client) IOReaderExport(ctx context.Context, r io.Reader, destPath string, destMode os.FileMode) (rerr error) { ctx = bklog.WithLogger(ctx, bklog.G(ctx).WithField("export_path", destPath)) bklog.G(ctx).Debug("exporting bytes")
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
defer func() { lg := bklog.G(ctx) if rerr != nil { lg = lg.WithError(rerr) } lg.Debug("finished exporting bytes") }() clientMetadata, err := engine.ClientMetadataFromContext(ctx) if err != nil { return fmt.Errorf("failed to get requester session ID: %s", err) } ctx = engine.LocalExportOpts{ DestClientID: clientMetadata.ClientID, Path: destPath, IsFileStream: true, FileOriginalName: filepath.Base(destPath), FileMode: destMode, }.AppendToOutgoingContext(ctx) clientCaller, err := c.SessionManager.Get(ctx, clientMetadata.ClientID, false) if err != nil { return fmt.Errorf("failed to get requester session: %s", err) } diffCopyClient, err := filesync.NewFileSendClient(clientCaller.Conn()).DiffCopy(ctx) if err != nil { return fmt.Errorf("failed to create diff copy client: %s", err) } defer diffCopyClient.CloseSend() chunkSize := int64(MaxFileContentsChunkSize) keepGoing := true for keepGoing {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/buildkit/filesync.go
buf := new(bytes.Buffer) _, err := io.CopyN(buf, r, chunkSize) if errors.Is(err, io.EOF) { keepGoing = false err = nil } if err != nil { return fmt.Errorf("failed to read file: %s", err) } err = diffCopyClient.SendMsg(&filesync.BytesMessage{Data: buf.Bytes()}) if errors.Is(err, io.EOF) { err := diffCopyClient.RecvMsg(struct{}{}) if err != nil { return fmt.Errorf("diff copy client error: %s", err) } } else if err != nil { return fmt.Errorf("failed to send file chunk: %s", err) } } if err := diffCopyClient.CloseSend(); err != nil { return fmt.Errorf("failed to close send: %s", err) } var msg filesync.BytesMessage if err := diffCopyClient.RecvMsg(&msg); err != io.EOF { return fmt.Errorf("unexpected closing recv msg: %s", err) } return nil }
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/sources/blob/blobsource.go
package blob import ( "context" "errors" "fmt" "strconv" "strings" "github.com/moby/buildkit/cache" "github.com/moby/buildkit/client/llb" "github.com/moby/buildkit/session" "github.com/moby/buildkit/solver" "github.com/moby/buildkit/solver/llbsolver/provenance" "github.com/moby/buildkit/solver/pb" "github.com/moby/buildkit/source" "github.com/opencontainers/go-digest" ocispecs "github.com/opencontainers/image-spec/specs-go/v1" ) const ( BlobScheme = "blob" MediaTypeAttr = "daggerBlobSourceMediaType" SizeAttr = "daggerBlobSourceSize" ) type Opt struct {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/sources/blob/blobsource.go
CacheAccessor cache.Accessor } type blobSource struct { cache cache.Accessor } type SourceIdentifier struct { ocispecs.Descriptor } func (SourceIdentifier) Scheme() string { return BlobScheme } func (id SourceIdentifier) Capture(*provenance.Capture, string) error { return nil } func LLB(desc ocispecs.Descriptor) llb.State { attrs := map[string]string{ MediaTypeAttr: desc.MediaType, SizeAttr: strconv.Itoa(int(desc.Size)), } for k, v := range desc.Annotations { attrs[k] = v } return llb.NewState(llb.NewSource( fmt.Sprintf("%s://%s", BlobScheme, desc.Digest.String()), attrs, llb.Constraints{}, ).Output()) } func IdentifierFromPB(op *pb.SourceOp) (*SourceIdentifier, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/sources/blob/blobsource.go
scheme, ref, ok := strings.Cut(op.Identifier, "://") if !ok { return nil, fmt.Errorf("invalid blob source identifier %q", op.Identifier) } bs := &blobSource{} return bs.identifier(scheme, ref, op.GetAttrs(), nil) } func NewSource(opt Opt) (source.Source, error) { bs := &blobSource{ cache: opt.CacheAccessor, } return bs, nil } func (bs *blobSource) Schemes() []string { return []string{BlobScheme} } func (bs *blobSource) Identifier(scheme, ref string, sourceAttrs map[string]string, p *pb.Platform) (source.Identifier, error) { return bs.identifier(scheme, ref, sourceAttrs, p) } func (bs *blobSource) identifier(scheme, ref string, sourceAttrs map[string]string, _ *pb.Platform) (*SourceIdentifier, error) { desc := ocispecs.Descriptor{ Digest: digest.Digest(ref), Annotations: map[string]string{}, } for k, v := range sourceAttrs { switch k { case MediaTypeAttr: desc.MediaType = v case SizeAttr: blobSize, err := strconv.Atoi(v)
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/sources/blob/blobsource.go
if err != nil { return nil, fmt.Errorf("invalid blob size %q: %w", v, err) } desc.Size = int64(blobSize) default: desc.Annotations[k] = v } } return &SourceIdentifier{desc}, nil } func (bs *blobSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager, _ solver.Vertex) (source.SourceInstance, error) { blobIdentifier, ok := id.(*SourceIdentifier) if !ok { return nil, fmt.Errorf("invalid blob identifier %v", id) } return &blobSourceInstance{ id: blobIdentifier, sm: sm, blobSource: bs, }, nil } type blobSourceInstance struct { id *SourceIdentifier sm *session.Manager *blobSource } func (bs *blobSourceInstance) CacheKey(context.Context, session.Group, int) (string, string, solver.CacheOpts, bool, error) { return "session:" + bs.id.Digest.String(), bs.id.Digest.String(), nil, true, nil } func (bs *blobSourceInstance) Snapshot(ctx context.Context, _ session.Group) (cache.ImmutableRef, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
6,163
๐Ÿž WithMountedDirectory invalidating remote cache
### What is the issue? Given the following pipeline: ```go func main() { // initialize Dagger client ctx := context.Background() client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { panic(err) } defer client.Close() src := client.Host().Directory(".", dagger.HostDirectoryOpts{ Include: []string{"bar"}, }) mountCache := client.Host().Directory("mount") _, err = client.Container(). From("alpine"). WithWorkdir("/root"). WithExec([]string{"apk", "add", "curl"}). WithMountedDirectory("/mount", mountCache). WithDirectory(".", src). WithExec([]string{"cat", "bar"}). Sync(ctx) if err != nil { panic(err) } } ``` Running that twice in my local setup, correctly caches all operations: ``` 130|marcos:tmp/test (โŽˆ |N/A)$ dagger run go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [1.28s] connect โ”‚ โ”ฃ [1.11s] starting engine โ”‚ โ”ฃ [0.17s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [1.36s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory mount โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ”ฃ [0.00s] transferring mount: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory . โ”‚ โ”‚ โ–ˆ [0.01s] upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ”‚ โ”ฃ [0.00s] transferring .: โ”‚ โ–ˆ โ”‚ CACHED upload mount from xps (client id: nf66pihk4bujhmj9nw5jrpzps) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ CACHED upload . from xps (client id: nf66pihk4bujhmj9nw5jrpzps) (include: bar) โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [1.11s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ•ฏ โ”‚ CACHED copy / /root โ–ˆโ—€โ”€โ”€โ”€โ”€โ•ฏ CACHED exec cat bar ``` When using magicache, for some reason the last `exec cat bar` operation doesn't seem to be cached at all: **output from a newly spawned engine** (local cache is empty): ``` โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ init โ”‚ โ–ˆ [19.56s] connect โ”‚ โ”ฃ [19.42s] starting engine โ”‚ โ”ฃ [0.14s] starting session โ”‚ โ”ƒ OK! โ”‚ โ”ป โ–ˆ [5.60s] go run main.go โ”ฃโ”€โ•ฎ โ”‚ โ–ฝ host.directory . โ”‚ โ–ˆ [0.04s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ [0.00s] transferring .: โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ–ฝ host.directory mount โ”‚ โ”‚ โ–ˆ [0.04s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.00s] transferring mount: โ”‚ โ–ˆ โ”‚ [0.01s] upload . from xps (client id: fvl7ohtwyhom301qxtt817rpg) (include: bar) โ”‚ โ”ฃ โ”‚ [0.43s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃ โ”‚ [0.01s] extracting sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”‚ โ–ˆ [0.01s] upload mount from xps (client id: fvl7ohtwyhom301qxtt817rpg) โ”‚ โ”‚ โ”ฃ [0.82s] โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ฃ [0.01s] extracting sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ blob://sha256:f4314233344fbbc7c171c06d5cace46282b4ee97b153ed06e0aa21ce6de98ae1 โ”‚ โ”ป โ”‚ โ”‚ โ”‚ โ–ˆ โ”‚ [0.00s] blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ•ญโ”€โ”ซ โ”‚ blob://sha256:afad735041289d8662a90d002343ddac7dfdeca7ebb85fd3b1a786ff1a02183c โ”‚ โ”‚ โ”ป โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ โ”‚ โ”‚ โ”‚ โ–ฝ โ”‚ from alpine โ”‚ โ”‚ โ–ˆ โ”‚ [2.12s] resolve image config for docker.io/library/alpine:latest โ”‚ โ”‚ โ–ˆ โ”‚ [0.01s] pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ฃ โ”‚ [0.01s] resolve docker.io/library/alpine@sha256:eece025e432126ce23f223450a0326fbebde39cdf496a85d8c016293fc851978 โ”‚ โ”‚ โ”ฃโ”€โ”ผโ”€โ•ฎ pull docker.io/library/alpine:latest โ”‚ โ”‚ โ”ป โ”‚ โ”‚ โ–ˆโ—€โ”ผโ”€โ”€โ”€โ”ผโ”€โ•ฏ CACHED exec apk add curl โ–ˆโ—€โ”ผโ”€โ”€โ”€โ•ฏ CACHED copy / /root โ–ˆโ—€โ•ฏ [0.30s] exec cat bar โ”ƒ bar โ”ป ``` ^ as you can see `exec cat bar` is not cached. If I check Dagger cloud, it also shows the same: ![image](https://github.com/dagger/dagger/assets/1578458/19367313-329b-4b46-8e84-6a8212109a2e) Looking a bit in-depth looks like there seems to be a `merge` op which is not cached when using magicache ![image](https://github.com/dagger/dagger/assets/1578458/35a9f9a2-6817-45ee-9abf-506243509078) Dagger cloud URL: https://dagger.cloud/runs/058cf603-4334-4b85-8fd2-80483e379df2 cc @RonanQuigley ### Log output N/A ### Steps to reproduce N/A ### SDK version Go SDK 0.9.3 ### OS version linux
https://github.com/dagger/dagger/issues/6163
https://github.com/dagger/dagger/pull/6211
099f2aebb0b486b6f584de1074f4ff1521541b07
a789dbe3747ad3cef142102447194d3e59f9ed7f
2023-11-27T18:54:01Z
go
2023-12-06T17:02:45Z
engine/sources/blob/blobsource.go
opts := []cache.RefOption{ cache.WithDescription(fmt.Sprintf("dagger blob source for %s", bs.id.Digest)), } ref, err := bs.cache.GetByBlob(ctx, bs.id.Descriptor, nil, opts...) var needsRemoteProviders cache.NeedsRemoteProviderError if errors.As(err, &needsRemoteProviders) { if optGetter := solver.CacheOptGetterOf(ctx); optGetter != nil { var keys []interface{} for _, dgst := range needsRemoteProviders { keys = append(keys, cache.DescHandlerKey(dgst)) } descHandlers := cache.DescHandlers(make(map[digest.Digest]*cache.DescHandler)) for k, v := range optGetter(true, keys...) { if key, ok := k.(cache.DescHandlerKey); ok { if handler, ok := v.(*cache.DescHandler); ok { descHandlers[digest.Digest(key)] = handler } } } opts = append(opts, descHandlers) ref, err = bs.cache.GetByBlob(ctx, bs.id.Descriptor, nil, opts...) } } if err != nil { return nil, fmt.Errorf("failed to load ref for blob snapshot: %w", err) } return ref, nil }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
package templates import ( "encoding/json" "fmt" "go/ast" "go/token" "go/types" "maps" "os" "path/filepath" "reflect" "regexp" "runtime/debug" "sort" "strconv" "strings" . "github.com/dave/jennifer/jen" "github.com/iancoleman/strcase" "golang.org/x/tools/go/packages" ) const ( daggerGenFilename = "dagger.gen.go" contextTypename = "context.Context" constructorFuncName = "New" ) /*
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
moduleMainSrc generates the source code of the main func for Dagger Module code using the Go SDK. The overall idea is that users just need to create a struct with the same name as their Module and then add methods to that struct to implement their Module. Methods on that struct become Functions. They are also free to return custom objects from Functions, which themselves may have methods that become Functions too. However, only the "top-level" Module struct's Functions will be directly invokable. This is essentially just the GraphQL execution model. The implementation works by parsing the user's code and generating a main func that reads function call inputs from the Engine, calls the relevant function and returns the result. The generated code is mostly a giant switch/case on the object+function name, with each case doing json deserialization of the input arguments and calling the actual Go function. */ func (funcs goTemplateFuncs) moduleMainSrc() (string, error) { defer func() { if r := recover(); r != nil { fmt.Fprintf(os.Stderr, "internal error during module code generation: %v\n", r) debug.PrintStack() panic(r) } }() if funcs.modulePkg == nil { return `func main() { panic("no code yet") }`, nil } ps := &parseState{ pkg: funcs.modulePkg, fset: funcs.moduleFset,
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
methods: make(map[string][]method), moduleName: funcs.module.Name, } pkgScope := funcs.modulePkg.Types.Scope() objFunctionCases := map[string][]Code{} createMod := Qual("dag", "CurrentModule").Call() objs := []types.Object{} for _, name := range pkgScope.Names() { obj := pkgScope.Lookup(name) if obj == nil { continue } objs = append(objs, obj) } sort.Slice(objs, func(i, j int) bool { return objs[i].Pos() < objs[j].Pos() }) tps := []types.Type{} for _, obj := range objs { fn, isFn := obj.(*types.Func) if isFn && fn.Name() == constructorFuncName { ps.constructor = fn continue } tps = append(tps, obj.Type()) } added := map[string]struct{}{}
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
topLevel := true for len(tps) != 0 { var nextTps []types.Type for _, tp := range tps { named, isNamed := tp.(*types.Named) if !isNamed { continue } obj := named.Obj() if obj.Pkg() != funcs.modulePkg.Types { continue } if !obj.Exported() { if !topLevel { return "", fmt.Errorf("cannot code-generate unexported type %s", obj.Name()) } continue } strct, isStruct := named.Underlying().(*types.Struct) if !isStruct { continue }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
if _, ok := added[obj.Name()]; ok { continue } objType, extraTypes, err := ps.goStructToAPIType(strct, named) if err != nil { return "", err } if objType == nil { continue } if err := ps.fillObjectFunctionCases(named, objFunctionCases); err != nil { return "", fmt.Errorf("failed to generate function cases for %s: %w", obj.Name(), err) } if len(objFunctionCases[obj.Name()]) == 0 && !ps.isMainModuleObject(obj.Name()) { if topLevel { continue } if ps.isDaggerGenerated(named.Obj()) { continue } } createMod = dotLine(createMod, "WithObject").Call(Add(Line(), objType)) added[obj.Name()] = struct{}{}
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
nextTps = append(nextTps, extraTypes...) } tps, nextTps = nextTps, nil topLevel = false } return strings.Join([]string{mainSrc, invokeSrc(objFunctionCases, createMod)}, "\n"), nil } func dotLine(a *Statement, id string) *Statement {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
return a.Op(".").Line().Id(id) } const ( mainSrc = `func main() { ctx := context.Background() fnCall := dag.CurrentFunctionCall() parentName, err := fnCall.ParentName(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } fnName, err := fnCall.Name(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } parentJson, err := fnCall.Parent(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
fnArgs, err := fnCall.InputArgs(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } inputArgs := map[string][]byte{} for _, fnArg := range fnArgs { argName, err := fnArg.Name(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } argValue, err := fnArg.Value(ctx) if err != nil { fmt.Println(err.Error()) os.Exit(2) } inputArgs[argName] = []byte(argValue) } result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs) if err != nil { fmt.Println(err.Error()) os.Exit(2) } resultBytes, err := json.Marshal(result) if err != nil { fmt.Println(err.Error()) os.Exit(2) } _, err = fnCall.ReturnValue(ctx, JSON(resultBytes))
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
if err != nil { fmt.Println(err.Error()) os.Exit(2) } } ` parentJSONVar = "parentJSON" parentNameVar = "parentName" fnNameVar = "fnName" inputArgsVar = "inputArgs" invokeFuncName = "invoke" ) func invokeSrc(objFunctionCases map[string][]Code, createMod Code) string { objCases := []Code{} for objName, functionCases := range objFunctionCases { objCases = append(objCases, Case(Lit(objName)).Block(Switch(Id(fnNameVar)).Block(functionCases...))) } objCases = append(objCases, Case(Lit("")).Block( Return(createMod, Nil()), )) objCases = append(objCases, Default().Block( Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown object %s"), Id(parentNameVar))), )) objSwitch := Switch(Id(parentNameVar)).Block(objCases...) invokeFunc := Func().Id(invokeFuncName).Params(
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
Id("ctx").Qual("context", "Context"), Id(parentJSONVar).Index().Byte(), Id(parentNameVar).String(), Id(fnNameVar).String(), Id(inputArgsVar).Map(String()).Index().Byte(), ).Params( Id("_").Id("any"), Id("err").Error(), ).Block(objSwitch) return fmt.Sprintf("%#v", invokeFunc) } func renderNameOrStruct(t types.Type) string { if ptr, ok := t.(*types.Pointer); ok { return "*" + renderNameOrStruct(ptr.Elem()) } if sl, ok := t.(*types.Slice); ok { return "[]" + renderNameOrStruct(sl.Elem()) } if st, ok := t.(*types.Struct); ok { result := "struct {\n" for i := 0; i < st.NumFields(); i++ { if !st.Field(i).Embedded() { result += st.Field(i).Name() + " " }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
result += renderNameOrStruct(st.Field(i).Type()) if tag := st.Tag(i); tag != "" { result += " `" + tag + "`" } result += "\n" } result += "}" return result } if named, ok := t.(*types.Named); ok { base := named.Obj().Name() if typeArgs := named.TypeArgs(); typeArgs.Len() > 0 { base += "[" for i := 0; i < typeArgs.Len(); i++ { if i > 0 { base += ", " } base += renderNameOrStruct(typeArgs.At(i)) } base += "]" } return base }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
return t.String() } var checkErrStatement = If(Err().Op("!=").Nil()).Block( Qual("fmt", "Println").Call(Err().Dot("Error").Call()), Qual("os", "Exit").Call(Lit(2)), ) func (ps *parseState) fillObjectFunctionCases(type_ types.Type, cases map[string][]Code) error { var objName string switch x := type_.(type) { case *types.Pointer: return ps.fillObjectFunctionCases(x.Elem(), cases) case *types.Named: objName = x.Obj().Name() default: return nil } if existingCases := cases[objName]; len(existingCases) > 0 { return nil } hasConstructor := ps.isMainModuleObject(objName) && ps.constructor != nil methods := ps.methods[objName] if len(methods) == 0 && !hasConstructor { return nil } for _, method := range methods { fnName, sig := method.fn.Name(), method.fn.Type().(*types.Signature)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
if err := ps.fillObjectFunctionCase(objName, fnName, fnName, sig, method.paramSpecs, cases); err != nil { return err } } if hasConstructor { sig, ok := ps.constructor.Type().(*types.Signature) if !ok { return fmt.Errorf("expected %s to be a function, got %T", constructorFuncName, ps.constructor.Type()) } paramSpecs, err := ps.parseParamSpecs(ps.constructor) if err != nil { return fmt.Errorf("failed to parse %s function: %w", constructorFuncName, err) } results := sig.Results() if results.Len() == 0 { return fmt.Errorf("%s must return a value", constructorFuncName) } resultType := results.At(0).Type() if ptrType, ok := resultType.(*types.Pointer); ok { resultType = ptrType.Elem() } namedType, ok := resultType.(*types.Named) if !ok { return fmt.Errorf("%s must return the main module object %q", constructorFuncName, objName) } if namedType.Obj().Name() != objName { return fmt.Errorf("%s must return the main module object %q", constructorFuncName, objName) }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
if err := ps.fillObjectFunctionCase(objName, ps.constructor.Name(), "", sig, paramSpecs, cases); err != nil { return err } } cases[objName] = append(cases[objName], Default().Block( Return(Nil(), Qual("fmt", "Errorf").Call(Lit("unknown function %s"), Id(fnNameVar))), )) return nil } func (ps *parseState) fillObjectFunctionCase( objName string, fnName string, caseName string, sig *types.Signature, paramSpecs []paramSpec, cases map[string][]Code, ) error { statements := []Code{} parentVarName := "parent" statements = append(statements, Var().Id(parentVarName).Id(objName), Err().Op("=").Qual("json", "Unmarshal").Call(Id(parentJSONVar), Op("&").Id(parentVarName)), checkErrStatement, ) var fnCallArgs []Code if sig.Recv() != nil { fnCallArgs = []Code{Op("&").Id(parentVarName)} } vars := map[string]struct{}{}
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
for i, spec := range paramSpecs { if i == 0 && spec.paramType.String() == contextTypename { fnCallArgs = append(fnCallArgs, Id("ctx")) continue } var varName string var varType types.Type var target *Statement if spec.parent == nil { varName = strcase.ToLowerCamel(spec.name) varType = spec.paramType target = Id(varName) } else { varName = spec.parent.name varType = spec.parent.paramType target = Id(spec.parent.name).Dot(spec.name) } if _, ok := vars[varName]; !ok { vars[varName] = struct{}{}
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
tp := varType access := Id(varName) tp2, access2 := findOptsAccessPattern(varType, Id(varName)) _, applyAccessPattern := tp2.(*types.Struct) if !applyAccessPattern { _, applyAccessPattern = ps.isOptionalWrapper(tp2) } if applyAccessPattern { tp = tp2 access = access2 } statements = append(statements, Var().Id(varName).Id(renderNameOrStruct(tp))) if spec.variadic { fnCallArgs = append(fnCallArgs, access.Op("...")) } else { fnCallArgs = append(fnCallArgs, access)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
} } statements = append(statements, If(Id(inputArgsVar).Index(Lit(spec.graphqlName())).Op("!=").Nil()).Block( Err().Op("=").Qual("json", "Unmarshal").Call( Index().Byte().Parens(Id(inputArgsVar).Index(Lit(spec.graphqlName()))), Op("&").Add(target), ), checkErrStatement, )) } results := sig.Results() var callStatement *Statement if sig.Recv() != nil { callStatement = Parens(Op("*").Id(objName)).Dot(fnName).Call(fnCallArgs...) } else { callStatement = Id(fnName).Call(fnCallArgs...) } switch results.Len() { case 2: if results.At(1).Type().String() != errorTypeName { return fmt.Errorf("second return value must be error, have %s", results.At(1).Type().String()) } statements = append(statements, Return(callStatement)) cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...)) if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil { return err }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
return nil case 1: if results.At(0).Type().String() == errorTypeName { statements = append(statements, Return(Nil(), callStatement)) cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...)) } else { statements = append(statements, Return(callStatement, Nil())) cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...)) if err := ps.fillObjectFunctionCases(results.At(0).Type(), cases); err != nil { return err } } return nil case 0: statements = append(statements, callStatement, Return(Nil(), Nil())) cases[objName] = append(cases[objName], Case(Lit(caseName)).Block(statements...)) return nil default: return fmt.Errorf("unexpected number of results from function %s: %d", fnName, results.Len()) } } type parseState struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
pkg *packages.Package fset *token.FileSet methods map[string][]method moduleName string constructor *types.Func } func (ps *parseState) isMainModuleObject(name string) bool { return strcase.ToCamel(ps.moduleName) == strcase.ToCamel(name) } type method struct { fn *types.Func paramSpecs []paramSpec } func (ps *parseState) goTypeToAPIType(typ types.Type, named *types.Named) (*Statement, *types.Named, error) { switch t := typ.(type) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
case *types.Named: typeDef, _, err := ps.goTypeToAPIType(t.Underlying(), t) if err != nil { return nil, nil, fmt.Errorf("failed to convert named type: %w", err) } return typeDef, t, nil case *types.Pointer: return ps.goTypeToAPIType(t.Elem(), named) case *types.Slice: elemTypeDef, underlying, err := ps.goTypeToAPIType(t.Elem(), nil) if err != nil { return nil, nil, fmt.Errorf("failed to convert slice element type: %w", err) } return Qual("dag", "TypeDef").Call().Dot("WithListOf").Call( elemTypeDef, ), underlying, nil case *types.Basic: if t.Kind() == types.Invalid { return nil, nil, fmt.Errorf("invalid type: %+v", t) } var kind Code switch t.Info() { case types.IsString: kind = Id("Stringkind") case types.IsInteger: kind = Id("Integerkind") case types.IsBoolean: kind = Id("Booleankind") default:
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
return nil, nil, fmt.Errorf("unsupported basic type: %+v", t) } return Qual("dag", "TypeDef").Call().Dot("WithKind").Call( kind, ), named, nil case *types.Struct: if named == nil { return nil, nil, fmt.Errorf("struct types must be named") } typeName := named.Obj().Name() if typeName == "" { return nil, nil, fmt.Errorf("struct types must be named") } return Qual("dag", "TypeDef").Call().Dot("WithObject").Call( Lit(typeName), ), named, nil default: return nil, nil, fmt.Errorf("unsupported type %T", t) } } const errorTypeName = "error" func (ps *parseState) goStructToAPIType(t *types.Struct, named *types.Named) (*Statement, []types.Type, error) { if named == nil { return nil, nil, fmt.Errorf("struct types must be named") } typeName := named.Obj().Name() if typeName == "" { return nil, nil, fmt.Errorf("struct types must be named") }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
objectIsDaggerGenerated := ps.isDaggerGenerated(named.Obj()) methods := []*types.Func{} methodSet := types.NewMethodSet(types.NewPointer(named)) for i := 0; i < methodSet.Len(); i++ { methodObj := methodSet.At(i).Obj() if ps.isDaggerGenerated(methodObj) { continue } if objectIsDaggerGenerated { return nil, nil, fmt.Errorf("cannot define methods on objects from outside this module") } method, ok := methodObj.(*types.Func) if !ok { return nil, nil, fmt.Errorf("expected method to be a func, got %T", methodObj) } if !method.Exported() { continue } methods = append(methods, method) } if objectIsDaggerGenerated { return nil, nil, nil } sort.Slice(methods, func(i, j int) bool { return methods[i].Pos() < methods[j].Pos()
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
}) withObjectArgs := []Code{ Lit(typeName), } withObjectOpts := []Code{} typeSpec, err := ps.typeSpecForNamedType(named) if err != nil { return nil, nil, fmt.Errorf("failed to find decl for named type %s: %w", typeName, err) } if comment := typeSpec.Doc.Text(); comment != "" { withObjectOpts = append(withObjectOpts, Id("Description").Op(":").Lit(strings.TrimSpace(comment))) } if len(withObjectOpts) > 0 { withObjectArgs = append(withObjectArgs, Id("TypeDefWithObjectOpts").Values(withObjectOpts...)) } typeDef := Qual("dag", "TypeDef").Call().Dot("WithObject").Call(withObjectArgs...) var subTypes []types.Type for _, method := range methods { fnTypeDef, functionSubTypes, err := ps.goFuncToAPIFunctionDef(typeName, method) if err != nil { return nil, nil, fmt.Errorf("failed to convert method %s to function def: %w", method.Name(), err) } subTypes = append(subTypes, functionSubTypes...) typeDef = dotLine(typeDef, "WithFunction").Call(Add(Line(), fnTypeDef)) } astStructType, ok := typeSpec.Type.(*ast.StructType) if !ok { return nil, nil, fmt.Errorf("expected type spec to be a struct, got %T", typeSpec.Type)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
} astFields := unpackASTFields(astStructType.Fields) for i := 0; i < t.NumFields(); i++ { field := t.Field(i) if !field.Exported() { continue } fieldTypeDef, subType, err := ps.goTypeToAPIType(field.Type(), nil) if err != nil { return nil, nil, fmt.Errorf("failed to convert field type: %w", err) } if subType != nil { subTypes = append(subTypes, subType) } description := astFields[i].Doc.Text() if description == "" { description = astFields[i].Comment.Text() } description = strings.TrimSpace(description) name := field.Name() tag := reflect.StructTag(t.Tag(i)) if dt := tag.Get("json"); dt != "" { dt, _, _ = strings.Cut(dt, ",") if dt == "-" { continue } name = dt
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
} withFieldArgs := []Code{ Lit(name), fieldTypeDef, } if description != "" { withFieldArgs = append(withFieldArgs, Id("TypeDefWithFieldOpts").Values( Id("Description").Op(":").Lit(description), )) } typeDef = dotLine(typeDef, "WithField").Call(withFieldArgs...) } if ps.isMainModuleObject(typeName) && ps.constructor != nil { fnTypeDef, _, err := ps.goFuncToAPIFunctionDef("", ps.constructor) if err != nil { return nil, nil, fmt.Errorf("failed to convert constructor to function def: %w", err) } typeDef = dotLine(typeDef, "WithConstructor").Call(Add(Line(), fnTypeDef)) } return typeDef, subTypes, nil } var voidDef = Qual("dag", "TypeDef").Call(). Dot("WithKind").Call(Id("Voidkind")). Dot("WithOptional").Call(Lit(true)) func (ps *parseState) goFuncToAPIFunctionDef(receiverTypeName string, fn *types.Func) (*Statement, []types.Type, error) { sig, ok := fn.Type().(*types.Signature) if !ok { return nil, nil, fmt.Errorf("expected method to be a func, got %T", fn.Type()) }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
specs, err := ps.parseParamSpecs(fn) if err != nil { return nil, nil, err } if receiverTypeName != "" { ps.methods[receiverTypeName] = append(ps.methods[receiverTypeName], method{fn: fn, paramSpecs: specs}) } var fnReturnType *Statement var subTypes []types.Type results := sig.Results() var returnSubType *types.Named switch results.Len() { case 0: fnReturnType = voidDef case 1: result := results.At(0).Type() if result.String() == errorTypeName { fnReturnType = voidDef } else { fnReturnType, returnSubType, err = ps.goTypeToAPIType(result, nil) if err != nil { return nil, nil, fmt.Errorf("failed to convert result type: %w", err) } } case 2: result := results.At(0).Type() subTypes = append(subTypes, result) fnReturnType, returnSubType, err = ps.goTypeToAPIType(result, nil)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
if err != nil { return nil, nil, fmt.Errorf("failed to convert result type: %w", err) } default: return nil, nil, fmt.Errorf("method %s has too many return values", fn.Name()) } if returnSubType != nil { subTypes = append(subTypes, returnSubType) } fnDef := Qual("dag", "Function").Call(Lit(fn.Name()), Add(Line(), fnReturnType)) funcDecl, err := ps.declForFunc(fn) if err != nil { return nil, nil, fmt.Errorf("failed to find decl for method %s: %w", fn.Name(), err) } if comment := funcDecl.Doc.Text(); comment != "" { fnDef = dotLine(fnDef, "WithDescription").Call(Lit(strings.TrimSpace(comment))) } for i, spec := range specs { if i == 0 && spec.paramType.String() == contextTypename { continue } typeDef, subType, err := ps.goTypeToAPIType(spec.baseType, nil) if err != nil { return nil, nil, fmt.Errorf("failed to convert param type: %w", err) } if subType != nil { subTypes = append(subTypes, subType) } if spec.optional {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
typeDef = typeDef.Dot("WithOptional").Call(Lit(true)) } args := []Code{Lit(spec.graphqlName()), typeDef} argOpts := []Code{} if spec.description != "" { argOpts = append(argOpts, Id("Description").Op(":").Lit(spec.description)) } if spec.defaultValue != "" { var jsonEnc string if spec.baseType.String() == "string" { enc, err := json.Marshal(spec.defaultValue) if err != nil { return nil, nil, fmt.Errorf("failed to marshal default value: %w", err) } jsonEnc = string(enc) } else { jsonEnc = spec.defaultValue } argOpts = append(argOpts, Id("DefaultValue").Op(":").Id("JSON").Call(Lit(jsonEnc))) } if len(argOpts) > 0 { args = append(args, Id("FunctionWithArgOpts").Values(argOpts...)) } fnDef = dotLine(fnDef, "WithArg").Call(args...) } return fnDef, subTypes, nil } func (ps *parseState) parseParamSpecs(fn *types.Func) ([]paramSpec, error) { sig := fn.Type().(*types.Signature)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
params := sig.Params() if params.Len() == 0 { return nil, nil } specs := make([]paramSpec, 0, params.Len()) i := 0 if params.At(i).Type().String() == contextTypename { spec, err := ps.parseParamSpecVar(params.At(i), "", "") if err != nil { return nil, err } specs = append(specs, spec) i++ } fnDecl, err := ps.declForFunc(fn) if err != nil { return nil, err } if i+1 == params.Len() { param := params.At(i) paramType, ok := asInlineStruct(param.Type()) if ok { stype, ok := asInlineStructAst(fnDecl.Type.Params.List[i].Type) if !ok { return nil, fmt.Errorf("expected struct type for %s", param.Name()) } parent := &paramSpec{ name: params.At(i).Name(),
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
paramType: param.Type(), baseType: param.Type(), } paramFields := unpackASTFields(stype.Fields) for f := 0; f < paramType.NumFields(); f++ { spec, err := ps.parseParamSpecVar(paramType.Field(f), paramFields[f].Doc.Text(), paramFields[f].Comment.Text()) if err != nil { return nil, err } spec.parent = parent specs = append(specs, spec) } return specs, nil } } paramFields := unpackASTFields(fnDecl.Type.Params) for ; i < params.Len(); i++ { docComment, lineComment := ps.commentForFuncField(fnDecl, paramFields, i) spec, err := ps.parseParamSpecVar(params.At(i), docComment.Text(), lineComment.Text()) if err != nil { return nil, err } if sig.Variadic() && i == params.Len()-1 { spec.variadic = true } specs = append(specs, spec) } return specs, nil
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
} func (ps *parseState) parseParamSpecVar(field *types.Var, docComment string, lineComment string) (paramSpec, error) { if _, ok := field.Type().(*types.Struct); ok { return paramSpec{}, fmt.Errorf("nested structs are not supported") } paramType := field.Type() baseType := paramType for { ptr, ok := baseType.(*types.Pointer) if !ok { break } baseType = ptr.Elem() } optional := false defaultValue := "" if named, ok := ps.isOptionalWrapper(baseType); ok { typeArgs := named.TypeArgs() if typeArgs.Len() != 1 { return paramSpec{}, fmt.Errorf("optional type must have exactly one type argument") } optional = true baseType = typeArgs.At(0) for { ptr, ok := baseType.(*types.Pointer) if !ok { break } baseType = ptr.Elem() }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
} docPragmas, docComment := parsePragmaComment(docComment) linePragmas, lineComment := parsePragmaComment(lineComment) comment := strings.TrimSpace(docComment) if comment == "" { comment = strings.TrimSpace(lineComment) } pragmas := make(map[string]string) maps.Copy(pragmas, docPragmas) maps.Copy(pragmas, linePragmas) if v, ok := pragmas["default"]; ok { defaultValue = v } if v, ok := pragmas["optional"]; ok { if v == "" { optional = true } else { optional, _ = strconv.ParseBool(v) } } return paramSpec{ name: field.Name(), paramType: paramType, baseType: baseType, optional: optional, defaultValue: defaultValue, description: comment, }, nil } type paramSpec struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
name string description string optional bool variadic bool defaultValue string paramType types.Type baseType types.Type parent *paramSpec } func (spec *paramSpec) graphqlName() string { return strcase.ToLowerCamel(spec.name) } func (ps *parseState) typeSpecForNamedType(namedType *types.Named) (*ast.TypeSpec, error) { tokenFile := ps.fset.File(namedType.Obj().Pos()) if tokenFile == nil { return nil, fmt.Errorf("no file for %s", namedType.Obj().Name()) } for _, f := range ps.pkg.Syntax { if ps.fset.File(f.Pos()) != tokenFile { continue } for _, decl := range f.Decls { genDecl, ok := decl.(*ast.GenDecl)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
if !ok { continue } for _, spec := range genDecl.Specs { typeSpec, ok := spec.(*ast.TypeSpec) if !ok { continue } if typeSpec.Name.Name == namedType.Obj().Name() { if typeSpec.Doc == nil { typeSpec.Doc = genDecl.Doc } return typeSpec, nil } } } } return nil, fmt.Errorf("no decl for %s", namedType.Obj().Name()) } func (ps *parseState) declForFunc(fnType *types.Func) (*ast.FuncDecl, error) { tokenFile := ps.fset.File(fnType.Pos()) if tokenFile == nil { return nil, fmt.Errorf("no file for %s", fnType.Name()) } for _, f := range ps.pkg.Syntax { if ps.fset.File(f.Pos()) != tokenFile { continue } for _, decl := range f.Decls { fnDecl, ok := decl.(*ast.FuncDecl)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
if ok && fnDecl.Name.Name == fnType.Name() { return fnDecl, nil } } } return nil, fmt.Errorf("no decl for %s", fnType.Name()) } func (ps *parseState) commentForFuncField(fnDecl *ast.FuncDecl, unpackedParams []*ast.Field, i int) (docComment *ast.CommentGroup, lineComment *ast.CommentGroup) { pos := unpackedParams[i].Pos() tokenFile := ps.fset.File(pos) if tokenFile == nil { return nil, nil } line := tokenFile.Line(pos) allowDocComment := true allowLineComment := true if i == 0 { fieldStartLine := tokenFile.Line(fnDecl.Type.Params.Pos()) if fieldStartLine == line || fieldStartLine == line-1 { allowDocComment = false } } else { prevArgLine := tokenFile.Line(unpackedParams[i-1].Pos()) if prevArgLine == line || prevArgLine == line-1 { allowDocComment = false }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
} if i+1 < len(fnDecl.Type.Params.List) { nextArgLine := tokenFile.Line(unpackedParams[i+1].Pos()) if nextArgLine == line { allowLineComment = false } } else { fieldEndLine := tokenFile.Line(fnDecl.Type.Params.End()) if fieldEndLine == line { allowLineComment = false } } for _, f := range ps.pkg.Syntax { if ps.fset.File(f.Pos()) != tokenFile { continue } if allowDocComment { npos := tokenFile.LineStart(tokenFile.Line(pos)) - 1 for _, comment := range f.Comments { if comment.Pos() <= npos && npos <= comment.End() { docComment = comment break } }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
} if allowLineComment { npos := tokenFile.LineStart(tokenFile.Line(pos)+1) - 1 for _, comment := range f.Comments { if comment.Pos() <= npos && npos <= comment.End() { lineComment = comment break } } } } return docComment, lineComment } func (ps *parseState) isDaggerGenerated(obj types.Object) bool { tokenFile := ps.fset.File(obj.Pos()) return filepath.Base(tokenFile.Name()) == daggerGenFilename } func (ps *parseState) isOptionalWrapper(typ types.Type) (*types.Named, bool) { named, ok := typ.(*types.Named) if !ok { return nil, false } if named.Obj().Name() == "Optional" && ps.isDaggerGenerated(named.Obj()) { return named, true } return nil, false } func findOptsAccessPattern(t types.Type, access *Statement) (types.Type, *Statement) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
switch t := t.(type) { case *types.Pointer: t2, val := findOptsAccessPattern(t.Elem(), access) return t2, Id("ptr").Call(val) default: return t, access } } var pragmaCommentRegexp = regexp.MustCompile(`\+\s*(\S+?)(?:=(.+))?(?:\n|$)`) func parsePragmaComment(comment string) (data map[string]string, rest string) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
data = map[string]string{} lastEnd := 0 for _, v := range pragmaCommentRegexp.FindAllStringSubmatchIndex(comment, -1) { var key, value string if v[2] != -1 { key = comment[v[2]:v[3]] } if v[4] != -1 { value = comment[v[4]:v[5]] } data[key] = value rest += comment[lastEnd:v[0]] lastEnd = v[1] } rest += comment[lastEnd:] return data, rest } func asInlineStruct(t types.Type) (*types.Struct, bool) { switch t := t.(type) { case *types.Pointer: return asInlineStruct(t.Elem()) case *types.Struct: return t, true default: return nil, false } } func asInlineStructAst(t ast.Node) (*ast.StructType, bool) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
cmd/codegen/generator/go/templates/modules.go
switch t := t.(type) { case *ast.StarExpr: return asInlineStructAst(t.X) case *ast.StructType: return t, true default: return nil, false } } func unpackASTFields(fields *ast.FieldList) []*ast.Field { var unpacked []*ast.Field for _, field := range fields.List { for i, name := range field.Names { field := *field field.Names = []*ast.Ident{name} if i != 0 { field.Doc = nil field.Comment = nil } unpacked = append(unpacked, &field) } } return unpacked }
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
package core import ( "context" _ "embed" "encoding/json" "fmt" "go/format" "os" "path/filepath" "strings" "testing" "time" "github.com/iancoleman/strcase" "github.com/moby/buildkit/identity" "github.com/stretchr/testify/require" "github.com/tidwall/gjson" "golang.org/x/sync/errgroup" "dagger.io/dagger" "github.com/dagger/dagger/cmd/codegen/introspection" "github.com/dagger/dagger/core/modules" ) func TestModuleGoInit(t *testing.T) { t.Run("from scratch", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=bare", "--sdk=go"))
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out) }) t.Run("reserved go.mod name", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=go", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{go{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"go":{"containerEcho":{"stdout":"hello\n"}}}`, out) }) t.Run("uses expected Go module name, camel-cases Dagger module name", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=My-Module", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen.
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
With(daggerQuery(`{myModule{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"myModule":{"containerEcho":{"stdout":"hello\n"}}}`, out) generated, err := modGen.File("go.mod").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, "module main") }) t.Run("creates go.mod beneath an existing go.mod if root points beneath it", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/go.mod", dagger.ContainerWithNewFileOpts{ Contents: "module example.com/test\n", }). WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{ Contents: "package foo\n", }). WithWorkdir("/work/ci"). With(daggerExec("mod", "init", "--name=beneathGoMod", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{beneathGoMod{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"beneathGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out) t.Run("names Go module after Dagger module", func(t *testing.T) { generated, err := modGen.File("go.mod").Contents(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
require.NoError(t, err) require.Contains(t, generated, "module main") }) }) t.Run("respects existing go.mod", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithExec([]string{"go", "mod", "init", "example.com/test"}). With(daggerExec("mod", "init", "--name=hasGoMod", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasGoMod{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasGoMod":{"containerEcho":{"stdout":"hello\n"}}}`, out) t.Run("preserves module name", func(t *testing.T) { generated, err := modGen.File("go.mod").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, "module example.com/test") }) }) t.Run("respects parent go.mod if root points to it", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work").
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
WithExec([]string{"go", "mod", "init", "example.com/test"}). WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{ Contents: "package foo\n", }). WithWorkdir("/work/child"). With(daggerExec("mod", "init", "--name=child", "--sdk=go", "--root=..")). WithNewFile("/work/child/main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main import "os" type Child struct{} func (m *Child) Root() *Directory { wd, err := os.Getwd() if err != nil { panic(err) } return dag.Host().Directory(wd+"/..") } `, }) generated := modGen. With(daggerExec("mod", "sync")). Directory(".") logGen(ctx, t, generated) out, err := modGen. With(daggerQuery(`{child{root{entries}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"child":{"root":{"entries":["child","foo.go","go.mod","go.sum"]}}}`, out)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
childEntries, err := generated.Entries(ctx) require.NoError(t, err) require.NotContains(t, childEntries, "go.mod") t.Run("preserves parent module name", func(t *testing.T) { generated, err := modGen.File("/work/go.mod").Contents(ctx) require.NoError(t, err) require.Contains(t, generated, "module example.com/test") }) }) t.Run("respects existing go.mod even if root points to parent that has go.mod", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithExec([]string{"go", "mod", "init", "example.com/test"}). WithNewFile("/work/foo.go", dagger.ContainerWithNewFileOpts{ Contents: "package foo\n", }). WithWorkdir("/work/child"). WithExec([]string{"go", "mod", "init", "my-mod"}). With(daggerExec("mod", "init", "--name=child", "--sdk=go", "--root=..")). WithNewFile("/work/child/main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main import "os" type Child struct{} func (m *Child) Root() *Directory { wd, err := os.Getwd() if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
panic(err) } return dag.Host().Directory(wd+"/..") } `, }) generated := modGen. With(daggerExec("mod", "sync")). Directory(".") logGen(ctx, t, generated) out, err := modGen. With(daggerQuery(`{child{root{entries}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"child":{"root":{"entries":["child","foo.go","go.mod"]}}}`, out) childEntries, err := generated.Entries(ctx) require.NoError(t, err) require.Contains(t, childEntries, "go.mod") require.Contains(t, childEntries, "go.sum") }) t.Run("respects existing main.go", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: `
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
package main type HasMainGo struct {} func (m *HasMainGo) Hello() string { return "Hello, world!" } `, }). With(daggerExec("mod", "init", "--name=hasMainGo", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasMainGo{hello}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasMainGo":{"hello":"Hello, world!"}}`, out) }) t.Run("respects existing main.go even if it uses types not generated yet", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/main.go", dagger.ContainerWithNewFileOpts{ Contents: ` package main type HasDaggerTypes struct {} func (m *HasDaggerTypes) Hello() *Container { return dag.Container(). From("` + alpineImage + `"). WithExec([]string{"echo", "Hello, world!"}) } `, }).
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
With(daggerExec("mod", "init", "--name=hasDaggerTypes", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasDaggerTypes{hello{stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasDaggerTypes":{"hello":{"stdout":"Hello, world!\n"}}}`, out) }) t.Run("respects existing package without creating main.go", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/notmain.go", dagger.ContainerWithNewFileOpts{ Contents: `package main type HasNotMainGo struct {} func (m *HasNotMainGo) Hello() string { return "Hello, world!" } `, }). With(daggerExec("mod", "init", "--name=hasNotMainGo", "--sdk=go")) logGen(ctx, t, modGen.Directory(".")) out, err := modGen. With(daggerQuery(`{hasNotMainGo{hello}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"hasNotMainGo":{"hello":"Hello, world!"}}`, out) }) } func TestModuleInitLICENSE(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
t.Run("bootstraps Apache-2.0 LICENSE file if none found", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=licensed-to-ill", "--sdk=go")) content, err := modGen.File("LICENSE").Contents(ctx) require.NoError(t, err) require.Contains(t, content, "Apache License, Version 2.0") }) t.Run("creates LICENSE file in the directory specified by -m", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "-m", "./mymod", "--name=licensed-to-ill", "--sdk=go")) content, err := modGen.File("mymod/LICENSE").Contents(ctx) require.NoError(t, err) require.Contains(t, content, "Apache License, Version 2.0") }) t.Run("does not bootstrap LICENSE file if it exists in the parent dir", func(t *testing.T) { t.Parallel() c, ctx := connect(t)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{ Contents: "doesnt matter", }). WithWorkdir("/work/sub"). With(daggerExec("mod", "init", "--name=licensed-to-ill", "--sdk=go")) _, err := modGen.File("LICENSE").Contents(ctx) require.Error(t, err) }) t.Run("bootstraps a LICENSE file when requested, even if it exists in the parent dir", func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). WithNewFile("/work/LICENSE", dagger.ContainerWithNewFileOpts{ Contents: "doesnt matter", }). WithWorkdir("/work/sub"). With(daggerExec("mod", "init", "--name=licensed-to-ill", "--sdk=go", "--license=MIT")) content, err := modGen.File("LICENSE").Contents(ctx) require.NoError(t, err) require.Contains(t, content, "MIT License") }) } func TestModuleGit(t *testing.T) { t.Parallel() type testCase struct {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
sdk string gitignores []string } for _, tc := range []testCase{ { sdk: "go", gitignores: []string{ "/dagger.gen.go\n", "/querybuilder/\n", }, }, { sdk: "python",
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
gitignores: []string{ "/sdk\n", }, }, } { tc := tc t.Run(fmt.Sprintf("module %s git", tc.sdk), func(t *testing.T) { t.Parallel() c, ctx := connect(t) modGen := goGitBase(t, c). With(daggerExec("mod", "init", "--name=bare", "--sdk="+tc.sdk)) if tc.sdk == "go" { logGen(ctx, t, modGen.Directory(".")) } out, err := modGen. With(daggerQuery(`{bare{containerEcho(stringArg:"hello"){stdout}}}`)). Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"bare":{"containerEcho":{"stdout":"hello\n"}}}`, out) t.Run("configures .gitignore", func(t *testing.T) { ignore, err := modGen.File(".gitignore").Contents(ctx) require.NoError(t, err) for _, gitignore := range tc.gitignores { require.Contains(t, ignore, gitignore) } }) }) } } func TestModuleGoGitRemovesIgnored(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) committedModGen := goGitBase(t, c). With(daggerExec("mod", "init", "--name=bare", "--sdk=go")). WithExec([]string{"rm", ".gitignore"}). WithExec([]string{"mkdir", "./internal"}). WithExec([]string{"cp", "-a", "./querybuilder", "./internal/querybuilder"}). WithExec([]string{"git", "add", "."}). WithExec([]string{"git", "commit", "-m", "init with generated files"}) changedAfterSync, err := committedModGen. With(daggerExec("mod", "sync")). WithExec([]string{"git", "diff"}). WithExec([]string{"git", "status", "--short"}). Stdout(ctx) require.NoError(t, err) t.Logf("changed after sync:\n%s", changedAfterSync) require.Contains(t, changedAfterSync, "D dagger.gen.go\n") require.Contains(t, changedAfterSync, "D querybuilder/marshal.go\n") require.Contains(t, changedAfterSync, "D querybuilder/querybuilder.go\n") require.Contains(t, changedAfterSync, "D internal/querybuilder/marshal.go\n") require.Contains(t, changedAfterSync, "D internal/querybuilder/querybuilder.go\n") } func TestModulePythonGitRemovesIgnored(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) committedModGen := goGitBase(t, c). With(daggerExec("mod", "init", "--name=bare", "--sdk=python")). WithExec([]string{"rm", ".gitignore"}). WithExec([]string{"git", "add", "."}). WithExec([]string{"git", "commit", "-m", "init with generated files"}) changedAfterSync, err := committedModGen. With(daggerExec("mod", "sync")). WithExec([]string{"git", "diff"}). WithExec([]string{"git", "status", "--short"}). Stdout(ctx) require.NoError(t, err) t.Logf("changed after sync:\n%s", changedAfterSync) require.Contains(t, changedAfterSync, "D sdk/pyproject.toml\n") require.Contains(t, changedAfterSync, "D sdk/src/dagger/__init__.py\n") } var goSignatures string func TestModuleGoSignatures(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
t.Parallel() c, ctx := connect(t) modGen := c.Container().From(golangImage). WithMountedFile(testCLIBinPath, daggerCliFile(t, c)). WithWorkdir("/work"). With(daggerExec("mod", "init", "--name=minimal", "--sdk=go")). WithNewFile("main.go", dagger.ContainerWithNewFileOpts{ Contents: goSignatures, }) logGen(ctx, t, modGen.Directory(".")) t.Run("func Hello() string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{hello}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"hello":"hello"}}`, out) })
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
t.Run("func Echo(string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echo(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echo":"hello...hello...hello..."}}`, out) }) t.Run("func EchoPointer(*string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoPointer(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoPointer":"hello...hello...hello..."}}`, out) }) t.Run("func EchoPointerPointer(**string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoPointerPointer(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoPointerPointer":"hello...hello...hello..."}}`, out) }) t.Run("func EchoOptional(string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoOptional(msg: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptional":"hello...hello...hello..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptional}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptional":"default...default...default..."}}`, out) }) t.Run("func EchoOptionalPointer(string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoOptionalPointer(msg: "hello")}}`)).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
5,991
Zenith: allow private fields in types
Creating an issue based on @shykes's comment here: https://discord.com/channels/707636530424053791/1120503349599543376/1166880734741549176 Today, an example type in Go might look something like: ```go type X struct { Foo string `json:"foo"` } ``` In this example, `Foo` is exported and persisted between multiple calls (since each function call is a separate execution of the go binary) as well as being queriable by the user / calling module. However, a relatively normal use case would be to want only that first property - a private field `Foo`, accessible and modifiable by the module, but inaccessible to the calling code. There are two main parts of this: - How should we mark a field as private at the API level? - We could have a `WithPrivate` call for fields, similar to `WithOptional` for function parameters. - This would mark the field as private, so we would always serialize/deserialize it, but would not generate it as part of the graphql schema for the module. - How should we indicate that the field is private in Go/Python/etc? - For Go, ideally we could use unexported fields as private - since `dagger.gen.go` is in the same package as `main.go`, then this wouldn't be a problem. However, a couple caveats: this would be the first thing (as far as I'm aware) to require access to private fields in `main.go` from `dagger.gen.go`, so it would be difficult to split this into a separate package later (if we wanted to prevent the user from accessing private parts of `dagger.gen.go`). It would still be possible though! We'd just need the code that accessed the parts of `main.go` to be auto-generated into the same package (and extract the internals into a separate package). Secondly, we'd then have no way to have fields with "forbidden types" - today, that's any structs (until we have module-defined IDable types), and any types declared outside the current package. This is similar in behavior to how args work today, so maybe this isn't a huge issue.
https://github.com/dagger/dagger/issues/5991
https://github.com/dagger/dagger/pull/6224
9a0f81a7367a675b13854f0be82694d4ebc44dd3
69da5d811ce20d7abc1d4af3a9912bb63ce93baf
2023-10-27T14:51:01Z
go
2023-12-11T13:49:57Z
core/integration/module_test.go
require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"hello...hello...hello..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptionalPointer}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalPointer":"default...default...default..."}}`, out) }) t.Run("func EchoOptionalSlice([]string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoOptionalSlice(msg: ["hello", "there"])}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"hello+there...hello+there...hello+there..."}}`, out) out, err = modGen.With(daggerQuery(`{minimal{echoOptionalSlice}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoOptionalSlice":"foobar...foobar...foobar..."}}`, out) }) t.Run("func Echoes([]string) []string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoes(msgs: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoes":["hello...hello...hello..."]}}`, out) }) t.Run("func EchoesVariadic(...string) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{echoesVariadic(msgs: "hello")}}`)).Stdout(ctx) require.NoError(t, err) require.JSONEq(t, `{"minimal":{"echoesVariadic":"hello...hello...hello..."}}`, out) }) t.Run("func HelloContext(context.Context) string", func(t *testing.T) { t.Parallel() out, err := modGen.With(daggerQuery(`{minimal{helloContext}}`)).Stdout(ctx)