Pipeline: If the WhenExpression of the task is evaluated to false immediately after the pipelinerun is started, the pipelinerun stays in "Running(Started)" state

Created on 11 Sep 2020  路  3Comments  路  Source: tektoncd/pipeline

Expected Behavior

The Pipelinerun should start and run successfully

Actual Behavior

If the WhenExpression of the task is evaluated to false immediately after the pipelinerun is started, the pipelinerun stays in "Running(Started)" state for a pipeline which has sequential tasks (tasks which run after another)

Steps to Reproduce the Problem

  1. Create 2 tasks (task-1, task-2)
  2. Create a pipeline in such a way that task-2 runs after the task-1 and add WhenExpression to the task-2
  3. Make sure that the WhenExpression of the task-2 always fails and always gets executed immediately when the pipelinerun is started (you can use static input to make sure that the WhenExpression always fails)
  4. Start the pipeline and check the status of the pipelinerun

Additional Info

  • Kubernetes version:

    Output of kubectl version:

    Client Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.0+b3b92b2", GitCommit:"b3b92b2", GitTreeState:"clean", BuildDate:"2020-07-15T09:27:21Z", GoVersion:"go1.14.3", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.3+8b0a82f", GitCommit:"8b0a82f", GitTreeState:"clean", BuildDate:"2020-07-10T05:34:00Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}
    
  • Tekton Pipeline version:

    $ tkn version
    Client version: 0.12.0
    Pipeline version: v0.16.0
    Triggers version: unknown
    


Command Execution Logs:

$ kubectl get pipeline pipeline-with-when-expression -o yaml
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  creationTimestamp: "2020-09-11T05:38:05Z"
  generation: 18
  managedFields:
  - apiVersion: tekton.dev/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:spec:
        .: {}
        f:params: {}
        f:resources: {}
        f:tasks: {}
    manager: Mozilla
    operation: Update
    time: "2020-09-11T08:35:28Z"
  name: pipeline-with-when-expression
  namespace: veeresh-testing
  resourceVersion: "412847"
  selfLink: /apis/tekton.dev/v1beta1/namespaces/veeresh-testing/pipelines/pipeline-with-when-expression
  uid: 3bc57b32-e865-4d57-ac0d-d32ad235898b
spec:
  params:
  - name: status-1
    type: string
  tasks:
  - name: task-1
    taskRef:
      kind: Task
      name: first-task
  - name: task-2
    runAfter:
    - task-1
    taskRef:
      kind: Task
      name: second-task
    when:
    - Input: $(params.status-1)
      Operator: in
      Values:
      - Success
      - success
$ 
$ 
$ tkn p start pipeline-with-when-expression -p status-1=Failure
PipelineRun started: pipeline-with-when-expression-run-6bd55

In order to track the PipelineRun progress run:
tkn pipelinerun logs pipeline-with-when-expression-run-6bd55 -f -n veeresh-testing
$ 
$ kubectl get pipelinerun
NAME                                      SUCCEEDED   REASON    STARTTIME   COMPLETIONTIME
pipeline-with-when-expression-run-6bd55   Unknown     Started   100s        
$ 
$ tkn pr ls
NAME                                      STARTED        DURATION   STATUS
pipeline-with-when-expression-run-6bd55   1 minute ago   ---        Running(Started)
$ 
$ kubectl get pipelinerun pipeline-with-when-expression-run-6bd55 -o yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  creationTimestamp: "2020-09-11T08:44:37Z"
  generateName: pipeline-with-when-expression-run-
  generation: 1
  labels:
    tekton.dev/pipeline: pipeline-with-when-expression
  managedFields:
  - apiVersion: tekton.dev/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:labels:
          .: {}
          f:tekton.dev/pipeline: {}
      f:status:
        .: {}
        f:conditions: {}
        f:pipelineSpec:
          .: {}
          f:params: {}
          f:tasks: {}
        f:startTime: {}
    manager: controller
    operation: Update
    time: "2020-09-11T08:44:37Z"
  - apiVersion: tekton.dev/v1beta1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:generateName: {}
      f:spec:
        .: {}
        f:params: {}
        f:pipelineRef:
          .: {}
          f:name: {}
    manager: tkn
    operation: Update
    time: "2020-09-11T08:44:37Z"
  name: pipeline-with-when-expression-run-6bd55
  namespace: veeresh-testing
  resourceVersion: "414792"
  selfLink: /apis/tekton.dev/v1beta1/namespaces/veeresh-testing/pipelineruns/pipeline-with-when-expression-run-6bd55
  uid: 5baedc5c-78b9-49ec-b05e-64a09c9156f9
spec:
  params:
  - name: status-1
    value: Failure
  pipelineRef:
    name: pipeline-with-when-expression
  timeout: 1h0m0s
status:
  conditions:
  - lastTransitionTime: "2020-09-11T08:44:37Z"
    reason: Started
    status: Unknown
    type: Succeeded
  pipelineSpec:
    params:
    - name: status-1
      type: string
    tasks:
    - name: task-1
      taskRef:
        kind: Task
        name: first-task
    - name: task-2
      runAfter:
      - task-1
      taskRef:
        kind: Task
        name: second-task
      when:
      - Input: $(params.status-1)
        Operator: in
        Values:
        - Success
        - success
  startTime: "2020-09-11T08:44:37Z"
$ 
$ 
$ kubectl get pipelinerun
NAME                                      SUCCEEDED   REASON    STARTTIME   COMPLETIONTIME
pipeline-with-when-expression-run-6bd55   Unknown     Started   3m6s        
$ 
$ tkn pr ls
NAME                                      STARTED         DURATION   STATUS
pipeline-with-when-expression-run-6bd55   4 minutes ago   ---        Running(Started)
$ tkn tr ls
No TaskRuns found
$ kubectl get taskrun
No resources found.
kinbug

Most helpful comment

yikes! thanks for trying when expressions out so thoroughly @VeereshAradhya we'll get to this right away :D

All 3 comments

yikes! thanks for trying when expressions out so thoroughly @VeereshAradhya we'll get to this right away :D

Quick update: aiming to have a release with a fix for this out on Monday

Okay 0.16.2 is up now (https://github.com/tektoncd/pipeline/releases/tag/v0.16.2) please let us know if you still run into problems!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

castlemilk picture castlemilk  路  4Comments

hrishin picture hrishin  路  3Comments

nader-ziada picture nader-ziada  路  4Comments

bobcatfish picture bobcatfish  路  4Comments

bobcatfish picture bobcatfish  路  4Comments