Skip to content

Commit

Permalink
fix updateTaskRunStatusForTimeout get pod switch/case may cause pod n…
Browse files Browse the repository at this point in the history
…ot deleted when taskRun timeout.
  • Loading branch information
assertion authored and tekton-robot committed Jan 22, 2020
1 parent 020137e commit b23f7d4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,17 +511,14 @@ func (c *Reconciler) updateTaskRunStatusForTimeout(tr *v1alpha1.TaskRun) error {
//
// If there's no such Pod, there's nothing to delete.
pod, err := getPod(tr, c.KubeClientSet)
switch {
case err == nil:
// Nothing to delete.
case err != nil:
if err != nil {
return err
}

c.Logger.Infof("TaskRun %q has timed out, deleting pod", tr.Name)
if err := c.KubeClientSet.CoreV1().Pods(tr.Namespace).Delete(pod.Name, &metav1.DeleteOptions{}); err != nil && !kerrors.IsNotFound(err) {
c.Logger.Errorf("Failed to terminate pod: %v", err)
return err
default:
c.Logger.Infof("TaskRun %q has timed out, deleting pod", tr.Name)
if err := c.KubeClientSet.CoreV1().Pods(tr.Namespace).Delete(pod.Name, &metav1.DeleteOptions{}); err != nil && !kerrors.IsNotFound(err) {
c.Logger.Errorf("Failed to terminate pod: %v", err)
return err
}
}

timeout := tr.Spec.Timeout.Duration
Expand Down

0 comments on commit b23f7d4

Please sign in to comment.