Skip to content

Commit

Permalink
support queued before scheduled (#708)
Browse files Browse the repository at this point in the history
  • Loading branch information
denkensk authored Nov 15, 2021
1 parent eb2933b commit 5a47651
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
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

0 comments on commit 5a47651

Please sign in to comment.