mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
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:
commit
626ff5c0c0
@ -23,6 +23,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
@ -92,6 +93,12 @@ func MoreImportantPod(pod1, pod2 *v1.Pod) bool {
|
|||||||
return GetPodStartTime(pod1).Before(GetPodStartTime(pod2))
|
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>,
|
// PatchPodStatus calculates the delta bytes change from <old.Status> to <newStatus>,
|
||||||
// and then submit a request to API server to patch the pod changes.
|
// 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 {
|
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 err
|
||||||
}
|
}
|
||||||
|
|
||||||
return retry.OnError(retry.DefaultBackoff, net.IsConnectionRefused, patchFn)
|
return retry.OnError(retry.DefaultBackoff, Retriable, patchFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeletePod deletes the given <pod> from API server
|
// DeletePod deletes the given <pod> from API server
|
||||||
|
Loading…
Reference in New Issue
Block a user