Skip to content

Commit

Permalink
Merge pull request #242 from scylladb/timeout_failure_to_stop
Browse files Browse the repository at this point in the history
gemini: ensure shutdown in case of timeout
  • Loading branch information
Henrik Johansson authored Jun 1, 2020
2 parents 843428e + a0f993d commit 9e8e61f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/gemini/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (hb heartBeat) await() {
}
}

func (p *Pump) Start(ctx context.Context, done context.CancelFunc) error {
func (p *Pump) Start(ctx context.Context) error {
defer p.cleanup()
for {
select {
Expand Down
8 changes: 6 additions & 2 deletions cmd/gemini/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ func run(cmd *cobra.Command, args []string) error {
signal.Notify(graceful, syscall.SIGTERM, syscall.SIGINT)
g.Go(func() error {
select {
case <-gCtx.Done():
return ctx.Err()
case <-graceful:
logger.Info("Told to stop, exiting.")
done()
Expand All @@ -251,18 +253,20 @@ func run(cmd *cobra.Command, args []string) error {
generators := createGenerators(gCtx, schema, schemaConfig, distFunc, concurrency, partitionCount, logger)
sp := createSpinner(interactive())
g.Go(func() error {
return pump.Start(gCtx, done)
defer done()
return pump.Start(gCtx)
})
resCh := make(chan *Status, 1)
g.Go(func() error {
defer done()
res, err := sampleStatus(gCtx, result, sp, logger)
sp.Stop()
resCh <- res
return err
})
time.AfterFunc(duration+warmup, func() {
defer done()
logger.Info("Test run completed. Exiting.")
done()
})

if warmup > 0 {
Expand Down

0 comments on commit 9e8e61f

Please sign in to comment.