diff --git a/pkg/scheduler/apis/config/validation/validation.go b/pkg/scheduler/apis/config/validation/validation.go index 12feae0e524..c50913a701f 100644 --- a/pkg/scheduler/apis/config/validation/validation.go +++ b/pkg/scheduler/apis/config/validation/validation.go @@ -115,7 +115,7 @@ func ValidatePolicy(policy config.Policy) error { priorities := make(map[string]config.PriorityPolicy, len(policy.Priorities)) for _, priority := range policy.Priorities { if priority.Weight <= 0 || priority.Weight >= config.MaxWeight { - validationErrors = append(validationErrors, fmt.Errorf("Priority %s should have a positive weight applied to it or it has overflown", priority.Name)) + validationErrors = append(validationErrors, fmt.Errorf("priority %s should have a positive weight applied to it or it has overflown", priority.Name)) } validationErrors = append(validationErrors, validateCustomPriorities(priorities, priority)) } @@ -171,7 +171,7 @@ func validateExtenders(fldPath *field.Path, extenders []config.Extender) field.E func validateCustomPriorities(priorities map[string]config.PriorityPolicy, priority config.PriorityPolicy) error { verifyRedeclaration := func(priorityType string) error { if existing, alreadyDeclared := priorities[priorityType]; alreadyDeclared { - return fmt.Errorf("Priority %q redeclares custom priority %q, from:%q", priority.Name, priorityType, existing.Name) + return fmt.Errorf("priority %q redeclares custom priority %q, from: %q", priority.Name, priorityType, existing.Name) } priorities[priorityType] = priority return nil @@ -199,7 +199,7 @@ func validateCustomPriorities(priorities map[string]config.PriorityPolicy, prior return err } } else { - return fmt.Errorf("No priority arguments set for priority %s", priority.Name) + return fmt.Errorf("no priority arguments set for priority %s", priority.Name) } } return nil diff --git a/pkg/scheduler/apis/config/validation/validation_test.go b/pkg/scheduler/apis/config/validation/validation_test.go index d1053a40c4d..f9281015a83 100644 --- a/pkg/scheduler/apis/config/validation/validation_test.go +++ b/pkg/scheduler/apis/config/validation/validation_test.go @@ -240,12 +240,12 @@ func TestValidatePolicy(t *testing.T) { { name: "no weight defined in policy", policy: config.Policy{Priorities: []config.PriorityPolicy{{Name: "NoWeightPriority"}}}, - expected: errors.New("Priority NoWeightPriority should have a positive weight applied to it or it has overflown"), + expected: errors.New("priority NoWeightPriority should have a positive weight applied to it or it has overflown"), }, { name: "policy weight is not positive", policy: config.Policy{Priorities: []config.PriorityPolicy{{Name: "NoWeightPriority", Weight: 0}}}, - expected: errors.New("Priority NoWeightPriority should have a positive weight applied to it or it has overflown"), + expected: errors.New("priority NoWeightPriority should have a positive weight applied to it or it has overflown"), }, { name: "valid weight priority", @@ -255,12 +255,12 @@ func TestValidatePolicy(t *testing.T) { { name: "invalid negative weight policy", policy: config.Policy{Priorities: []config.PriorityPolicy{{Name: "WeightPriority", Weight: -2}}}, - expected: errors.New("Priority WeightPriority should have a positive weight applied to it or it has overflown"), + expected: errors.New("priority WeightPriority should have a positive weight applied to it or it has overflown"), }, { name: "policy weight exceeds maximum", policy: config.Policy{Priorities: []config.PriorityPolicy{{Name: "WeightPriority", Weight: config.MaxWeight}}}, - expected: errors.New("Priority WeightPriority should have a positive weight applied to it or it has overflown"), + expected: errors.New("priority WeightPriority should have a positive weight applied to it or it has overflown"), }, { name: "valid weight in policy extender config", @@ -316,7 +316,7 @@ func TestValidatePolicy(t *testing.T) { {Name: "customPriority2", Weight: 1, Argument: &config.PriorityArgument{RequestedToCapacityRatioArguments: &config.RequestedToCapacityRatioArguments{}}}, }, }, - expected: errors.New("Priority \"customPriority2\" redeclares custom priority \"RequestedToCapacityRatio\", from:\"customPriority1\""), + expected: errors.New("priority \"customPriority2\" redeclares custom priority \"RequestedToCapacityRatio\", from: \"customPriority1\""), }, { name: "different weights for LabelPreference custom priority", diff --git a/pkg/scheduler/core/extender.go b/pkg/scheduler/core/extender.go index 712f0c80564..46dd305a16a 100644 --- a/pkg/scheduler/core/extender.go +++ b/pkg/scheduler/core/extender.go @@ -386,7 +386,7 @@ func (h *HTTPExtender) Bind(binding *v1.Binding) error { var result extenderv1.ExtenderBindingResult if !h.IsBinder() { // This shouldn't happen as this extender wouldn't have become a Binder. - return fmt.Errorf("Unexpected empty bindVerb in extender") + return fmt.Errorf("unexpected empty bindVerb in extender") } req := &extenderv1.ExtenderBindingArgs{ PodName: binding.Name, @@ -431,7 +431,7 @@ func (h *HTTPExtender) send(action string, args interface{}, result interface{}) defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return fmt.Errorf("Failed %v with extender at URL %v, code %v", action, url, resp.StatusCode) + return fmt.Errorf("failed %v with extender at URL %v, code %v", action, url, resp.StatusCode) } return json.NewDecoder(resp.Body).Decode(result) diff --git a/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go b/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go index 38d9e06c4da..d7d23547269 100644 --- a/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go +++ b/pkg/scheduler/framework/plugins/interpodaffinity/scoring.go @@ -207,7 +207,7 @@ func (pl *InterPodAffinity) PreScore( func getPreScoreState(cycleState *framework.CycleState) (*preScoreState, error) { c, err := cycleState.Read(preScoreStateKey) if err != nil { - return nil, fmt.Errorf("Error reading %q from cycleState: %v", preScoreStateKey, err) + return nil, fmt.Errorf("failed to read %q from cycleState: %v", preScoreStateKey, err) } s, ok := c.(*preScoreState) diff --git a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go index 3e175c956ac..769fe372a1c 100644 --- a/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go +++ b/pkg/scheduler/framework/plugins/tainttoleration/taint_toleration.go @@ -109,7 +109,7 @@ func (pl *TaintToleration) PreScore(ctx context.Context, cycleState *framework.C func getPreScoreState(cycleState *framework.CycleState) (*preScoreState, error) { c, err := cycleState.Read(preScoreStateKey) if err != nil { - return nil, fmt.Errorf("Error reading %q from cycleState: %v", preScoreStateKey, err) + return nil, fmt.Errorf("failed to read %q from cycleState: %v", preScoreStateKey, err) } s, ok := c.(*preScoreState) diff --git a/pkg/scheduler/scheduler.go b/pkg/scheduler/scheduler.go index 28958c75157..556139dc2c4 100755 --- a/pkg/scheduler/scheduler.go +++ b/pkg/scheduler/scheduler.go @@ -425,7 +425,7 @@ func (sched *Scheduler) finishBinding(fwk framework.Framework, assumed *v1.Pod, fwk.EventRecorder().Eventf(assumed, nil, v1.EventTypeNormal, "Scheduled", "Binding", "Successfully assigned %v/%v to %v", assumed.Namespace, assumed.Name, targetNode) } -// scheduleOne does the entire scheduling workflow for a single pod. It is serialized on the scheduling algorithm's host fitting. +// scheduleOne does the entire scheduling workflow for a single pod. It is serialized on the scheduling algorithm's host fitting. func (sched *Scheduler) scheduleOne(ctx context.Context) { podInfo := sched.NextPod() // pod could be nil when schedulerQueue is closed @@ -585,7 +585,7 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) { if err := sched.SchedulerCache.ForgetPod(assumedPod); err != nil { klog.Errorf("scheduler cache ForgetPod failed: %v", err) } - sched.recordSchedulingFailure(fwk, assumedPodInfo, fmt.Errorf("Binding rejected: %v", err), SchedulerError, "") + sched.recordSchedulingFailure(fwk, assumedPodInfo, fmt.Errorf("binding rejected: %w", err), SchedulerError, "") } else { // Calculating nodeResourceString can be heavy. Avoid it if klog verbosity is below 2. if klog.V(2).Enabled() { diff --git a/pkg/scheduler/scheduler_test.go b/pkg/scheduler/scheduler_test.go index b328ffa7301..9d39102ffae 100644 --- a/pkg/scheduler/scheduler_test.go +++ b/pkg/scheduler/scheduler_test.go @@ -287,7 +287,7 @@ func TestSchedulerScheduleOne(t *testing.T) { expectBind: &v1.Binding{ObjectMeta: metav1.ObjectMeta{Name: "foo", UID: types.UID("foo")}, Target: v1.ObjectReference{Kind: "Node", Name: testNode.Name}}, expectAssumedPod: podWithID("foo", testNode.Name), injectBindError: errB, - expectError: errors.New(`Binding rejected: running Bind plugin "DefaultBinder": binder`), + expectError: fmt.Errorf(`binding rejected: %w`, fmt.Errorf("running Bind plugin %q: %w", "DefaultBinder", errors.New("binder"))), expectErrorPod: podWithID("foo", testNode.Name), expectForgetPod: podWithID("foo", testNode.Name), eventReason: "FailedScheduling", diff --git a/test/e2e/scheduling/ubernetes_lite.go b/test/e2e/scheduling/ubernetes_lite.go index 898d2d8ee45..0e019571c80 100644 --- a/test/e2e/scheduling/ubernetes_lite.go +++ b/test/e2e/scheduling/ubernetes_lite.go @@ -125,7 +125,7 @@ func getZoneNameForNode(node v1.Node) (string, error) { return value, nil } } - return "", fmt.Errorf("Zone name for node %s not found. No label with key %s", + return "", fmt.Errorf("node %s doesn't have zone label %s", node.Name, v1.LabelFailureDomainBetaZone) } diff --git a/test/integration/scheduler/preemption_test.go b/test/integration/scheduler/preemption_test.go index 1dfc2ce1a0f..c0d9e31fbae 100644 --- a/test/integration/scheduler/preemption_test.go +++ b/test/integration/scheduler/preemption_test.go @@ -653,7 +653,7 @@ func TestPodPriorityResolution(t *testing.T) { Namespace: metav1.NamespaceSystem, PriorityClassName: "foo", }), - ExpectedError: fmt.Errorf("Error creating pause pod: pods \"pod3-system-cluster-critical\" is forbidden: no PriorityClass with name foo was found"), + ExpectedError: fmt.Errorf("failed to create pause pod: pods \"pod3-system-cluster-critical\" is forbidden: no PriorityClass with name foo was found"), }, } diff --git a/test/integration/scheduler/util.go b/test/integration/scheduler/util.go index 2251123fc49..d64ef8535ad 100644 --- a/test/integration/scheduler/util.go +++ b/test/integration/scheduler/util.go @@ -263,13 +263,13 @@ func createPausePodWithResource(cs clientset.Interface, podName string, func runPausePod(cs clientset.Interface, pod *v1.Pod) (*v1.Pod, error) { pod, err := cs.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{}) if err != nil { - return nil, fmt.Errorf("Error creating pause pod: %v", err) + return nil, fmt.Errorf("failed to create pause pod: %v", err) } if err = testutils.WaitForPodToSchedule(cs, pod); err != nil { return pod, fmt.Errorf("Pod %v/%v didn't schedule successfully. Error: %v", pod.Namespace, pod.Name, err) } if pod, err = cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}); err != nil { - return pod, fmt.Errorf("Error getting pod %v/%v info: %v", pod.Namespace, pod.Name, err) + return pod, fmt.Errorf("failed to get pod %v/%v info: %v", pod.Namespace, pod.Name, err) } return pod, nil } @@ -300,13 +300,13 @@ func initPodWithContainers(cs clientset.Interface, conf *podWithContainersConfig func runPodWithContainers(cs clientset.Interface, pod *v1.Pod) (*v1.Pod, error) { pod, err := cs.CoreV1().Pods(pod.Namespace).Create(context.TODO(), pod, metav1.CreateOptions{}) if err != nil { - return nil, fmt.Errorf("Error creating pod-with-containers: %v", err) + return nil, fmt.Errorf("failed to create pod-with-containers: %v", err) } if err = testutils.WaitForPodToSchedule(cs, pod); err != nil { return pod, fmt.Errorf("Pod %v didn't schedule successfully. Error: %v", pod.Name, err) } if pod, err = cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}); err != nil { - return pod, fmt.Errorf("Error getting pod %v info: %v", pod.Name, err) + return pod, fmt.Errorf("failed to get pod %v info: %v", pod.Name, err) } return pod, nil }