Skip to content

Commit

Permalink
fix(scheduler): move JobInfo helper functions to method
Browse files Browse the repository at this point in the history
also formatted several doc strings.

Signed-off-by: Siyuan Wang <c.one@thrimbda.com>
  • Loading branch information
Thrimbda committed Mar 3, 2021
1 parent daf26a7 commit 10475a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions pkg/apis/batch/v1alpha1/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type JobSpec struct {
// Default to nil
RunningEstimate *metav1.Duration `json:"runningEstimate,omitempty" protobuf:"bytes,4,opt,name=runningEstimate"`

//Specifies the queue that will be used in the scheduler, "default" queue is used this leaves empty.
// Specifies the queue that will be used in the scheduler, "default" queue is used this leaves empty.
// +optional
Queue string `json:"queue,omitempty" protobuf:"bytes,7,opt,name=queue"`

Expand Down Expand Up @@ -126,9 +126,9 @@ const (
PVCError JobEvent = "PVCError"
// PodGroupError pod grp error event is generated if error happens during pod grp creation
PodGroupError JobEvent = "PodGroupError"
//ExecuteAction action issued event for each action
// ExecuteAction action issued event for each action
ExecuteAction JobEvent = "ExecuteAction"
//JobStatusError is generated if update job status failed
// JobStatusError is generated if update job status failed
JobStatusError JobEvent = "JobStatusError"
// PodGroupPending pod grp pending event is generated if pg pending due to some error
PodGroupPending JobEvent = "PodGroupPending"
Expand Down Expand Up @@ -263,7 +263,7 @@ type JobStatus struct {
// +optional
Unknown int32 `json:"unknown,omitempty" protobuf:"bytes,8,opt,name=unknown"`

//Current version of job
// Current version of job
// +optional
Version int32 `json:"version,omitempty" protobuf:"bytes,9,opt,name=version"`

Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/scheduling/v1beta1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const QueueNameAnnotationKey = GroupName + "/queue-name"
// PodPreemptable is the key of preemptable
const PodPreemptable = "volcano.sh/preemptable"

//RevocableZone is the key of revocable-zone
// RevocableZone is the key of revocable-zone
const RevocableZone = "volcano.sh/revocable-zone"

// JDBMinAvailable is the key of min available pod number
Expand Down
16 changes: 8 additions & 8 deletions pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,24 +239,24 @@ func (ji *JobInfo) SetPodGroup(pg *PodGroup) {
ji.CreationTimestamp = pg.GetCreationTimestamp()

var err error
ji.WaitingTime, err = GetWaitingTime(pg)
ji.WaitingTime, err = ji.GetWaitingTime(pg)
if err != nil {
klog.Warningf("Error occurs in parsing waiting time for job <%s/%s>, err: %s.",
pg.Namespace, pg.Name, err.Error())
ji.WaitingTime = nil
}

ji.Preemptable = GetJobPreemptable(pg)
ji.RevocableZone = GetJobRevocableZone(pg)
ji.Budget = GetBudget(pg)
ji.Preemptable = ji.GetJobPreemptable(pg)
ji.RevocableZone = ji.GetJobRevocableZone(pg)
ji.Budget = ji.GetBudget(pg)

ji.PodGroup = pg

}

// GetWaitingTime reads sla waiting time for job from podgroup annotations
// TODO: should also read from given field in volcano job spec
func GetWaitingTime(pg *PodGroup) (*time.Duration, error) {
func (ji *JobInfo) GetWaitingTime(pg *PodGroup) (*time.Duration, error) {
if _, exist := pg.Annotations[JobWaitingTime]; !exist {
return nil, nil
}
Expand All @@ -274,7 +274,7 @@ func GetWaitingTime(pg *PodGroup) (*time.Duration, error) {
}

// GetJobPreemptable return volcano.sh/preemptable value for job
func GetJobPreemptable(pg *PodGroup) bool {
func (ji *JobInfo) GetJobPreemptable(pg *PodGroup) bool {
// check annotaion first
if len(pg.Annotations) > 0 {
if value, found := pg.Annotations[v1beta1.PodPreemptable]; found {
Expand Down Expand Up @@ -303,7 +303,7 @@ func GetJobPreemptable(pg *PodGroup) bool {
}

// GetJobRevocableZone return volcano.sh/revocable-zone value for pod/podgroup
func GetJobRevocableZone(pg *PodGroup) string {
func (ji *JobInfo) GetJobRevocableZone(pg *PodGroup) string {
// check annotaion first
if len(pg.Annotations) > 0 {
if value, found := pg.Annotations[v1beta1.RevocableZone]; found {
Expand All @@ -324,7 +324,7 @@ func GetJobRevocableZone(pg *PodGroup) string {
}

// GetBudget return budget value for job
func GetBudget(pg *PodGroup) *DisruptionBudget {
func (ji *JobInfo) GetBudget(pg *PodGroup) *DisruptionBudget {
if len(pg.Annotations) > 0 {
if value, found := pg.Annotations[v1beta1.JDBMinAvailable]; found {
return NewDisruptionBudget(value, "")
Expand Down

0 comments on commit 10475a4

Please sign in to comment.