#Run two dagger call sequentially in code?

1 messages · Page 1 of 1 (latest)

marble bison
#

I have a GitHub Action that runs two Dagger calls sequentially. Now I want to run one Dagger call that triggers two Dagger actions. However, these two actions do not depend on each other and just return error, so Dagger will run them in parallel. This results in a race condition. Does anyone know how I can combine two Dagger calls with CLI in one Dagger call but run them sequentially?

Something like this

func (m *Ci) Ci() error {
    m.Update("test")
    m.Update("stg")
    
    return nil
}
rotund field
#

You can use whatever your programming language does to parallelize this - so in go, you can use go with a wait group, or even better an errgroup

marble bison
#

Yes, but I want to run them sequentially, not in parallel.

#

With the above sample code, wouldn't Dagger run it in parallel? I want stg to run after test.

rotund field
#

ah, i think it should just run them in sequence?

#

but you need to get the context and the errors handling in there

dry stratus
marble bison
#

Just return the error type. As far as I know, if two actions don’t depend on each other, they will run in parallel.

dry stratus
#

if you do:

func (m *Ci) Ci() error {
    c, err := dag.Container.From("alpine").Sync(ctx)
    c, err := dag.Container.From("alpine").Sync(ctx)
    return nil
}

that will run sequentially

marble bison
#

thanks @dry stratus, Is there any way I can achieve the same with m.Update returning only error types?