From 63a7e6da89fbbe28ddec6447d40a75db243a87d7 Mon Sep 17 00:00:00 2001 From: "shenmu.wy" Date: Tue, 12 Dec 2023 14:05:13 +0800 Subject: [PATCH] add reasons to filters --- pkg/controller/manager/scheduler/filter/affinity.go | 4 ++++ pkg/controller/manager/scheduler/filter/basic.go | 1 + pkg/controller/manager/scheduler/filter/error.go | 3 +++ 3 files changed, 8 insertions(+) diff --git a/pkg/controller/manager/scheduler/filter/affinity.go b/pkg/controller/manager/scheduler/filter/affinity.go index e2a1386..3994632 100644 --- a/pkg/controller/manager/scheduler/filter/affinity.go +++ b/pkg/controller/manager/scheduler/filter/affinity.go @@ -18,6 +18,7 @@ func AffinityFilterFunc(ctx *FilterContext, n *state.Node, vol *v1.AntstorVolume match, err := schedcore.MatchNodeSelectorTerms(convertNodeInfo(n.Info), vol.Spec.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution) if !match || err != nil { klog.Infof("[SchedFail] vol=%s Pool %s NodeAffnity fail", vol.Name, n.Pool.Name) + ctx.Error.AddReason(ReasonNodeAffinity) return false } } @@ -31,6 +32,7 @@ func AffinityFilterFunc(ctx *FilterContext, n *state.Node, vol *v1.AntstorVolume matched := selector.Matches(labels.Set(n.Info.Labels)) if !matched { klog.Infof("[SchedFail] vol=%s Pool %s NodeLabelSelector fail", vol.Name, n.Pool.Name) + ctx.Error.AddReason(ReasonNodeAffinity) return false } } @@ -41,6 +43,7 @@ func AffinityFilterFunc(ctx *FilterContext, n *state.Node, vol *v1.AntstorVolume match, err := schedcore.MatchNodeSelectorTerms(convertPoolLabels(n.Pool.Labels), vol.Spec.PoolAffinity.RequiredDuringSchedulingIgnoredDuringExecution) if !match || err != nil { klog.Infof("[SchedFail] vol=%s Pool %s PoolAffinity fail", vol.Name, n.Pool.Name) + ctx.Error.AddReason(ReasonPoolAffinity) return false } } @@ -52,6 +55,7 @@ func AffinityFilterFunc(ctx *FilterContext, n *state.Node, vol *v1.AntstorVolume matched := selector.Matches(labels.Set(n.Pool.Labels)) if !matched { klog.Infof("[SchedFail] vol=%s Pool %s PoolLabelSelector fail", vol.Name, n.Pool.Name) + ctx.Error.AddReason(ReasonPoolAffinity) return false } } diff --git a/pkg/controller/manager/scheduler/filter/basic.go b/pkg/controller/manager/scheduler/filter/basic.go index 8132bdd..9c9956e 100644 --- a/pkg/controller/manager/scheduler/filter/basic.go +++ b/pkg/controller/manager/scheduler/filter/basic.go @@ -11,6 +11,7 @@ func BasicFilterFunc(ctx *FilterContext, n *state.Node, vol *v1.AntstorVolume) b // consider Pool status if !n.Pool.IsSchedulable() { klog.Infof("[SchedFail] vol=%s Pool %s status is %s, or check Pool labels", vol.Name, n.Pool.Name, n.Pool.Status.Status) + ctx.Error.AddReason(ReasonPoolUnschedulable) return false } diff --git a/pkg/controller/manager/scheduler/filter/error.go b/pkg/controller/manager/scheduler/filter/error.go index 07ae84b..dc2d24a 100644 --- a/pkg/controller/manager/scheduler/filter/error.go +++ b/pkg/controller/manager/scheduler/filter/error.go @@ -13,6 +13,9 @@ const ( ReasonPositionNotMatch = "PositionNotMatch" ReasonVolTypeNotMatch = "VolTypeNotMatch" ReasonDataConflict = "DataConflict" + ReasonNodeAffinity = "NodeAffinity" + ReasonPoolAffinity = "PoolAffinity" + ReasonPoolUnschedulable = "PoolUnschedulable" NoStoragePoolAvailable = "NoStoragePoolAvailable" //