Skip to content

Commit bd48125

Browse files
authored
add queuing (#7)
1 parent 7c09130 commit bd48125

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
k8s.io/apimachinery v0.21.2
99
k8s.io/client-go v0.21.2
1010
k8s.io/code-generator v0.21.2
11-
k8s.io/klog v1.0.0
1211
k8s.io/klog/v2 v2.8.0
1312
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
1413
k8s.io/sample-controller v0.21.2

pkg/contorller/contoller.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const (
4343
// QuNameSuffix is the suffix of the queue unit name when create a new one.
4444
// In this way, different types of jobs with the same name will create different queue unit name.
4545
QuNameSuffix = "-pytorch-qu"
46+
Queuing = "Queuing"
4647
)
4748

4849
type PyTorchExtensionController struct {
@@ -358,6 +359,19 @@ func (pc *PyTorchExtensionController) AddPyTorchJob(obj interface{}) {
358359
if err != nil {
359360
klog.Errorf("Can't create queueunit for pytorchjob %v/%v,err is:%v", pytorchJob.Namespace, pytorchJob.Name, err)
360361
}
362+
363+
if pytorchJob.Status.Conditions == nil {
364+
pytorchJob.Status.Conditions = make([]commonv1.JobCondition, 0)
365+
pytorchJob.Status.Conditions = append(pytorchJob.Status.Conditions, commonv1.JobCondition{
366+
Type: Queuing,
367+
LastUpdateTime: metav1.Now(),
368+
})
369+
_, err := pc.pytorchJobClient.KubeflowV1().PyTorchJobs(pytorchJob.Namespace).UpdateStatus(context.TODO(), pytorchJob, metav1.UpdateOptions{})
370+
if err != nil {
371+
klog.Errorf("update pytorchJob failed Queuing %v/%v %v", pytorchJob.Namespace, pytorchJob.Name, err.Error())
372+
}
373+
klog.Infof("update pytorchJob %v/%v status Queuing successfully", pytorchJob.Namespace, pytorchJob.Name)
374+
}
361375
}
362376

363377
func (pc *PyTorchExtensionController) UpdatePyTorchJob(_, newObj interface{}) {

0 commit comments

Comments
 (0)