Skip to content

Commit abb37f7

Browse files
authored
fix: pod group controller fails on missing priority class (#271)
1 parent 33727f0 commit abb37f7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pkg/podgroupcontroller/utilities/pod-group/preemptible.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import (
77
"context"
88

99
schedulingv1 "k8s.io/api/scheduling/v1"
10+
"k8s.io/apimachinery/pkg/api/errors"
1011
"k8s.io/apimachinery/pkg/types"
1112
"sigs.k8s.io/controller-runtime/pkg/client"
13+
"sigs.k8s.io/controller-runtime/pkg/log"
1214

1315
"github.com/NVIDIA/KAI-scheduler/pkg/apis/scheduling/v2alpha2"
1416
)
@@ -19,6 +21,16 @@ const (
1921

2022
func IsPreemptible(ctx context.Context, podGroup *v2alpha2.PodGroup, kubeClient client.Client) (bool, error) {
2123
priority, err := getPodGroupPriority(ctx, podGroup, kubeClient)
24+
if errors.IsNotFound(err) {
25+
logger := log.FromContext(ctx)
26+
logger.Info(
27+
"Priority Class not found",
28+
"podGroup", podGroup.Name,
29+
"namespace", podGroup.Namespace,
30+
"priorityClass", podGroup.Spec.PriorityClassName,
31+
)
32+
return true, nil
33+
}
2234
if err != nil {
2335
return false, err
2436
}

pkg/podgroupcontroller/utilities/pod-group/preemptible_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ func TestIsPreemptibleJob(t *testing.T) {
110110
},
111111
},
112112
},
113-
false,
114113
true,
114+
false,
115115
},
116116
{
117117
"Custom preemptable class",

0 commit comments

Comments
 (0)