Merge pull request #111809 from Huang-Wei/retriable-sched-err

[sched] more error types when retry patching a pod's status
This commit is contained in:
Kubernetes Prow Robot 2022-08-23 19:01:05 -07:00 committed by GitHub
commit 626ff5c0c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 <old.Status> to <newStatus>,
// 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 <pod> from API server