Skip to content

Commit

Permalink
timeout job progress (#4468)
Browse files Browse the repository at this point in the history
This PR aims at making sure that  job progress is timed out correctly.
  • Loading branch information
udsamani authored Sep 19, 2024
1 parent 96e99c9 commit 07e89ff
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/util/printer/job_progress_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
)

const PrintoutCanceledButRunningNormally string = "printout canceled but running normally"
const PrintoutTimeoutButRunningNormally string = "but running normally"

type JobProgressPrinter struct {
client clientv2.API
Expand Down Expand Up @@ -244,7 +245,7 @@ To cancel the job, run:
var returnError error = nil

// Capture Ctrl + C if the user wants to finish the job early
ctx, cancel := context.WithCancel(ctx)
ctx, cancel := context.WithTimeout(ctx, 1*time.Minute)
signalChan := make(chan os.Signal, 2)
signal.Notify(signalChan, util.ShutdownSignals...)
defer func() {
Expand Down Expand Up @@ -280,8 +281,17 @@ To cancel the job, run:
}
cancel()
case <-ctx.Done():
return
cmdShuttingDown = true
cmd.SetOut(os.Stdout)

if !quiet {
cmd.Println("\n\n\rPrintout canceled due to timeout (the job is still running).")
cmd.Println(getMoreInfoString)
cmd.Println(cancelString)
}
returnError = fmt.Errorf("%s", PrintoutCanceledButRunningNormally)
}
return
}
}()

Expand Down

0 comments on commit 07e89ff

Please sign in to comment.