diff --git a/core/provider/digitalocean/digitalocean_provider.go b/core/provider/digitalocean/digitalocean_provider.go index b5c40f6..ae8b1c5 100644 --- a/core/provider/digitalocean/digitalocean_provider.go +++ b/core/provider/digitalocean/digitalocean_provider.go @@ -70,6 +70,8 @@ func NewDigitalOceanProvider(ctx context.Context, logger *zap.Logger, providerNa sshFingerprint: sshFingerprint, } + logger.Debug("petri tag", zap.String("tag", digitalOceanProvider.petriTag)) + _, err = digitalOceanProvider.createTag(ctx, digitalOceanProvider.petriTag) if err != nil { diff --git a/core/provider/digitalocean/droplet.go b/core/provider/digitalocean/droplet.go index 32855d7..17dda40 100644 --- a/core/provider/digitalocean/droplet.go +++ b/core/provider/digitalocean/droplet.go @@ -26,7 +26,6 @@ func (p *Provider) CreateDroplet(ctx context.Context, definition provider.TaskDe if !ok { return nil, fmt.Errorf("could not cast provider specific config to DigitalOceanConfig") } - req := &godo.DropletCreateRequest{ Name: fmt.Sprintf("%s-%s", p.petriTag, definition.Name), Region: doConfig.Region, @@ -85,6 +84,7 @@ func (p *Provider) CreateDroplet(ctx context.Context, definition provider.TaskDe } p.logger.Info("droplet is active", zap.Duration("after", time.Since(start)), zap.String("task", definition.Name)) + droplet = d return true, nil }) diff --git a/core/provider/task.go b/core/provider/task.go index 797c81b..3c2bed2 100644 --- a/core/provider/task.go +++ b/core/provider/task.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "go.uber.org/zap" + "golang.org/x/sync/errgroup" "sync" ) @@ -26,34 +27,49 @@ func CreateTask(ctx context.Context, logger *zap.Logger, provider Provider, defi sidecarTasks := make([]*Task, 0) - for _, sidecar := range definition.Sidecars { - if len(sidecar.Sidecars) > 0 { - return nil, errors.New("sidecar cannot have sidecar") - } + var eg errgroup.Group - id, err := provider.CreateTask(ctx, task.logger, sidecar) - if err != nil { - return nil, err - } + for i := range definition.Sidecars { + sidecar := definition.Sidecars[i] + eg.Go(func() error { + if len(sidecar.Sidecars) > 0 { + return errors.New("sidecar cannot have sidecar") + } + + id, err := provider.CreateTask(ctx, task.logger, sidecar) + if err != nil { + return err + } + + sidecarTasks = append(sidecarTasks, &Task{ + Provider: provider, + Definition: sidecar, + ID: id, + Sidecars: make([]*Task, 0), + logger: task.logger, + }) - sidecarTasks = append(sidecarTasks, &Task{ - Provider: provider, - Definition: sidecar, - ID: id, - Sidecars: make([]*Task, 0), - logger: task.logger, + return nil }) } - task.Sidecars = sidecarTasks - - id, err := provider.CreateTask(ctx, logger, definition) - if err != nil { + + eg.Go(func() error { + id, err := provider.CreateTask(ctx, logger, definition) + if err != nil { + return err + } + + task.ID = id + + return nil + }) + + if err := eg.Wait(); err != nil { return nil, err } - - task.ID = id - + + task.Sidecars = sidecarTasks return task, nil } diff --git a/cosmos/cosmosutil/wallet.go b/cosmos/cosmosutil/wallet.go index b793e7b..f840f0b 100644 --- a/cosmos/cosmosutil/wallet.go +++ b/cosmos/cosmosutil/wallet.go @@ -243,7 +243,7 @@ func (w *InteractingWallet) getTxResponse(ctx context.Context, txHash string) (s clientCtx := client.Context{Client: cc, TxConfig: w.chain.GetTxConfig(), InterfaceRegistry: w.chain.GetInterfaceRegistry()} - err = util.WaitForCondition(ctx, time.Second*60, time.Second*1, func() (bool, error) { + err = util.WaitForCondition(ctx, time.Second*60, time.Millisecond * 100, func() (bool, error) { res, err := authtx.QueryTx(clientCtx, txHash) if err != nil {