@@ -22,6 +22,7 @@ import (
22
22
"strconv"
23
23
"time"
24
24
25
+ batchv1 "k8s.io/api/batch/v1"
25
26
v1 "k8s.io/api/core/v1"
26
27
apierrors "k8s.io/apimachinery/pkg/api/errors"
27
28
"k8s.io/apimachinery/pkg/api/meta"
@@ -515,8 +516,8 @@ func (r *AppWrapperReconciler) getComponentStatus(ctx context.Context, aw *workl
515
516
516
517
for componentIdx := range aw .Status .ComponentStatus {
517
518
cs := & aw .Status .ComponentStatus [componentIdx ]
518
- switch cs .Kind {
519
- case "PyTorchJob" :
519
+ switch cs .APIVersion + ":" + cs . Kind {
520
+ case "kubeflow.org/v1: PyTorchJob" :
520
521
obj := & unstructured.Unstructured {}
521
522
obj .SetAPIVersion (cs .APIVersion )
522
523
obj .SetKind (cs .Kind )
@@ -547,16 +548,26 @@ func (r *AppWrapperReconciler) getComponentStatus(ctx context.Context, aw *workl
547
548
}
548
549
}
549
550
}
550
- } else {
551
- if apierrors .IsNotFound (err ) {
552
- meta .SetStatusCondition (& aw .Status .ComponentStatus [componentIdx ].Conditions , metav1.Condition {
553
- Type : string (workloadv1beta2 .Unhealthy ),
554
- Status : metav1 .ConditionTrue ,
555
- Reason : "ComponentNotFound" ,
556
- })
557
- } else {
558
- return nil , err
551
+ } else if ! apierrors .IsNotFound (err ) {
552
+ return nil , err
553
+ }
554
+
555
+ case "batch/v1:Job" :
556
+ obj := & batchv1.Job {}
557
+ if err := r .Get (ctx , types.NamespacedName {Name : cs .Name , Namespace : aw .Namespace }, obj ); err == nil {
558
+ if obj .GetDeletionTimestamp ().IsZero () {
559
+ summary .deployed += 1
560
+
561
+ // batch/v1 Jobs are failed when status.Conditions contains an entry with type "Failed" and status "True"
562
+ for _ , jc := range obj .Status .Conditions {
563
+ if jc .Type == batchv1 .JobFailed && jc .Status == v1 .ConditionTrue {
564
+ summary .failed += 1
565
+ }
566
+ }
559
567
}
568
+
569
+ } else if ! apierrors .IsNotFound (err ) {
570
+ return nil , err
560
571
}
561
572
562
573
default :
@@ -565,16 +576,8 @@ func (r *AppWrapperReconciler) getComponentStatus(ctx context.Context, aw *workl
565
576
if obj .GetDeletionTimestamp ().IsZero () {
566
577
summary .deployed += 1
567
578
}
568
- } else {
569
- if apierrors .IsNotFound (err ) {
570
- meta .SetStatusCondition (& aw .Status .ComponentStatus [componentIdx ].Conditions , metav1.Condition {
571
- Type : string (workloadv1beta2 .Unhealthy ),
572
- Status : metav1 .ConditionTrue ,
573
- Reason : "ComponentNotFound" ,
574
- })
575
- } else {
576
- return nil , err
577
- }
579
+ } else if ! apierrors .IsNotFound (err ) {
580
+ return nil , err
578
581
}
579
582
}
580
583
}
0 commit comments