Skip to content

Commit

Permalink
fix: ending retry loop when the request canceled for the choosePod (#…
Browse files Browse the repository at this point in the history
…2731)

Signed-off-by: saltbo <saltbo@foxmail.com>
  • Loading branch information
saltbo committed Mar 21, 2023
1 parent a96b92f commit 963081e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/executor/executortype/poolmgr/gp.go
Expand Up @@ -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))
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{})
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))
gp.readyPodQueue.Done(key)
gp.readyPodQueue.AddAfter(key, expoDelay)
Expand Down

0 comments on commit 963081e

Please sign in to comment.