Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

taskrunCancelled sets the startedAt and finishedAt times for steps that were not executed #8479

Open
pritidesai opened this issue Jan 10, 2025 · 0 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@pritidesai
Copy link
Member

Expected Behavior

When a taskRun is cancelled due to a timeout, I expect the steps that were not executed to have no timings attached to them. It is misleading to set the same time for all steps, as steps are generally executed in sequence. Additionally, the startedAt time is set to the start time of the taskRun. Meaning, if a taskRun is canceled while executing the second step of a task, that step may have a startedAt time earlier than the first step, which is inaccurate.

Actual Behavior

Steps to Reproduce the Problem

apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: task
spec:
  steps:
    - image: mirror.gcr.io/busybox
      name: step-1
      command: ['/bin/sh']
      args: ['-c', 'sleep 1']
    - image: mirror.gcr.io/busybox
      name: step-2
      command: ['/bin/sh']
      args: ['-c', 'sleep 10']
    - image: mirror.gcr.io/busybox
      name: step-3
      command: ['/bin/sh']
      args: ['-c', 'sleep 10']
    - image: mirror.gcr.io/busybox
      name: step-4
      command: ['/bin/sh']
      args: ['-c', 'sleep 10']
---

apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: pipeline
spec:
  tasks:
    - name: foo
      taskRef:
        name: task
---

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: pipelinerun
spec:
  pipelineRef:
    name: pipeline
  timeouts:
    pipeline: 10s

Apply this pipelineRun:

k create -f pipelinerun-timeout.yaml

Analyze the taskRun:

 tkn taskrun describe pipelinerun-foo                    
Name:              pipelinerun-foo
Namespace:         default
Task Ref:          task
Service Account:   default
Timeout:           24h0m0s
Labels:
 app.kubernetes.io/managed-by=tekton-pipelines
 tekton.dev/memberOf=tasks
 tekton.dev/pipeline=pipeline
 tekton.dev/pipelineRun=pipelinerun
 tekton.dev/pipelineTask=foo
 tekton.dev/task=task
Annotations:
 pipeline.tekton.dev/release=e58ca13

🌡️  Status

STARTED          DURATION    STATUS
11 seconds ago   10s         Cancelled(TaskRunCancelled)

Message

TaskRun "pipelinerun-foo" was cancelled. TaskRun cancelled as the PipelineRun it belongs to has timed out.

🦶 Steps

 NAME       STATUS
 ∙ step-2   TaskRunCancelled
 ∙ step-3   TaskRunCancelled
 ∙ step-4   TaskRunCancelled
 ∙ step-1   Completed

Analyze the steps:

k get taskruns.tekton.dev pipelinerun-foo -o json | jq .status.steps
[
  {
    "container": "step-step-1",
    "imageID": "mirror.gcr.io/busybox@sha256:2919d0172f7524b2d8df9e50066a682669e6d170ac0f6a49676d54358fe970b5",
    "name": "step-1",
    "terminated": {
      "containerID": "containerd://0f9896d9080b86b7deb09dea2b2b73d3f5d5a8a57a5e76222df9b3dce911ff1b",
      "exitCode": 0,
      "finishedAt": "2025-01-10T20:07:18Z",
      "reason": "Completed",
      "startedAt": "2025-01-10T20:07:17Z"
    },
    "terminationReason": "Completed"
  },
  {
    "container": "step-step-2",
    "imageID": "mirror.gcr.io/busybox@sha256:2919d0172f7524b2d8df9e50066a682669e6d170ac0f6a49676d54358fe970b5",
    "name": "step-2",
    "terminated": {
      "exitCode": 1,
      "finishedAt": "2025-01-10T20:07:22Z",
      "message": "Step step-2 terminated as pod pipelinerun-foo-pod is terminated",
      "reason": "TaskRunCancelled",
      "startedAt": "2025-01-10T20:07:15Z"
    },
    "terminationReason": "TaskRunCancelled"
  },
  {
    "container": "step-step-3",
    "imageID": "mirror.gcr.io/busybox@sha256:2919d0172f7524b2d8df9e50066a682669e6d170ac0f6a49676d54358fe970b5",
    "name": "step-3",
    "terminated": {
      "exitCode": 1,
      "finishedAt": "2025-01-10T20:07:22Z",
      "message": "Step step-3 terminated as pod pipelinerun-foo-pod is terminated",
      "reason": "TaskRunCancelled",
      "startedAt": "2025-01-10T20:07:15Z"
    },
    "terminationReason": "TaskRunCancelled"
  },
  {
    "container": "step-step-4",
    "imageID": "mirror.gcr.io/busybox@sha256:2919d0172f7524b2d8df9e50066a682669e6d170ac0f6a49676d54358fe970b5",
    "name": "step-4",
    "terminated": {
      "exitCode": 1,
      "finishedAt": "2025-01-10T20:07:22Z",
      "message": "Step step-4 terminated as pod pipelinerun-foo-pod is terminated",
      "reason": "TaskRunCancelled",
      "startedAt": "2025-01-10T20:07:16Z"
    },
    "terminationReason": "TaskRunCancelled"
  }
]
Step startedAt finishedAt
step-1 2025-01-10T20:07:17Z 2025-01-10T20:07:18Z
step-2 2025-01-10T20:07:15Z 2025-01-10T20:07:22Z
step-3 2025-01-10T20:07:15Z 2025-01-10T20:07:22Z
step-4 2025-01-10T20:07:16Z 2025-01-10T20:07:22Z

Additional Info

  • Kubernetes version:

    Output of kubectl version:

 k version
Client Version: v1.31.0
Server Version: v1.29.11+IKS
  • Tekton Pipeline version:

    Output of tkn version or kubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'

 tkn version                                                                                                                               
Client version: 0.32.0
Pipeline version: v0.62.1
@pritidesai pritidesai added the kind/bug Categorizes issue or PR as related to a bug. label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
Status: Todo
Development

No branches or pull requests

1 participant