mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 05:19:05 +01:00
Only autostop jobs with a positive walltime
This commit is contained in:
parent
cdfb144b82
commit
9d49fea48a
@ -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 {
|
||||
|
25
server.go
25
server.go
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user