fix: ending retry loop when the request canceled for the choosePod (#2731)
Signed-off-by: saltbo <saltbo@foxmail.com>
This commit is contained in:
@@ -292,7 +292,12 @@ func (gp *GenericPool) choosePod(ctx context.Context, newLabels map[string]strin
|
|||||||
patch := fmt.Sprintf(`{"metadata":{"annotations":%v, "labels":%v}}`, string(annotationPatch), string(labelPatch))
|
patch := fmt.Sprintf(`{"metadata":{"annotations":%v, "labels":%v}}`, string(annotationPatch), string(labelPatch))
|
||||||
logger.Info("relabel pod", zap.String("pod", patch))
|
logger.Info("relabel pod", zap.String("pod", patch))
|
||||||
newPod, err := gp.kubernetesClient.CoreV1().Pods(chosenPod.Namespace).Patch(ctx, chosenPod.Name, k8sTypes.StrategicMergePatchType, []byte(patch), metav1.PatchOptions{})
|
newPod, err := gp.kubernetesClient.CoreV1().Pods(chosenPod.Namespace).Patch(ctx, chosenPod.Name, k8sTypes.StrategicMergePatchType, []byte(patch), metav1.PatchOptions{})
|
||||||
if err != nil {
|
if err != nil && errors.Is(err, context.Canceled) {
|
||||||
|
// ending retry loop when the request canceled
|
||||||
|
gp.readyPodQueue.Done(key)
|
||||||
|
gp.readyPodQueue.AddAfter(key, expoDelay)
|
||||||
|
return "", nil, errors.Errorf("failed to relabel pod: %s", err)
|
||||||
|
} else if err != nil {
|
||||||
logger.Error("failed to relabel pod", zap.Error(err), zap.String("pod", chosenPod.Name), zap.Duration("delay", expoDelay))
|
logger.Error("failed to relabel pod", zap.Error(err), zap.String("pod", chosenPod.Name), zap.Duration("delay", expoDelay))
|
||||||
gp.readyPodQueue.Done(key)
|
gp.readyPodQueue.Done(key)
|
||||||
gp.readyPodQueue.AddAfter(key, expoDelay)
|
gp.readyPodQueue.AddAfter(key, expoDelay)
|
||||||
|
|||||||
Reference in New Issue
Block a user