From d95d6ba526438045cad361f9a63b3ad28018df22 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Tue, 18 Mar 2025 12:18:25 +0100 Subject: [PATCH] DRA scheduler: fix potential panic during unit test verification If there was an unexpected status, the code extracting the expected error message crashed with a panic. Happened once so far, for unknown reasons because the unexpected status then didn't get logged. --- .../plugins/dynamicresources/dynamicresources_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go index 0b85ac77aac..64339188a63 100644 --- a/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go +++ b/pkg/scheduler/framework/plugins/dynamicresources/dynamicresources_test.go @@ -1047,7 +1047,9 @@ type testContext struct { func (tc *testContext) verify(t *testing.T, expected result, initialObjects []metav1.Object, result interface{}, status *framework.Status) { t.Helper() - if actualErr := status.AsError(); actualErr != nil { + if expected.status == nil { + assert.Nil(t, status) + } else if actualErr := status.AsError(); actualErr != nil { // Compare only the error strings. assert.ErrorContains(t, actualErr, expected.status.AsError().Error()) } else {