diff --git a/pkg/scheduler/algorithm/predicates/error.go b/pkg/scheduler/algorithm/predicates/error.go index bf1518add33..5860ef3048d 100644 --- a/pkg/scheduler/algorithm/predicates/error.go +++ b/pkg/scheduler/algorithm/predicates/error.go @@ -31,8 +31,6 @@ var ( // it can never be made to pass by removing pods, you need to add the predicate // failure error in nodesWherePreemptionMightHelp() in scheduler/core/generic_scheduler.go - // ErrDiskConflict is used for NoDiskConflict predicate error. - ErrDiskConflict = NewPredicateFailureError("NoDiskConflict", "node(s) had no available disk") // ErrVolumeZoneConflict is used for NoVolumeZoneConflict predicate error. ErrVolumeZoneConflict = NewPredicateFailureError("NoVolumeZoneConflict", "node(s) had no available volume zone") // ErrNodeSelectorNotMatch is used for MatchNodeSelector predicate error. diff --git a/pkg/scheduler/core/BUILD b/pkg/scheduler/core/BUILD index deb3a7b47dc..6e0e77e7a62 100644 --- a/pkg/scheduler/core/BUILD +++ b/pkg/scheduler/core/BUILD @@ -58,6 +58,7 @@ go_test( "//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/plugins/volumerestrictions: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 a90e6f1357d..64f650a93ce 100644 --- a/pkg/scheduler/core/generic_scheduler_test.go +++ b/pkg/scheduler/core/generic_scheduler_test.go @@ -27,6 +27,8 @@ import ( "testing" "time" + "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumerestrictions" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -1903,7 +1905,7 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { name: "Mix of failed predicates works fine", nodesStatuses: framework.NodeToStatusMap{ "machine1": framework.NewStatus(framework.UnschedulableAndUnresolvable, algorithmpredicates.ErrNodeUnderDiskPressure.GetReason()), - "machine2": framework.NewStatus(framework.UnschedulableAndUnresolvable, algorithmpredicates.ErrDiskConflict.GetReason()), + "machine2": framework.NewStatus(framework.UnschedulableAndUnresolvable, volumerestrictions.ErrReasonDiskConflict), "machine3": framework.NewStatus(framework.Unschedulable, algorithmpredicates.NewInsufficientResourceError(v1.ResourceMemory, 1000, 600, 400).GetReason()), }, expected: map[string]bool{"machine3": true, "machine4": true}, @@ -1976,7 +1978,7 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) { func TestPreempt(t *testing.T) { defaultFailedNodeToStatusMap := framework.NodeToStatusMap{ "machine1": framework.NewStatus(framework.Unschedulable, algorithmpredicates.NewInsufficientResourceError(v1.ResourceMemory, 1000, 500, 300).GetReason()), - "machine2": framework.NewStatus(framework.Unschedulable, algorithmpredicates.ErrDiskConflict.GetReason()), + "machine2": framework.NewStatus(framework.Unschedulable, volumerestrictions.ErrReasonDiskConflict), "machine3": framework.NewStatus(framework.Unschedulable, algorithmpredicates.NewInsufficientResourceError(v1.ResourceMemory, 1000, 600, 400).GetReason()), } // Prepare 3 node names. diff --git a/pkg/scheduler/framework/plugins/migration/utils_test.go b/pkg/scheduler/framework/plugins/migration/utils_test.go index 9d11c8a6e67..8b5abcb2355 100644 --- a/pkg/scheduler/framework/plugins/migration/utils_test.go +++ b/pkg/scheduler/framework/plugins/migration/utils_test.go @@ -43,7 +43,7 @@ func TestPredicateResultToFrameworkStatus(t *testing.T) { { name: "Error with reason", err: errors.New("Failed with error"), - reasons: []predicates.PredicateFailureReason{predicates.ErrDiskConflict}, + reasons: []predicates.PredicateFailureReason{predicates.ErrTaintsTolerationsNotMatch}, wantStatus: framework.NewStatus(framework.Error, "Failed with error"), }, { @@ -53,8 +53,8 @@ func TestPredicateResultToFrameworkStatus(t *testing.T) { }, { name: "Unschedulable and Unresolvable", - reasons: []predicates.PredicateFailureReason{predicates.ErrDiskConflict, predicates.ErrNodeSelectorNotMatch}, - wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "node(s) had no available disk", "node(s) didn't match node selector"), + reasons: []predicates.PredicateFailureReason{predicates.ErrTaintsTolerationsNotMatch, predicates.ErrNodeSelectorNotMatch}, + wantStatus: framework.NewStatus(framework.UnschedulableAndUnresolvable, "node(s) had taints that the pod didn't tolerate", "node(s) didn't match node selector"), }, } for _, tt := range tests { diff --git a/pkg/scheduler/framework/plugins/volumerestrictions/BUILD b/pkg/scheduler/framework/plugins/volumerestrictions/BUILD index a35654afb94..927cba1ebf5 100644 --- a/pkg/scheduler/framework/plugins/volumerestrictions/BUILD +++ b/pkg/scheduler/framework/plugins/volumerestrictions/BUILD @@ -6,7 +6,6 @@ go_library( importpath = "k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumerestrictions", visibility = ["//visibility:public"], deps = [ - "//pkg/scheduler/algorithm/predicates:go_default_library", "//pkg/scheduler/framework/v1alpha1:go_default_library", "//pkg/scheduler/nodeinfo:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", @@ -33,7 +32,6 @@ go_test( srcs = ["volume_restrictions_test.go"], embed = [":go_default_library"], deps = [ - "//pkg/scheduler/algorithm/predicates:go_default_library", "//pkg/scheduler/framework/v1alpha1:go_default_library", "//pkg/scheduler/nodeinfo:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", diff --git a/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go b/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go index 01cdbf4b2f1..33299b29e26 100644 --- a/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go +++ b/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions.go @@ -21,7 +21,6 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates" framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1" "k8s.io/kubernetes/pkg/scheduler/nodeinfo" ) @@ -34,6 +33,11 @@ var _ framework.FilterPlugin = &VolumeRestrictions{} // Name is the name of the plugin used in the plugin registry and configurations. const Name = "VolumeRestrictions" +const ( + // ErrReasonDiskConflict is used for NoDiskConflict predicate error. + ErrReasonDiskConflict = "node(s) had no available disk" +) + // Name returns name of the plugin. It is used in logs, etc. func (pl *VolumeRestrictions) Name() string { return Name @@ -118,7 +122,7 @@ func (pl *VolumeRestrictions) Filter(ctx context.Context, _ *framework.CycleStat for _, v := range pod.Spec.Volumes { for _, ev := range nodeInfo.Pods() { if isVolumeConflict(v, ev) { - return framework.NewStatus(framework.Unschedulable, predicates.ErrDiskConflict.GetReason()) + return framework.NewStatus(framework.Unschedulable, ErrReasonDiskConflict) } } } diff --git a/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions_test.go b/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions_test.go index b31e4947ab4..7efd8a84b84 100644 --- a/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions_test.go +++ b/pkg/scheduler/framework/plugins/volumerestrictions/volume_restrictions_test.go @@ -22,7 +22,6 @@ import ( "testing" 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" ) @@ -50,7 +49,7 @@ func TestGCEDiskConflicts(t *testing.T) { }, }, } - errStatus := framework.NewStatus(framework.Unschedulable, predicates.ErrDiskConflict.GetReason()) + errStatus := framework.NewStatus(framework.Unschedulable, ErrReasonDiskConflict) tests := []struct { pod *v1.Pod nodeInfo *schedulernodeinfo.NodeInfo @@ -98,7 +97,7 @@ func TestAWSDiskConflicts(t *testing.T) { }, }, } - errStatus := framework.NewStatus(framework.Unschedulable, predicates.ErrDiskConflict.GetReason()) + errStatus := framework.NewStatus(framework.Unschedulable, ErrReasonDiskConflict) tests := []struct { pod *v1.Pod nodeInfo *schedulernodeinfo.NodeInfo @@ -152,7 +151,7 @@ func TestRBDDiskConflicts(t *testing.T) { }, }, } - errStatus := framework.NewStatus(framework.Unschedulable, predicates.ErrDiskConflict.GetReason()) + errStatus := framework.NewStatus(framework.Unschedulable, ErrReasonDiskConflict) tests := []struct { pod *v1.Pod nodeInfo *schedulernodeinfo.NodeInfo @@ -206,7 +205,7 @@ func TestISCSIDiskConflicts(t *testing.T) { }, }, } - errStatus := framework.NewStatus(framework.Unschedulable, predicates.ErrDiskConflict.GetReason()) + errStatus := framework.NewStatus(framework.Unschedulable, ErrReasonDiskConflict) tests := []struct { pod *v1.Pod nodeInfo *schedulernodeinfo.NodeInfo