diff --git a/pkg/cli/job/common.go b/pkg/cli/job/common.go index 43fff20759a..040b566112e 100644 --- a/pkg/cli/job/common.go +++ b/pkg/cli/job/common.go @@ -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 != "" { diff --git a/pkg/cli/job/list.go b/pkg/cli/job/list.go index ba14c07324e..534fe6db3d8 100644 --- a/pkg/cli/job/list.go +++ b/pkg/cli/job/list.go @@ -31,7 +31,8 @@ import ( type listFlags struct { commonFlags - Namespace string + Namespace string + SchedulerName string } const ( @@ -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 { @@ -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 diff --git a/pkg/cli/job/run.go b/pkg/cli/job/run.go index 79372f5920b..4fc8c28afb5 100644 --- a/pkg/cli/job/run.go +++ b/pkg/cli/job/run.go @@ -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{} @@ -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"