New filter hiding short running jobs

This commit is contained in:
Lou Knauer 2022-03-02 10:48:52 +01:00
parent 2d9070ec02
commit a2f626fb0e
7 changed files with 23 additions and 3 deletions

@ -1 +1 @@
Subproject commit 984532dbf2a05d670c90a16cba9c93de813e304a Subproject commit 0fe9296c15e76957c2d929c8993d5834a3f6f73f

View File

@ -1379,6 +1379,8 @@ input JobFilter {
partition: StringInput partition: StringInput
duration: IntRange duration: IntRange
minRunningFor: Int
numNodes: IntRange numNodes: IntRange
numAccelerators: IntRange numAccelerators: IntRange
numHWThreads: IntRange numHWThreads: IntRange
@ -7218,6 +7220,14 @@ func (ec *executionContext) unmarshalInputJobFilter(ctx context.Context, obj int
if err != nil { if err != nil {
return it, err return it, err
} }
case "minRunningFor":
var err error
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("minRunningFor"))
it.MinRunningFor, err = ec.unmarshalOInt2ᚖint(ctx, v)
if err != nil {
return it, err
}
case "numNodes": case "numNodes":
var err error var err error

View File

@ -57,6 +57,7 @@ type JobFilter struct {
Cluster *StringInput `json:"cluster"` Cluster *StringInput `json:"cluster"`
Partition *StringInput `json:"partition"` Partition *StringInput `json:"partition"`
Duration *IntRange `json:"duration"` Duration *IntRange `json:"duration"`
MinRunningFor *int `json:"minRunningFor"`
NumNodes *IntRange `json:"numNodes"` NumNodes *IntRange `json:"numNodes"`
NumAccelerators *IntRange `json:"numAccelerators"` NumAccelerators *IntRange `json:"numAccelerators"`
NumHWThreads *IntRange `json:"numHWThreads"` NumHWThreads *IntRange `json:"numHWThreads"`

View File

@ -179,6 +179,8 @@ input JobFilter {
partition: StringInput partition: StringInput
duration: IntRange duration: IntRange
minRunningFor: Int
numNodes: IntRange numNodes: IntRange
numAccelerators: IntRange numAccelerators: IntRange
numHWThreads: IntRange numHWThreads: IntRange

View File

@ -23,6 +23,8 @@ var groupBy2column = map[model.Aggregate]string{
model.AggregateCluster: "job.cluster", model.AggregateCluster: "job.cluster",
} }
const ShortJobDuration int = 180
// Helper function for the jobsStatistics GraphQL query placed here so that schema.resolvers.go is not too full. // Helper function for the jobsStatistics GraphQL query placed here so that schema.resolvers.go is not too full.
func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate) ([]*model.JobsStatistics, error) { func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobFilter, groupBy *model.Aggregate) ([]*model.JobsStatistics, error) {
// In case `groupBy` is nil (not used), the model.JobsStatistics used is at the key '' (empty string) // In case `groupBy` is nil (not used), the model.JobsStatistics used is at the key '' (empty string)
@ -90,7 +92,7 @@ func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobF
} }
if groupBy == nil { if groupBy == nil {
query := sq.Select("COUNT(job.id)").From("job").Where("job.duration < 120") query := sq.Select("COUNT(job.id)").From("job").Where("job.duration < ?", ShortJobDuration)
query = repository.SecurityCheck(ctx, query) query = repository.SecurityCheck(ctx, query)
for _, f := range filter { for _, f := range filter {
query = repository.BuildWhereClause(f, query) query = repository.BuildWhereClause(f, query)
@ -100,7 +102,7 @@ func (r *queryResolver) jobsStatistics(ctx context.Context, filter []*model.JobF
} }
} else { } else {
col := groupBy2column[*groupBy] col := groupBy2column[*groupBy]
query := sq.Select(col, "COUNT(job.id)").From("job").Where("job.duration < 120") query := sq.Select(col, "COUNT(job.id)").From("job").Where("job.duration < ?", ShortJobDuration)
query = repository.SecurityCheck(ctx, query) query = repository.SecurityCheck(ctx, query)
for _, f := range filter { for _, f := range filter {
query = repository.BuildWhereClause(f, query) query = repository.BuildWhereClause(f, query)

View File

@ -126,6 +126,10 @@ func BuildWhereClause(filter *model.JobFilter, query sq.SelectBuilder) sq.Select
now := time.Now().Unix() // There does not seam to be a portable way to get the current unix timestamp accross different DBs. now := time.Now().Unix() // There does not seam to be a portable way to get the current unix timestamp accross different DBs.
query = query.Where("(CASE WHEN job.job_state = 'running' THEN (? - job.start_time) ELSE job.duration END) BETWEEN ? AND ?", now, filter.Duration.From, filter.Duration.To) query = query.Where("(CASE WHEN job.job_state = 'running' THEN (? - job.start_time) ELSE job.duration END) BETWEEN ? AND ?", now, filter.Duration.From, filter.Duration.To)
} }
if filter.MinRunningFor != nil {
now := time.Now().Unix() // There does not seam to be a portable way to get the current unix timestamp accross different DBs.
query = query.Where("(job.job_state != 'running' OR (? - job.start_time) > ?)", now, *filter.MinRunningFor)
}
if filter.State != nil { if filter.State != nil {
states := make([]string, len(filter.State)) states := make([]string, len(filter.State))
for i, val := range filter.State { for i, val := range filter.State {

View File

@ -113,6 +113,7 @@ var programConfig ProgramConfig = ProgramConfig{
"plot_general_colorBackground": true, "plot_general_colorBackground": true,
"plot_general_colorscheme": []string{"#00bfff", "#0000ff", "#ff00ff", "#ff0000", "#ff8000", "#ffff00", "#80ff00"}, "plot_general_colorscheme": []string{"#00bfff", "#0000ff", "#ff00ff", "#ff0000", "#ff8000", "#ffff00", "#80ff00"},
"plot_general_lineWidth": 1, "plot_general_lineWidth": 1,
"plot_list_hideShortRunningJobs": 5 * 60,
"plot_list_jobsPerPage": 10, "plot_list_jobsPerPage": 10,
"plot_list_selectedMetrics": []string{"cpu_load", "mem_used", "flops_any", "mem_bw", "clock"}, "plot_list_selectedMetrics": []string{"cpu_load", "mem_used", "flops_any", "mem_bw", "clock"},
"plot_view_plotsPerRow": 2, "plot_view_plotsPerRow": 2,