-
Notifications
You must be signed in to change notification settings - Fork 132
/
scheduling.go
109 lines (92 loc) · 2.92 KB
/
scheduling.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package cmd
import (
"strings"
"github.com/spf13/cobra"
"github.com/armadaproject/armada/internal/armadactl"
)
func getSchedulingReportCmd(a *armadactl.App) *cobra.Command {
cmd := &cobra.Command{
Use: "scheduling-report",
Short: "Get scheduler reports",
Args: cobra.ExactArgs(0),
SilenceUsage: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
return initParams(cmd, a.Params)
},
RunE: func(cmd *cobra.Command, args []string) error {
verbosity, err := cmd.Flags().GetCount("verbose")
if err != nil {
return err
}
queueName, err := cmd.Flags().GetString("queue")
if err != nil {
return err
}
queueName = strings.TrimSpace(queueName)
if queueName != "" {
return a.GetSchedulingReportForQueue(queueName, int32(verbosity))
}
jobId, err := cmd.Flags().GetString("job")
if err != nil {
return err
}
jobId = strings.TrimSpace(jobId)
if jobId != "" {
return a.GetSchedulingReportForJob(jobId, int32(verbosity))
}
return a.GetSchedulingReport(int32(verbosity))
},
}
cmd.Flags().CountP("verbose", "v", "report verbosity; repeat (e.g., -vvv) to increase verbosity")
cmd.Flags().String("queue", "", "get scheduler reports relevant for this queue; mutually exclusive with --job")
cmd.Flags().String("job", "", "get scheduler reports relevant for this job; mutually exclusive with --queue")
cmd.MarkFlagsMutuallyExclusive("queue", "job")
return cmd
}
func getQueueSchedulingReportCmd(a *armadactl.App) *cobra.Command {
cmd := &cobra.Command{
Use: "queue-report",
Short: "Get queue scheduler reports",
Args: cobra.ExactArgs(0),
SilenceUsage: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
return initParams(cmd, a.Params)
},
RunE: func(cmd *cobra.Command, args []string) error {
verbosity, err := cmd.Flags().GetCount("verbose")
if err != nil {
return err
}
queueName, err := cmd.Flags().GetString("queue")
if err != nil {
return err
}
queueName = strings.TrimSpace(queueName)
return a.GetQueueSchedulingReport(queueName, int32(verbosity))
},
}
cmd.Flags().CountP("verbose", "v", "report verbosity; repeat (e.g., -vvv) to increase verbosity")
cmd.Flags().String("queue", "", "Queue name to query reports for.")
return cmd
}
func getJobSchedulingReportCmd(a *armadactl.App) *cobra.Command {
cmd := &cobra.Command{
Use: "job-report",
Short: "Get job scheduler reports",
Args: cobra.ExactArgs(0),
SilenceUsage: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
return initParams(cmd, a.Params)
},
RunE: func(cmd *cobra.Command, args []string) error {
jobId, err := cmd.Flags().GetString("jobId")
if err != nil {
return err
}
jobId = strings.TrimSpace(jobId)
return a.GetJobSchedulingReport(jobId)
},
}
cmd.Flags().String("jobId", "", "Id of job to query reports for.")
return cmd
}