Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pkg/cli/job/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import (
)

type commonFlags struct {
Master string
Kubeconfig string
SchedulerName string
Master string
Kubeconfig string
}

func initFlags(cmd *cobra.Command, cf *commonFlags) {
cmd.Flags().StringVarP(&cf.SchedulerName, "scheduler", "S", "kube-batch", "the scheduler for this job")
cmd.Flags().StringVarP(&cf.Master, "master", "s", "", "the address of apiserver")

if home := homeDir(); home != "" {
Expand Down
7 changes: 6 additions & 1 deletion pkg/cli/job/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import (
type listFlags struct {
commonFlags

Namespace string
Namespace string
SchedulerName string
}

const (
Expand All @@ -57,6 +58,7 @@ func InitListFlags(cmd *cobra.Command) {
initFlags(cmd, &listJobFlags.commonFlags)

cmd.Flags().StringVarP(&listJobFlags.Namespace, "namespace", "N", "default", "the namespace of job")
cmd.Flags().StringVarP(&listJobFlags.SchedulerName, "scheduler", "S", "", "list job with specified scheduler name")
}

func ListJobs() error {
Expand Down Expand Up @@ -89,6 +91,9 @@ func PrintJobs(jobs *v1alpha1.JobList, writer io.Writer) {
}

for _, job := range jobs.Items {
if listJobFlags.SchedulerName != "" && listJobFlags.SchedulerName != job.Spec.SchedulerName {
continue
}
replicas := int32(0)
for _, ts := range job.Spec.Tasks {
replicas += ts.Replicas
Expand Down
10 changes: 6 additions & 4 deletions pkg/cli/job/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ type runFlags struct {
Namespace string
Image string

MinAvailable int
Replicas int
Requests string
Limits string
MinAvailable int
Replicas int
Requests string
Limits string
SchedulerName string
}

var launchJobFlags = &runFlags{}
Expand All @@ -50,6 +51,7 @@ func InitRunFlags(cmd *cobra.Command) {
cmd.Flags().IntVarP(&launchJobFlags.Replicas, "replicas", "r", 1, "the total tasks of job")
cmd.Flags().StringVarP(&launchJobFlags.Requests, "requests", "R", "cpu=1000m,memory=100Mi", "the resource request of the task")
cmd.Flags().StringVarP(&launchJobFlags.Limits, "limits", "L", "cpu=1000m,memory=100Mi", "the resource limit of the task")
cmd.Flags().StringVarP(&listJobFlags.SchedulerName, "scheduler", "S", "kube-batch", "the scheduler for this job")
}

var jobName = "job.volcano.sh"
Expand Down