Handle not found case for status update
If we don't handle the "pod not found" case then we end up with the pod getting re-queued over and over until the max retries are hit. It also blocks the queue for other pod status updates for that pod namespace/name.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
pkgerrors "github.com/pkg/errors"
|
pkgerrors "github.com/pkg/errors"
|
||||||
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/trace"
|
"github.com/virtual-kubelet/virtual-kubelet/trace"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
@@ -206,7 +207,7 @@ func (pc *PodController) updatePodStatus(ctx context.Context, pod *corev1.Pod) e
|
|||||||
ctx = addPodAttributes(ctx, span, pod)
|
ctx = addPodAttributes(ctx, span, pod)
|
||||||
|
|
||||||
status, err := pc.provider.GetPodStatus(ctx, pod.Namespace, pod.Name)
|
status, err := pc.provider.GetPodStatus(ctx, pod.Namespace, pod.Name)
|
||||||
if err != nil {
|
if err != nil && !errdefs.IsNotFound(err) {
|
||||||
span.SetStatus(err)
|
span.SetStatus(err)
|
||||||
return pkgerrors.Wrap(err, "error retreiving pod status")
|
return pkgerrors.Wrap(err, "error retreiving pod status")
|
||||||
}
|
}
|
||||||
@@ -277,6 +278,10 @@ func (pc *PodController) podStatusHandler(ctx context.Context, key string) (retE
|
|||||||
|
|
||||||
pod, err := pc.podsLister.Pods(namespace).Get(name)
|
pod, err := pc.podsLister.Pods(namespace).Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
log.G(ctx).WithError(err).Debug("Skipping pod status update for pod missing in Kubernetes")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return pkgerrors.Wrap(err, "error looking up pod")
|
return pkgerrors.Wrap(err, "error looking up pod")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func handleQueueItem(ctx context.Context, q workqueue.RateLimitingInterface, han
|
|||||||
if err := handler(ctx, key); err != nil {
|
if err := handler(ctx, key); err != nil {
|
||||||
if q.NumRequeues(key) < maxRetries {
|
if q.NumRequeues(key) < maxRetries {
|
||||||
// Put the item back on the work queue to handle any transient errors.
|
// Put the item back on the work queue to handle any transient errors.
|
||||||
log.G(ctx).Warnf("requeuing %q due to failed sync: %v", key, err)
|
log.G(ctx).WithError(err).Warnf("requeuing %q due to failed sync", key)
|
||||||
q.AddRateLimited(key)
|
q.AddRateLimited(key)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user