Skip to content

Commit

Permalink
commit provisioning transaction before starting pipeline (#1759)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovromazgon authored Aug 7, 2024
1 parent 7601e06 commit 8670c8a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/provisioning/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,23 @@ func (s *Service) provisionPipeline(ctx context.Context, cfg config.Pipeline) er
return cerrors.Errorf("invalid pipeline config: %w", err)
}

txn, ctx, err := s.db.NewTransaction(ctx, true)
txn, importCtx, err := s.db.NewTransaction(ctx, true)
if err != nil {
return cerrors.Errorf("could not create db transaction: %w", err)
}
defer txn.Discard()

err = s.Import(ctx, cfg)
err = s.Import(importCtx, cfg)
if err != nil {
return cerrors.Errorf("could not import pipeline: %w", err)
}

// commit db transaction
err = txn.Commit()
if err != nil {
return cerrors.Errorf("could not commit db transaction: %w", err)
}

// check if pipeline should be running
if cfg.Status == config.StatusRunning {
// TODO set status and let the pipeline service start it
Expand All @@ -253,12 +259,6 @@ func (s *Service) provisionPipeline(ctx context.Context, cfg config.Pipeline) er
}
}

// commit db transaction
err = txn.Commit()
if err != nil {
return cerrors.Errorf("could not commit db transaction: %w", err)
}

return nil
}

Expand Down

0 comments on commit 8670c8a

Please sign in to comment.