Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move scheduler name out of common args #187

Merged
merged 3 commits into from
May 20, 2019
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