#Dagger Cloud

1 messages · Page 1 of 1 (latest)

ember ruin
signal juniper
#

do you have code pushed anywhere?

#

looks like the span context isn't being passed on to the API calls

ember ruin
#

no it's not public code but can share the code snippet does this

    p := pool.New().WithErrors().WithContext(ctx).WithMaxGoroutines(10)

    modules, err := snyf.Modules(ctx, dag, m.Source)
    if err != nil {
        return err
    }

    for _, module := range modules {
        module := module
        p.Go(func(ctx context.Context) error {
            ctx, span := Tracer().Start(ctx, "Tidy "+module.Path)
            defer func() {
                if rerr != nil {
                    span.SetStatus(codes.Error, rerr.Error())
                }
                span.End()
            }()

            exitcode, err := dag.Container().
                From("golang:1.23").
                WithMountedDirectory("/work", m.Source).
                WithWorkdir("/work/"+module.Path).
                WithExec([]string{"sha256sum", "go.mod", "go.sum"}, dagger.ContainerWithExecOpts{RedirectStdout: "/work/go.sum.sha256.bak"}).
                WithExec([]string{"go", "mod", "tidy"}).
                WithExec([]string{"sha256sum", "go.mod", "go.sum"}, dagger.ContainerWithExecOpts{RedirectStdout: "/work/go.sum.sha256"}).
                WithExec([]string{"diff", "-u", "/work/go.sum.sha256.bak", "/work/go.sum.sha256"}, dagger.ContainerWithExecOpts{Expect: dagger.ReturnTypeAny}).
                ExitCode(ctx)

            if err != nil {
                return fmt.Errorf("failed to tidy module %s: %w", module.Path, err)
            }

            if exitcode != 0 {
                return fmt.Errorf("module %s is not tidy", module.Path)
            }

            return nil
        })
    }

    return p.Wait()
signal juniper
#

strange, that looks right to me

ember ruin
#

found the issue p := pool.New().WithErrors().WithContext(ctx)

#

this is not respect dagger context

#

i removed with context and everything is normal now

signal juniper
ember ruin