diff --git a/pkg/scheduler/util/utils.go b/pkg/scheduler/util/utils.go index c597510fb62..6cc18eee74b 100644 --- a/pkg/scheduler/util/utils.go +++ b/pkg/scheduler/util/utils.go @@ -23,6 +23,7 @@ import ( "time" v1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" utilerrors "k8s.io/apimachinery/pkg/util/errors" @@ -92,6 +93,12 @@ func MoreImportantPod(pod1, pod2 *v1.Pod) bool { return GetPodStartTime(pod1).Before(GetPodStartTime(pod2)) } +// Retriable defines the retriable errors during a scheduling cycle. +func Retriable(err error) bool { + return apierrors.IsInternalError(err) || apierrors.IsServiceUnavailable(err) || + net.IsConnectionRefused(err) +} + // PatchPodStatus calculates the delta bytes change from to , // and then submit a request to API server to patch the pod changes. func PatchPodStatus(ctx context.Context, cs kubernetes.Interface, old *v1.Pod, newStatus *v1.PodStatus) error { @@ -122,7 +129,7 @@ func PatchPodStatus(ctx context.Context, cs kubernetes.Interface, old *v1.Pod, n return err } - return retry.OnError(retry.DefaultBackoff, net.IsConnectionRefused, patchFn) + return retry.OnError(retry.DefaultBackoff, Retriable, patchFn) } // DeletePod deletes the given from API server