Only autostop jobs with a positive walltime

This commit is contained in:
Lou Knauer 2022-05-09 11:53:41 +02:00
parent cdfb144b82
commit 9d49fea48a
2 changed files with 14 additions and 12 deletions

View File

@ -378,6 +378,7 @@ func (r *JobRepository) StopJobsExceedingWalltimeBy(seconds int) error {
Set("duration", 0).
Set("job_state", schema.JobStateFailed).
Where("job.job_state = 'running'").
Where("job.walltime > 0").
Where(fmt.Sprintf("(%d - job.start_time) > (job.walltime + %d)", time.Now().Unix(), seconds)).
RunWith(r.DB).Exec()
if err != nil {

View File

@ -13,6 +13,7 @@ import (
"net/url"
"os"
"os/signal"
"runtime"
"runtime/debug"
"strings"
"sync"
@ -126,7 +127,7 @@ var programConfig ProgramConfig = ProgramConfig{
"plot_view_showStatTable": true,
"system_view_selectedMetric": "cpu_load",
},
StopJobsExceedingWalltime: 3600,
StopJobsExceedingWalltime: -1,
}
func main() {
@ -481,17 +482,17 @@ func main() {
api.OngoingArchivings.Wait()
}()
// if programConfig.StopJobsExceedingWalltime != 0 {
// go func() {
// for range time.Tick(1 * time.Hour) {
// err := jobRepo.StopJobsExceedingWalltimeBy(programConfig.StopJobsExceedingWalltime)
// if err != nil {
// log.Errorf("error while looking for jobs exceeding theire walltime: %s", err.Error())
// }
// runtime.GC()
// }
// }()
// }
if programConfig.StopJobsExceedingWalltime > 0 {
go func() {
for range time.Tick(30 * time.Minute) {
err := jobRepo.StopJobsExceedingWalltimeBy(programConfig.StopJobsExceedingWalltime)
if err != nil {
log.Errorf("error while looking for jobs exceeding theire walltime: %s", err.Error())
}
runtime.GC()
}
}()
}
if os.Getenv("GOGC") == "" {
debug.SetGCPercent(25)