You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@yunikorn.apache.org by ma...@apache.org on 2026/09/28 12:20:31 UTC

(yunikorn-k8shim) branch master updated: [YUNIKORN-3433] Send the plugin errors back to core (#1092)

This is an automated email from the ASF dual-hosted git repository.

manirajv06 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git


The following commit(s) were added to refs/heads/master by this push:
     new 07a87ef7 [YUNIKORN-3433] Send the plugin errors back to core (#1092)
07a87ef7 is described below

commit 07a87ef7d1c2b07293f1bfc76880428ee43bf54f
Author: Manikandan R <ma...@gmail.com>
AuthorDate: Mon Sep 28 17:50:05 2026 +0530

    [YUNIKORN-3433] Send the plugin errors back to core (#1092)
    
    PreFilter predicate failures would be sent through errorMessage field in PreFilterPredicatesResponse in order to be consumed by the core.
    
    Dropped Plugin name from Filter response as it has been already embedded in the error and does not even get passed back to the core. Not really required.
    
    Closes: #1092
    
    Signed-off-by: Manikandan R <ma...@gmail.com>
---
 go.mod                                          |  4 +-
 go.sum                                          |  8 +--
 pkg/cache/context.go                            |  7 +-
 pkg/cache/scheduler_callback_test.go            | 24 ++++---
 pkg/plugin/predicates/predicate_manager.go      | 27 ++++----
 pkg/plugin/predicates/predicate_manager_test.go | 86 +++++++++++++------------
 6 files changed, 80 insertions(+), 76 deletions(-)

diff --git a/go.mod b/go.mod
index ff587413..ca33a05d 100644
--- a/go.mod
+++ b/go.mod
@@ -21,8 +21,8 @@ module github.com/apache/yunikorn-k8shim
 go 1.26.0
 
 require (
-	github.com/apache/yunikorn-core v0.0.0-20260903142729-2577453c1aed
-	github.com/apache/yunikorn-scheduler-interface v0.0.0-20260902114836-aee56d9f5e48
+	github.com/apache/yunikorn-core v0.0.0-20260918084419-a38869d52bd0
+	github.com/apache/yunikorn-scheduler-interface v0.0.0-20260917064053-bd4e35e972a4
 	github.com/google/go-cmp v0.7.0
 	github.com/google/uuid v1.6.0
 	github.com/looplab/fsm v1.0.3
diff --git a/go.sum b/go.sum
index 70b5549a..a222df26 100644
--- a/go.sum
+++ b/go.sum
@@ -10,10 +10,10 @@ github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e h1:4dAU9FXIyQktp
 github.com/alexbrainman/sspi v0.0.0-20250919150558-7d374ff0d59e/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
 github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
 github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
-github.com/apache/yunikorn-core v0.0.0-20260903142729-2577453c1aed h1:ewPTgqXK1NSUVvC5b0zoyqNkAXgW7lZhGDc+F4stXe0=
-github.com/apache/yunikorn-core v0.0.0-20260903142729-2577453c1aed/go.mod h1:i7cffBji5eXhyCWewL9ubNNy3F+YiOIbu82SBoE5u7M=
-github.com/apache/yunikorn-scheduler-interface v0.0.0-20260902114836-aee56d9f5e48 h1:l0aoGpXocwRihoXoUgeyi3gu4BbcAeKa0IIxcbseZXA=
-github.com/apache/yunikorn-scheduler-interface v0.0.0-20260902114836-aee56d9f5e48/go.mod h1:eF8OKdrML/PjpazkpA71nPK1BK8kxvMAi5R+YmwheFg=
+github.com/apache/yunikorn-core v0.0.0-20260918084419-a38869d52bd0 h1:pIytRoZD0ZD2Mwv4igZHTc1NeQSvf30I2E6HTuDluyc=
+github.com/apache/yunikorn-core v0.0.0-20260918084419-a38869d52bd0/go.mod h1:syK7Af+gPUqGAyXvTwVPzhNH/MpvNSRq4DEIyy5QB80=
+github.com/apache/yunikorn-scheduler-interface v0.0.0-20260917064053-bd4e35e972a4 h1:x0P1kw8uPCuosCTBFSTHXXjaE4nBBg8fxDAMVI4OqYQ=
+github.com/apache/yunikorn-scheduler-interface v0.0.0-20260917064053-bd4e35e972a4/go.mod h1:yGzF2ElwYisgWrs6FhBuOZWMhgJmHt1wUzHGCky/bQc=
 github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
 github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
 github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
diff --git a/pkg/cache/context.go b/pkg/cache/context.go
index ee0cf9c0..ef1e6855 100644
--- a/pkg/cache/context.go
+++ b/pkg/cache/context.go
@@ -723,6 +723,7 @@ func (ctx *Context) PreFilter(name string, allocate bool) *si.PreFilterPredicate
 		return &si.PreFilterPredicatesResponse{
 			FeasibleNodes: make(map[string]*si.Empty),
 			Success:       false,
+			ErrorMessage:  ErrorPodNotFound.Error(),
 		}
 	}
 	// if pod exists in cache, try to run predicates
@@ -740,6 +741,7 @@ func (ctx *Context) PreFilter(name string, allocate bool) *si.PreFilterPredicate
 	return &si.PreFilterPredicatesResponse{
 		FeasibleNodes: make(map[string]*si.Empty),
 		Success:       false,
+		ErrorMessage:  err.Error(),
 	}
 }
 
@@ -763,10 +765,7 @@ func (ctx *Context) IsPodFitNode(name, node string, allocate bool) error {
 	if cycleState == nil {
 		return ErrorCycleStateNotFound
 	}
-	plugin, err := ctx.predManager.Filter(pod, targetNode, cycleState, allocate)
-	if err != nil {
-		err = errors.Join(fmt.Errorf("failed plugin: '%s'", plugin), err)
-	}
+	err := ctx.predManager.Filter(pod, targetNode, cycleState, allocate)
 	return err
 }
 
diff --git a/pkg/cache/scheduler_callback_test.go b/pkg/cache/scheduler_callback_test.go
index c71ce820..84a94962 100644
--- a/pkg/cache/scheduler_callback_test.go
+++ b/pkg/cache/scheduler_callback_test.go
@@ -545,8 +545,9 @@ func TestPredicatesPreFilter(t *testing.T) {
 
 	// pod not found
 	predicatesResults := callback.PreFilterPredicates(&si.PreFilterPredicatesArgs{AllocationKey: "unknown", Allocate: true})
-	assert.Equal(t, predicatesResults.Success, false)
-	assert.Equal(t, len(predicatesResults.FeasibleNodes), 0)
+	assert.Equal(t, predicatesResults.GetSuccess(), false)
+	assert.Equal(t, len(predicatesResults.GetFeasibleNodes()), 0)
+	assert.Equal(t, predicatesResults.GetErrorMessage(), "predicates were not run because pod was not found in cache")
 	assert.Assert(t, callback.context.schedulerCache.GetCycleState(&v1.Pod{ObjectMeta: apis.ObjectMeta{
 		Name: "unknown",
 		UID:  "unknown",
@@ -555,8 +556,9 @@ func TestPredicatesPreFilter(t *testing.T) {
 
 	// pod found
 	predicatesResults = callback.PreFilterPredicates(&si.PreFilterPredicatesArgs{AllocationKey: taskUID1, Allocate: true})
-	assert.Equal(t, predicatesResults.Success, true)
-	assert.Equal(t, len(predicatesResults.FeasibleNodes), 0)
+	assert.Equal(t, predicatesResults.GetSuccess(), true)
+	assert.Equal(t, len(predicatesResults.GetFeasibleNodes()), 0)
+	assert.Equal(t, predicatesResults.GetErrorMessage(), "")
 	assert.Assert(t, callback.context.schedulerCache.GetCycleState(&v1.Pod{ObjectMeta: apis.ObjectMeta{
 		Name: taskUID1,
 		UID:  taskUID1,
@@ -589,8 +591,9 @@ func TestPredicates(t *testing.T) {
 
 	// pod, node & cycle state found
 	results := callback.PreFilterPredicates(&si.PreFilterPredicatesArgs{AllocationKey: taskUID1, Allocate: true})
-	assert.Equal(t, results.Success, true)
-	assert.Equal(t, len(results.FeasibleNodes), 0)
+	assert.Equal(t, results.GetSuccess(), true)
+	assert.Equal(t, len(results.GetFeasibleNodes()), 0)
+	assert.Equal(t, results.GetErrorMessage(), "")
 	assert.Assert(t, callback.context.schedulerCache.GetCycleState(&v1.Pod{ObjectMeta: apis.ObjectMeta{
 		Name: taskUID1,
 		UID:  taskUID1,
@@ -630,8 +633,9 @@ func TestPreemptionPredicates(t *testing.T) {
 
 	// pod, node & cycle state found
 	results := callback.PreFilterPredicates(&si.PreFilterPredicatesArgs{AllocationKey: taskUID1, Allocate: true})
-	assert.Equal(t, results.Success, true)
-	assert.Equal(t, len(results.FeasibleNodes), 0)
+	assert.Equal(t, results.GetSuccess(), true)
+	assert.Equal(t, len(results.GetFeasibleNodes()), 0)
+	assert.Equal(t, results.GetErrorMessage(), "")
 	assert.Assert(t, callback.context.schedulerCache.GetCycleState(&v1.Pod{ObjectMeta: apis.ObjectMeta{
 		Name: taskUID1,
 		UID:  taskUID1,
@@ -714,8 +718,8 @@ func (m *mockPredicateManager) PreFilter(_ *v1.Pod, _ bool) (map[string]*si.Empt
 	return map[string]*si.Empty{}, framework.NewCycleState(), nil
 }
 
-func (m *mockPredicateManager) Filter(_ *v1.Pod, _ *framework.NodeInfo, _ *framework.CycleState, _ bool) (string, error) {
-	return "", nil
+func (m *mockPredicateManager) Filter(_ *v1.Pod, _ *framework.NodeInfo, _ *framework.CycleState, _ bool) error {
+	return nil
 }
 
 func (m *mockPredicateManager) PreemptionFilter(_ *v1.Pod, _ *framework.NodeInfo, _ *framework.CycleState, _ []*v1.Pod, _ int) int {
diff --git a/pkg/plugin/predicates/predicate_manager.go b/pkg/plugin/predicates/predicate_manager.go
index 085be78b..c51a8287 100644
--- a/pkg/plugin/predicates/predicate_manager.go
+++ b/pkg/plugin/predicates/predicate_manager.go
@@ -50,7 +50,7 @@ type PredicateManager interface {
 	PreFilter(pod *v1.Pod, allocate bool) (feasibleNodes map[string]*si.Empty, cycleState *framework.CycleState, error error)
 	// Filter Predicates checks if a pod can fit on a node.
 	// Returns the name of the predicate plugin that failed (may be empty) and any error encountered.
-	Filter(pod *v1.Pod, node *framework.NodeInfo, cycleState *framework.CycleState, allocate bool) (plugin string, error error)
+	Filter(pod *v1.Pod, node *framework.NodeInfo, cycleState *framework.CycleState, allocate bool) (error error)
 	// PreemptionPredicates checks if a pod can be scheduled on the node by preempting victims.
 	// Returns the victim index that allows the pod to fit, or -1 if none.
 	PreemptionFilter(pod *v1.Pod, node *framework.NodeInfo, cycleState *framework.CycleState, victims []*v1.Pod, startIndex int) (index int)
@@ -147,7 +147,7 @@ func (p *predicateManagerImpl) PreemptionFilter(pod *v1.Pod, node *framework.Nod
 	// loop through remaining pods
 	for i := startIndex; i < len(victims); i++ {
 		p.removePodFromNodeNoFail(preemptingNode, victims[i])
-		status, _ := p.runFilterPlugins(ctx, *p.allocationFilters, cycleState, pod, preemptingNode)
+		status := p.runFilterPlugins(ctx, *p.allocationFilters, cycleState, pod, preemptingNode)
 		if status.IsSuccess() {
 			return i
 		}
@@ -216,7 +216,7 @@ func (p *predicateManagerImpl) runPreFilterPlugins(ctx context.Context, cycleSta
 				zap.String("pluginName", plugin),
 				zap.String("pod", fmt.Sprintf("%s/%s", pod.Namespace, pod.Name)),
 				zap.Error(err))
-			return fwk.AsStatus(errors.Join(fmt.Errorf("running PreFilter plugin %q: ", plugin), err)), map[string]*si.Empty{}
+			return fwk.AsStatus(fmt.Errorf("PreFilter plugin %q failed", plugin)), map[string]*si.Empty{}
 		}
 		mergedPreFilterResults = mergedPreFilterResults.Merge(nodes)
 	}
@@ -231,23 +231,22 @@ func (p *predicateManagerImpl) runPreFilterPlugins(ctx context.Context, cycleSta
 	return nil, feasibleNodes
 }
 
-func (p *predicateManagerImpl) Filter(pod *v1.Pod, node *framework.NodeInfo, cycleState *framework.CycleState, allocate bool) (string, error) {
+func (p *predicateManagerImpl) Filter(pod *v1.Pod, node *framework.NodeInfo, cycleState *framework.CycleState, allocate bool) error {
 	ctx := context.Background()
 
 	var status *fwk.Status
-	var plugin string
 	if allocate {
-		status, plugin = p.runFilterPlugins(ctx, *p.allocationFilters, cycleState, pod, node)
+		status = p.runFilterPlugins(ctx, *p.allocationFilters, cycleState, pod, node)
 	} else {
-		status, plugin = p.runFilterPlugins(ctx, *p.reservationFilters, cycleState, pod, node)
+		status = p.runFilterPlugins(ctx, *p.reservationFilters, cycleState, pod, node)
 	}
 	if !status.IsSuccess() {
-		return plugin, errors.New(status.Message())
+		return errors.New(status.Message())
 	}
-	return "", nil
+	return nil
 }
 
-func (p *predicateManagerImpl) runFilterPlugins(ctx context.Context, plugins []fwk.FilterPlugin, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo fwk.NodeInfo) (*fwk.Status, string) {
+func (p *predicateManagerImpl) runFilterPlugins(ctx context.Context, plugins []fwk.FilterPlugin, cycleState *framework.CycleState, pod *v1.Pod, nodeInfo fwk.NodeInfo) *fwk.Status {
 	skipPlugins := cycleState.GetSkipFilterPlugins()
 	for _, pl := range plugins {
 		plugin := pl.Name()
@@ -261,17 +260,17 @@ func (p *predicateManagerImpl) runFilterPlugins(ctx context.Context, plugins []f
 			if !status.IsRejected() {
 				// Filter plugins are not supposed to return any status other than
 				// Success or Unschedulable.
-				status = fwk.NewStatus(fwk.Error, fmt.Sprintf("running %q filter plugin for pod %q: %v", plugin, pod.Name, status.Message()))
 				log.Log(log.ShimPredicates).Error("failed running Filter plugin",
 					zap.String("pluginName", plugin),
 					zap.String("pod", fmt.Sprintf("%s/%s", pod.Namespace, pod.Name)),
 					zap.String("message", status.Message()))
-				return status, plugin
+				status = fwk.NewStatus(fwk.Error, fmt.Sprintf("Filter plugin %q failed", plugin))
+				return status
 			}
-			return status, plugin
+			return status
 		}
 	}
-	return fwk.NewStatus(fwk.Success), ""
+	return fwk.NewStatus(fwk.Success)
 }
 
 // EnableOptionalKubernetesFeatureGates ensures that any optional Kubernetes feature gates that YuniKorn supports are
diff --git a/pkg/plugin/predicates/predicate_manager_test.go b/pkg/plugin/predicates/predicate_manager_test.go
index eb592161..aeb53f2d 100644
--- a/pkg/plugin/predicates/predicate_manager_test.go
+++ b/pkg/plugin/predicates/predicate_manager_test.go
@@ -65,14 +65,14 @@ var (
 const (
 	mockPreFilterPlugin = "mock-prefilter-plugin"
 	mockFilterPlugin    = "mock-filter-plugin"
-	injectReason        = "injected status"
-	injectFilterReason  = "injected filter status"
 )
 
 type injectedResult struct {
 	PreFilterResult *fwk.PreFilterResult `json:"preFilterResult,omitempty"`
 	PreFilterStatus int                  `json:"preFilterStatus,omitempty"`
+	PreFilterReason string               `json:"preFilterReason,omitempty"`
 	FilterStatus    int                  `json:"filterStatus,omitempty"`
+	FilterReason    string               `json:"filterReason,omitempty"`
 }
 
 // MockPreFilterPlugin implements PreFilter interface.
@@ -90,7 +90,7 @@ func (pl *MockPreFilterPlugin) Name() string {
 }
 
 func (pl *MockPreFilterPlugin) PreFilter(ctx context.Context, state fwk.CycleState, p *v1.Pod, nodes []fwk.NodeInfo) (*fwk.PreFilterResult, *fwk.Status) {
-	return pl.inj.PreFilterResult, fwk.NewStatus(fwk.Code(pl.inj.PreFilterStatus), injectReason)
+	return pl.inj.PreFilterResult, fwk.NewStatus(fwk.Code(pl.inj.PreFilterStatus), pl.inj.PreFilterReason)
 }
 
 // MockFilterPlugin implements Filter interface.
@@ -100,7 +100,7 @@ type MockFilterPlugin struct {
 }
 
 func (pl *MockFilterPlugin) Filter(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeInfo fwk.NodeInfo) *fwk.Status {
-	return fwk.NewStatus(fwk.Code(pl.inj.FilterStatus), injectFilterReason)
+	return fwk.NewStatus(fwk.Code(pl.inj.FilterStatus), pl.inj.FilterReason)
 }
 
 func (pl *MockFilterPlugin) Name() string {
@@ -250,9 +250,9 @@ func TestPodFitsHost(t *testing.T) {
 		t.Run(test.name, func(t *testing.T) {
 			nodeInfo := framework.NewNodeInfo()
 			nodeInfo.SetNode(test.node)
-			plugin, err := predicateManager.Filter(test.pod, nodeInfo, framework.NewCycleState(), true)
+			err := predicateManager.Filter(test.pod, nodeInfo, framework.NewCycleState(), true)
 			if (err == nil) != test.fits {
-				t.Errorf("%s expected fit state '%t' did not match real state and err = %v, plugin = %v", test.name, test.fits, err, plugin)
+				t.Errorf("%s expected fit state '%t' did not match real state and err = %v", test.name, test.fits, err)
 			}
 		})
 	}
@@ -393,9 +393,9 @@ func TestPodFitsHostPorts(t *testing.T) {
 			_, cycleState, err := predicateManager.PreFilter(test.pod, true)
 			assert.NilError(t, err)
 			assert.Assert(t, cycleState != nil)
-			plugin, err := predicateManager.Filter(test.pod, test.nodeInfo, cycleState, true)
-			if (err == nil) != test.fits {
-				t.Errorf("%s expected fit state '%t' did not match real state and err = %v, plugin = %v", test.name, test.fits, err, plugin)
+			pluginErr := predicateManager.Filter(test.pod, test.nodeInfo, cycleState, true)
+			if (pluginErr == nil) != test.fits {
+				t.Errorf("%s expected fit state '%t' did not match real state and err = %v", test.name, test.fits, pluginErr)
 			}
 		})
 	}
@@ -1092,9 +1092,9 @@ func TestPodFitsSelector(t *testing.T) {
 			_, cycleState, err := predicateManager.PreFilter(test.pod, true)
 			assert.NilError(t, err)
 			assert.Assert(t, cycleState != nil)
-			plugin, err := predicateManager.Filter(test.pod, nodeInfo, cycleState, true)
-			if (err == nil) != test.fits {
-				t.Errorf("%s expected fit state '%t' did not match real state and err = %v, plugin = %v", test.name, test.fits, err, plugin)
+			pluginErr := predicateManager.Filter(test.pod, nodeInfo, cycleState, true)
+			if (pluginErr == nil) != test.fits {
+				t.Errorf("%s expected fit state '%t' did not match real state and err = %v", test.name, test.fits, pluginErr)
 			}
 		})
 	}
@@ -1235,9 +1235,9 @@ func TestRunGeneralPredicates(t *testing.T) {
 			_, cycleState, err := predicateManager.PreFilter(test.pod, true)
 			assert.NilError(t, err)
 			assert.Assert(t, cycleState != nil)
-			plugin, err := predicateManager.Filter(test.pod, test.nodeInfo, cycleState, true)
-			if (err == nil) != test.fits {
-				t.Errorf("%s expected fit state '%t' did not match real state and err = %v, plugin = %v", test.name, test.fits, err, plugin)
+			pluginErr := predicateManager.Filter(test.pod, test.nodeInfo, cycleState, true)
+			if (pluginErr == nil) != test.fits {
+				t.Errorf("%s expected fit state '%t' did not match real state and err = %v", test.name, test.fits, pluginErr)
 			}
 		})
 	}
@@ -2186,9 +2186,9 @@ func TestInterPodAffinity(t *testing.T) {
 			_, cycleState, err := predicateManager.PreFilter(test.pod, true)
 			assert.NilError(t, err)
 			assert.Assert(t, cycleState != nil)
-			pl, err := predicateManager.Filter(test.pod, nodeInfo, cycleState, true)
-			if (err == nil) != test.fits {
-				t.Errorf("%s expected fit state '%t' did not match real state and err = %v, plugin = %v", test.name, test.fits, err, pl)
+			pluginErr := predicateManager.Filter(test.pod, nodeInfo, cycleState, true)
+			if (pluginErr == nil) != test.fits {
+				t.Errorf("%s expected fit state '%t' did not match real state and err = %v", test.name, test.fits, pluginErr)
 			}
 		})
 	}
@@ -2214,14 +2214,14 @@ func TestReserveAlloc(t *testing.T) {
 	config, err := DefaultConfig()
 	assert.NilError(t, err)
 	predicateManager := newPredicateManagerInternal(handle, plugins.NewInTreeRegistry(), config, ep, ep, ep, ep)
-	_, err = predicateManager.Filter(pod, nodeInfo, framework.NewCycleState(), false)
-	assert.NilError(t, err, "error should have been nil, no predicates given")
+	pluginErr := predicateManager.Filter(pod, nodeInfo, framework.NewCycleState(), false)
+	assert.NilError(t, pluginErr, "error should have been nil, no predicates given")
 
 	// add one predicate also run by reservations
 	ep[nodeunschedulable.Name] = true
 	predicateManager = newPredicateManagerInternal(handle, plugins.NewInTreeRegistry(), config, ep, ep, ep, ep)
-	_, err = predicateManager.Filter(pod, nodeInfo, framework.NewCycleState(), false)
-	assert.NilError(t, err, "error should have been nil, node is schedulable")
+	pluginErr = predicateManager.Filter(pod, nodeInfo, framework.NewCycleState(), false)
+	assert.NilError(t, pluginErr, "error should have been nil, node is schedulable")
 
 	// make the node unschedulable
 	node, _, err = taints.AddOrUpdateTaint(nodeInfo.Node(), &v1.Taint{
@@ -2231,8 +2231,8 @@ func TestReserveAlloc(t *testing.T) {
 	node.Spec.Unschedulable = true
 	assert.NilError(t, err, "failed to add taint")
 	nodeInfo.SetNode(node)
-	_, err = predicateManager.Filter(pod, nodeInfo, framework.NewCycleState(), false)
-	if err == nil {
+	pluginErr = predicateManager.Filter(pod, nodeInfo, framework.NewCycleState(), false)
+	if pluginErr == nil {
 		t.Errorf("error should not have been nil, predicate should have failed")
 	}
 }
@@ -2276,12 +2276,12 @@ func TestReserveNodeSelector(t *testing.T) {
 			_, cycleState, err := predicateManager.PreFilter(pod, true)
 			assert.NilError(t, err)
 			assert.Assert(t, cycleState != nil)
-			plugin, err := predicateManager.Filter(pod, nodeInfo, cycleState, false)
-			log.Log(log.Test).Info("reservation predicates called", zap.Error(err), zap.String("plugin", plugin))
+			pluginErr := predicateManager.Filter(pod, nodeInfo, cycleState, false)
+			log.Log(log.Test).Info("reservation predicates called", zap.Error(err))
 			if tc.errorExpected {
-				assert.Assert(t, err != nil, "An error is expected")
+				assert.Assert(t, pluginErr != nil, "An error is expected")
 			} else {
-				assert.NilError(t, err, "No error expected")
+				assert.NilError(t, pluginErr, "No error expected")
 			}
 		})
 	}
@@ -2340,24 +2340,24 @@ func TestPreFilter(t *testing.T) {
 
 		{"rejected - unschedulable and unresolvable", pod,
 			[]*MockPreFilterPlugin{
-				{name: mockPreFilterPlugin, inj: injectedResult{PreFilterResult: &fwk.PreFilterResult{}, PreFilterStatus: int(fwk.UnschedulableAndUnresolvable)}},
+				{name: mockPreFilterPlugin, inj: injectedResult{PreFilterResult: &fwk.PreFilterResult{}, PreFilterStatus: int(fwk.UnschedulableAndUnresolvable), PreFilterReason: "UnschedulableAndUnresolvable"}},
 			},
 			[]string{},
 			nil, errors.New("UnschedulableAndUnresolvable"),
 		},
 		{"rejected - unschedulable", pod,
 			[]*MockPreFilterPlugin{
-				{name: mockPreFilterPlugin, inj: injectedResult{PreFilterResult: &fwk.PreFilterResult{}, PreFilterStatus: int(fwk.Unschedulable)}},
+				{name: mockPreFilterPlugin, inj: injectedResult{PreFilterResult: &fwk.PreFilterResult{}, PreFilterStatus: int(fwk.Unschedulable), PreFilterReason: "Unschedulable"}},
 			},
 			[]string{},
-			nil, errors.New("unschedulable"),
+			nil, errors.New("Unschedulable"),
 		},
 		{"error", pod,
 			[]*MockPreFilterPlugin{
-				{name: mockPreFilterPlugin, inj: injectedResult{PreFilterResult: &fwk.PreFilterResult{}, PreFilterStatus: int(fwk.Error)}},
+				{name: mockPreFilterPlugin, inj: injectedResult{PreFilterResult: &fwk.PreFilterResult{}, PreFilterStatus: int(fwk.Error), PreFilterReason: "PreFilter plugin \"mock-prefilter-plugin\" failed"}},
 			},
 			[]string{},
-			nil, errors.New("error"),
+			nil, errors.New("PreFilter plugin \"mock-prefilter-plugin\" failed"),
 		},
 	}
 	for _, tc := range testCases {
@@ -2401,6 +2401,9 @@ func TestPreFilter(t *testing.T) {
 				}
 				if tc.errorExpected != nil {
 					assert.Assert(t, filterErr != nil, "error should not be nil")
+					assert.Equal(t, filterErr.Error(), tc.errorExpected.Error(), "error should match")
+				} else {
+					assert.NilError(t, err, filterErr)
 				}
 			}
 		})
@@ -2441,21 +2444,21 @@ func TestFilter(t *testing.T) {
 		},
 		{"rejected - unschedulable and unresolvable", pod,
 			[]*MockFilterPlugin{
-				{name: mockFilterPlugin, inj: injectedResult{FilterStatus: int(fwk.UnschedulableAndUnresolvable)}},
+				{name: mockFilterPlugin, inj: injectedResult{FilterStatus: int(fwk.UnschedulableAndUnresolvable), FilterReason: "UnschedulableAndUnresolvable"}},
 			},
 			nil, errors.New("UnschedulableAndUnresolvable"),
 		},
 		{"rejected - unschedulable", pod,
 			[]*MockFilterPlugin{
-				{name: mockFilterPlugin, inj: injectedResult{FilterStatus: int(fwk.Unschedulable)}},
+				{name: mockFilterPlugin, inj: injectedResult{FilterStatus: int(fwk.Unschedulable), FilterReason: "Unschedulable"}},
 			},
-			nil, errors.New("unschedulable"),
+			nil, errors.New("Unschedulable"),
 		},
 		{"error", pod,
 			[]*MockFilterPlugin{
-				{name: mockFilterPlugin, inj: injectedResult{FilterStatus: int(fwk.Error)}},
+				{name: mockFilterPlugin, inj: injectedResult{FilterStatus: int(fwk.Error), FilterReason: "Filter plugin \"mock-filter-plugin\" failed"}},
 			},
-			nil, errors.New("error"),
+			nil, errors.New("filter plugin \"mock-filter-plugin\" failed"),
 		},
 	}
 
@@ -2492,12 +2495,11 @@ func TestFilter(t *testing.T) {
 				}
 				nodeInfo := framework.NewNodeInfo()
 				nodeInfo.SetNode(node)
-				filter, err := p.Filter(tc.pod, nodeInfo, cycleState, allocate)
+				pluginErr := p.Filter(tc.pod, nodeInfo, cycleState, allocate)
 				if tc.errorExpected != nil {
-					assert.Assert(t, err != nil, "error should not be nil")
-					assert.Equal(t, filter, tc.filterPlugins[0].Name())
+					assert.Assert(t, pluginErr != nil, "error should not be nil")
 				} else {
-					assert.Equal(t, filter, "")
+					assert.NilError(t, pluginErr, "error should be nil")
 				}
 			}
 		})


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: issues-help@yunikorn.apache.org