diff --git a/pkg/scheduler/algorithm/predicates/error.go b/pkg/scheduler/algorithm/predicates/error.go index f6fd6ad7ca4..bf1518add33 100644 --- a/pkg/scheduler/algorithm/predicates/error.go +++ b/pkg/scheduler/algorithm/predicates/error.go @@ -71,10 +71,6 @@ var ( ErrNodeUnschedulable = NewPredicateFailureError("NodeUnschedulable", "node(s) were unschedulable") // ErrNodeUnknownCondition is used for NodeUnknownCondition predicate error. ErrNodeUnknownCondition = NewPredicateFailureError("NodeUnknownCondition", "node(s) had unknown conditions") - // ErrVolumeNodeConflict is used for VolumeNodeAffinityConflict predicate error. - ErrVolumeNodeConflict = NewPredicateFailureError("VolumeNodeAffinityConflict", "node(s) had volume node affinity conflict") - // ErrVolumeBindConflict is used for VolumeBindingNoMatch predicate error. - ErrVolumeBindConflict = NewPredicateFailureError("VolumeBindingNoMatch", "node(s) didn't find available persistent volumes to bind") // ErrTopologySpreadConstraintsNotMatch is used for EvenPodsSpread predicate error. ErrTopologySpreadConstraintsNotMatch = NewPredicateFailureError("EvenPodsSpreadNotMatch", "node(s) didn't match pod topology spread constraints") // ErrFakePredicate is used for test only. The fake predicates returning false also returns error @@ -99,8 +95,6 @@ var unresolvablePredicateFailureErrors = map[PredicateFailureReason]struct{}{ ErrNodeUnschedulable: {}, ErrNodeUnknownCondition: {}, ErrVolumeZoneConflict: {}, - ErrVolumeNodeConflict: {}, - ErrVolumeBindConflict: {}, } // UnresolvablePredicateExists checks if there is at least one unresolvable predicate failure reason. diff --git a/pkg/scheduler/core/BUILD b/pkg/scheduler/core/BUILD index 1e1b75e24a2..deb3a7b47dc 100644 --- a/pkg/scheduler/core/BUILD +++ b/pkg/scheduler/core/BUILD @@ -57,6 +57,7 @@ go_test( "//pkg/scheduler/framework/plugins/interpodaffinity:go_default_library", "//pkg/scheduler/framework/plugins/noderesources:go_default_library", "//pkg/scheduler/framework/plugins/podtopologyspread:go_default_library", + "//pkg/scheduler/framework/plugins/volumebinding:go_default_library", "//pkg/scheduler/framework/v1alpha1:go_default_library", "//pkg/scheduler/internal/cache:go_default_library", "//pkg/scheduler/internal/queue:go_default_library", diff --git a/pkg/scheduler/core/generic_scheduler_test.go b/pkg/scheduler/core/generic_scheduler_test.go index 07255473567..a90e6f1357d 100644 --- a/pkg/scheduler/core/generic_scheduler_test.go +++ b/pkg/scheduler/core/generic_scheduler_test.go @@ -46,6 +46,7 @@ import ( "k8s.io/kubernetes/pkg/scheduler/framework/plugins/interpodaffinity" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/noderesources" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/podtopologyspread" + "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache" internalqueue "k8s.io/kubernetes/pkg/scheduler/internal/queue" @@ -1929,8 +1930,8 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { name: "ErrVolume... errors should not be tried as it indicates that the pod is unschedulable due to no matching volumes for pod on node", nodesStatuses: framework.NodeToStatusMap{ "machine1": framework.NewStatus(framework.UnschedulableAndUnresolvable, algorithmpredicates.ErrVolumeZoneConflict.GetReason()), - "machine2": framework.NewStatus(framework.UnschedulableAndUnresolvable, algorithmpredicates.ErrVolumeNodeConflict.GetReason()), - "machine3": framework.NewStatus(framework.UnschedulableAndUnresolvable, algorithmpredicates.ErrVolumeBindConflict.GetReason()), + "machine2": framework.NewStatus(framework.UnschedulableAndUnresolvable, volumebinding.ErrReasonNodeConflict), + "machine3": framework.NewStatus(framework.UnschedulableAndUnresolvable, volumebinding.ErrReasonBindConflict), }, expected: map[string]bool{"machine4": true}, }, diff --git a/pkg/scheduler/framework/plugins/volumebinding/BUILD b/pkg/scheduler/framework/plugins/volumebinding/BUILD index 56b09906860..dcdd72415b6 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/BUILD +++ b/pkg/scheduler/framework/plugins/volumebinding/BUILD @@ -6,7 +6,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumebinding", visibility = ["//visibility:public"], deps = [ - "//pkg/scheduler/algorithm/predicates:go_default_library", "//pkg/scheduler/framework/v1alpha1:go_default_library", "//pkg/scheduler/nodeinfo:go_default_library", "//pkg/scheduler/volumebinder:go_default_library", @@ -34,7 +33,6 @@ go_test( embed = [":go_default_library"], deps = [ "//pkg/controller/volume/scheduling:go_default_library", - "//pkg/scheduler/algorithm/predicates:go_default_library", "//pkg/scheduler/framework/v1alpha1:go_default_library", "//pkg/scheduler/nodeinfo:go_default_library", "//pkg/scheduler/volumebinder:go_default_library", diff --git a/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go b/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go index c12e78637fb..305573e9aba 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go +++ b/pkg/scheduler/framework/plugins/volumebinding/volume_binding.go @@ -20,7 +20,6 @@ import ( "context" v1 "k8s.io/api/core/v1" - "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" "k8s.io/kubernetes/pkg/scheduler/volumebinder" @@ -36,6 +35,13 @@ var _ framework.FilterPlugin = &VolumeBinding{} // Name is the name of the plugin used in Registry and configurations. const Name = "VolumeBinding" +const ( + // ErrReasonBindConflict is used for VolumeBindingNoMatch predicate error. + ErrReasonBindConflict = "node(s) didn't find available persistent volumes to bind" + // ErrReasonNodeConflict is used for VolumeNodeAffinityConflict predicate error. + ErrReasonNodeConflict = "node(s) had volume node affinity conflict" +) + // Name returns name of the plugin. It is used in logs, etc. func (pl *VolumeBinding) Name() string { return Name @@ -81,10 +87,10 @@ func (pl *VolumeBinding) Filter(ctx context.Context, cs *framework.CycleState, p if !boundSatisfied || !unboundSatisfied { status := framework.NewStatus(framework.UnschedulableAndUnresolvable) if !boundSatisfied { - status.AppendReason(predicates.ErrVolumeNodeConflict.GetReason()) + status.AppendReason(ErrReasonNodeConflict) } if !unboundSatisfied { - status.AppendReason(predicates.ErrVolumeBindConflict.GetReason()) + status.AppendReason(ErrReasonBindConflict) } return status } diff --git a/pkg/scheduler/framework/plugins/volumebinding/volume_binding_test.go b/pkg/scheduler/framework/plugins/volumebinding/volume_binding_test.go index 5cbc03392f6..557112e9780 100644 --- a/pkg/scheduler/framework/plugins/volumebinding/volume_binding_test.go +++ b/pkg/scheduler/framework/plugins/volumebinding/volume_binding_test.go @@ -24,7 +24,6 @@ import ( v1 "k8s.io/api/core/v1" volumescheduling "k8s.io/kubernetes/pkg/controller/volume/scheduling" - "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo" "k8s.io/kubernetes/pkg/scheduler/volumebinder" @@ -73,7 +72,7 @@ func TestVolumeBinding(t *testing.T) { FindUnboundSatsified: false, FindBoundSatsified: true, }, - wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, predicates.ErrVolumeBindConflict.GetReason()), + wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonBindConflict), }, { name: "bound and unbound unsatisfied", @@ -83,8 +82,8 @@ func TestVolumeBinding(t *testing.T) { FindUnboundSatsified: false, FindBoundSatsified: false, }, - wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, predicates.ErrVolumeNodeConflict.GetReason(), - predicates.ErrVolumeBindConflict.GetReason()), + wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, ErrReasonNodeConflict, + ErrReasonBindConflict), }, { name: "unbound/found matches/bind succeeds",