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

support queued before scheduled #708

Merged
merged 1 commit into from
Nov 15, 2021
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
3 changes: 3 additions & 0 deletions pkg/apis/types/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ type CommonSubmitArgs struct {
// EnableRDMA enable rdma or not,match option --rdma
EnableRDMA bool `yaml:"enableRDMA"`

// EnableQueue enables the feature to queue jobs after they are scheduled.
EnableQueue bool `yaml:"enableQueue"`

// UseENI defines using eni or not
UseENI bool `yaml:"useENI"`

Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/types/training.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ type TrainingJobInfo struct {
type TrainingJobStatus string

const (
// TrainingJobQueuing means the job is queuing
TrainingJobQueuing TrainingJobStatus = "QUEUING"
// TrainingJobPending means the job is pending
TrainingJobPending TrainingJobStatus = "PENDING"
// TrainingJobRunning means the job is running
Expand Down
2 changes: 2 additions & 0 deletions pkg/argsbuilder/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ const (
gangSchdName = "kube-batch"

aliyunENIAnnotation = "k8s.aliyun.com/eni"

jobSuspend = "scheduling.x-k8s.io/suspend"
)
16 changes: 16 additions & 0 deletions pkg/argsbuilder/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ func (s *SubmitArgsBuilder) AddCommandFlags(command *cobra.Command) {
command.Flags().BoolVar(&s.args.Coscheduling, "gang", false, "enable gang scheduling")
// use priority
command.Flags().StringVarP(&s.args.PriorityClassName, "priority", "p", "", "priority class name")
// enable Queue
command.Flags().BoolVar(&s.args.EnableQueue, "queue", false, "enables the feature to queue jobs after they are scheduled (Kube-queue needs to be pre-installed https://github.com/kube-queue/kube-queue)")
// add option --toleration,its' value will be get from viper
command.Flags().StringArrayVar(&tolerations, "toleration", []string{}, `tolerate some k8s nodes with taints,usage: "--toleration taint-key" or "--toleration all" `)
// add option --selector,its' value will be get from viper
Expand Down Expand Up @@ -174,6 +176,9 @@ func (s *SubmitArgsBuilder) Build() error {
if err := s.setAnnotations(); err != nil {
return err
}
if err := s.setQueue(); err != nil {
return err
}
if err := s.setLabels(); err != nil {
return err
}
Expand Down Expand Up @@ -323,6 +328,17 @@ func (s *SubmitArgsBuilder) setAnnotations() error {
return nil
}

// setQueue is used to add annotation for suspend status
func (s *SubmitArgsBuilder) setQueue() error {
if s.args.EnableQueue {
if s.args.Annotations == nil {
s.args.Annotations = map[string]string{}
}
s.args.Annotations[jobSuspend] = "true"
}
return nil
}

// setAnnotations is used to handle option --annotation
func (s *SubmitArgsBuilder) setLabels() error {
if s.args.Labels == nil {
Expand Down