Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
CreationTimestamp field introduced to JobInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-marek committed Nov 4, 2018
1 parent e165255 commit 3f0dfd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package api

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/api/core/v1"
policyv1 "k8s.io/api/policy/v1beta1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -128,6 +128,8 @@ type JobInfo struct {
Allocated *Resource
TotalRequest *Resource

CreationTimestamp metav1.Time

PodGroup *arbcorev1.PodGroup

// TODO(k82cn): keep backward compatbility, removed it when v1alpha1 finalized.
Expand Down Expand Up @@ -164,6 +166,7 @@ func (ji *JobInfo) SetPodGroup(pg *arbcorev1.PodGroup) {
ji.Queue = QueueID(pg.Spec.Queue)
}

ji.CreationTimestamp = pg.GetCreationTimestamp()
ji.PodGroup = pg
}

Expand All @@ -173,6 +176,7 @@ func (ji *JobInfo) SetPDB(pdb *policyv1.PodDisruptionBudget) {
ji.Namespace = pdb.Namespace
ji.Queue = QueueID(pdb.Namespace)

ji.CreationTimestamp = pdb.GetCreationTimestamp()
ji.PDB = pdb
}

Expand Down Expand Up @@ -267,14 +271,16 @@ func (ji *JobInfo) Clone() *JobInfo {
NodeSelector: map[string]string{},
Allocated: ji.Allocated.Clone(),
TotalRequest: ji.TotalRequest.Clone(),

PDB: ji.PDB,
PodGroup: ji.PodGroup,

TaskStatusIndex: map[TaskStatus]tasksMap{},
Tasks: tasksMap{},
}

ji.CreationTimestamp.DeepCopyInto(&info.CreationTimestamp)

for k, v := range ji.NodeSelector {
info.NodeSelector[k] = v
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/plugins/gang/gang.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ func (gp *gangPlugin) OnSessionOpen(ssn *framework.Session) {
}

if !lReady && !rReady {
if lv.PodGroup.GetCreationTimestamp().Time.Equal(rv.PodGroup.GetCreationTimestamp().Time) {
if lv.CreationTimestamp.Equal(&rv.CreationTimestamp) {
if lv.UID < rv.UID {
return -1;
}
} else if lv.PodGroup.GetCreationTimestamp().Time.Before(rv.PodGroup.GetCreationTimestamp().Time) {
} else if lv.CreationTimestamp.Before(&rv.CreationTimestamp) {
return -1
}
return 1
Expand Down

0 comments on commit 3f0dfd8

Please sign in to comment.