when the hint fn returns error, the scheduling queue logs the error and treats it as QueueAfterBackoff.
Co-authored-by: Kensei Nakada <handbomusic@gmail.com> Co-authored-by: Kante Yin <kerthcet@gmail.com> Co-authored-by: XsWack <xushiwei5@huawei.com>
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/net"
|
||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||
clienttesting "k8s.io/client-go/testing"
|
||||
"k8s.io/klog/v2"
|
||||
extenderv1 "k8s.io/kube-scheduler/extender/v1"
|
||||
)
|
||||
|
||||
@@ -487,3 +488,57 @@ func Test_As_Node(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Test_As_KMetadata tests the As function with Pod.
|
||||
func Test_As_KMetadata(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
oldObj interface{}
|
||||
newObj interface{}
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "nil old Pod",
|
||||
oldObj: nil,
|
||||
newObj: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "nil new Pod",
|
||||
oldObj: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
|
||||
newObj: nil,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "two different kinds of objects",
|
||||
oldObj: &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
|
||||
newObj: &v1.Node{ObjectMeta: metav1.ObjectMeta{Name: "foo"}},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "unknown old type",
|
||||
oldObj: "unknown type",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "unknown new type",
|
||||
newObj: "unknown type",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
_, _, err := As[klog.KMetadata](tc.oldObj, tc.newObj)
|
||||
if err != nil && !tc.wantErr {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if tc.wantErr {
|
||||
if err == nil {
|
||||
t.Fatalf("expected error, but got nil")
|
||||
}
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user