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

Handle PipelineRun conversion when embedded-status flag is set to "full" or "both" #5813

Closed
3 tasks
JeromeJu opened this issue Nov 30, 2022 · 9 comments
Closed
3 tasks
Assignees

Comments

@JeromeJu
Copy link
Member

JeromeJu commented Nov 30, 2022

This issue aims point out the needs to handle PipelineRunStatus conversion when embedded-status flag is set to "full" or "both". It tracks the information loss depending on embedded-status flag when converting ChildReferences to TaskRuns and Runs status. Specifically in the case where:

  • Users creates a v1 PipelineRun CRD without TaskRuns/ Runs but with ChildReferences, converted to v1beta1
  • Since there is no way converting ChildStatusReference to TaskRuns / Runs, the information would get lost

Local tests results following the above procedures are provided to determine the behaviours of the conversion

Thanks to @lbernick spotting this at #5797 (comment), pointing out that without the reconciler logics processing the embedded-status flag.

Thanks for the discussion cc @abayer @lbernick And also many thanks to @XinruZhang for the pointers at the storage version concerns and the reconciler logics on the findings!

@JeromeJu
Copy link
Member Author

JeromeJu commented Nov 30, 2022

  • Embedded status:
  • minimal - Just populate status.childReferences, not status.taskRuns or status.runs.
    The current default behavior of populating status.taskRuns and status.runs, without populating status.childReferences.

(this shall be safe as both v1beta1 and v1 has ChildReferences)

± |fix-pr-status-conversion → origin {6} U:2 ?:2 ✗| → k get pipelineruns.v1.tekton.dev/pipelinerun-test-embedded -o yaml
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  creationTimestamp: "2022-11-30T17:19:41Z"
  generation: 1
  labels:
    tekton.dev/pipeline: pipelinerun-test-embedded
  name: pipelinerun-test-embedded
  namespace: default
  resourceVersion: "33376108"
  uid: 0bf519dd-1ede-4304-8938-8716c8a1da36
spec:
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - computeResources: {}
          image: ubuntu
          name: echo
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  taskRunTemplate:
    serviceAccountName: default
  timeouts:
    pipeline: 1h0m0s
status:
  childReferences:
  - apiVersion: tekton.dev/v1beta1
    kind: TaskRun
    name: pipelinerun-test-embedded-echo-good-morning
    pipelineTaskName: echo-good-morning
  conditions:
  - lastTransitionTime: "2022-11-30T17:19:41Z"
    message: 'Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped:
      0'
    reason: Running
    status: Unknown
    type: Succeeded
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - computeResources: {}
          image: ubuntu
          name: echo
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  startTime: "2022-11-30T17:19:41Z"
± |fix-pr-status-conversion → origin {6} U:2 ?:2 ✗| → k get pipelineruns.v1beta1.tekton.dev/pipelinerun-test-embedded -o yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
 creationTimestamp: "2022-11-30T17:19:41Z"
 generation: 1
 labels:
   tekton.dev/pipeline: pipelinerun-test-embedded
 name: pipelinerun-test-embedded
 namespace: default
 resourceVersion: "33376173"
 uid: 0bf519dd-1ede-4304-8938-8716c8a1da36
spec:
 pipelineSpec:
   tasks:
   - name: echo-good-morning
     taskSpec:
       metadata:
         labels:
           app: example
       spec: null
       steps:
       - image: ubuntu
         name: echo
         resources: {}
         script: |
           #!/usr/bin/env bash
           echo "Good Morning!"
 serviceAccountName: default
 timeout: 1h0m0s
status:
 childReferences:
 - apiVersion: tekton.dev/v1beta1
   kind: TaskRun
   name: pipelinerun-test-embedded-echo-good-morning
   pipelineTaskName: echo-good-morning
 completionTime: "2022-11-30T17:19:46Z"
 conditions:
 - lastTransitionTime: "2022-11-30T17:19:46Z"
   message: 'Tasks Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0'
   reason: Succeeded
   status: "True"
   type: Succeeded
 pipelineSpec:
   tasks:
   - name: echo-good-morning
     taskSpec:
       metadata:
         labels:
           app: example
       spec: null
       steps:
       - image: ubuntu
         name: echo
         resources: {}
         script: |
           #!/usr/bin/env bash
           echo "Good Morning!"
 startTime: "2022-11-30T17:19:41Z"

@JeromeJu
Copy link
Member Author

JeromeJu commented Nov 30, 2022

Embedded-status:

  • both - Populate status.childReferences as well as status.taskRuns and status.runs.

v1beta1

± |fix-pr-status-conversion → origin {6} U:2 ?:2 ✗| → k get pipelineruns.v1beta1.tekton.dev/pipelinerun-test-embedded -o yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
creationTimestamp: "2022-11-30T17:47:54Z"
generation: 1
labels:
  tekton.dev/pipeline: pipelinerun-test-embedded
name: pipelinerun-test-embedded
namespace: default
resourceVersion: "33392727"
uid: 0767ecf2-2cf1-47cc-bffa-cfabef7a84d3
spec:
pipelineSpec:
  tasks:
  - name: echo-good-morning
    taskSpec:
      metadata:
        labels:
          app: example
      spec: null
      steps:
      - image: ubuntu
        name: echo
        resources: {}
        script: |
          #!/usr/bin/env bash
          echo "Good Morning!"
serviceAccountName: default
timeout: 1h0m0s
status:
childReferences:
- apiVersion: tekton.dev/v1beta1
  kind: TaskRun
  name: pipelinerun-test-embedded-echo-good-morning
  pipelineTaskName: echo-good-morning
conditions:
- lastTransitionTime: "2022-11-30T17:47:54Z"
  message: 'Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped:
    0'
  reason: Running
  status: Unknown
  type: Succeeded
pipelineSpec:
  tasks:
  - name: echo-good-morning
    taskSpec:
      metadata:
        labels:
          app: example
      spec: null
      steps:
      - image: ubuntu
        name: echo
        resources: {}
        script: |
          #!/usr/bin/env bash
          echo "Good Morning!"
startTime: "2022-11-30T17:47:54Z"
taskRuns:
  pipelinerun-test-embedded-echo-good-morning:
    pipelineTaskName: echo-good-morning
    status:
      conditions:
      - lastTransitionTime: "2022-11-30T17:47:57Z"
        message: Not all Steps in the Task have finished executing
        reason: Running
        status: Unknown
        type: Succeeded
      podName: pipelinerun-test-embedded-echo-good-morning-pod
      startTime: "2022-11-30T17:47:54Z"
      steps:
      - container: step-echo
        imageID: docker.io/library/ubuntu@sha256:4b1d0c4a2d2aaf63b37111f34eb9fa89fa1bf53dd6e4ca954d47caebca4005c2
        name: echo
        running:
          startedAt: "2022-11-30T17:47:57Z"
      taskSpec:
        steps:
        - image: ubuntu
          name: echo
          resources: {}
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"

v1

± |fix-pr-status-conversion → origin {6} U:2 ?:2 ✗| → k get pipelineruns.v1.tekton.dev/pipelinerun-test-embedded -o yaml
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  creationTimestamp: "2022-11-30T17:40:47Z"
  generation: 1
  labels:
    tekton.dev/pipeline: pipelinerun-test-embedded
  name: pipelinerun-test-embedded
  namespace: default
  resourceVersion: "33388557"
  uid: eae75279-0578-415a-ad81-bbf397c48bfa
spec:
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - computeResources: {}
          image: ubuntu
          name: echo
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  taskRunTemplate:
    serviceAccountName: default
  timeouts:
    pipeline: 1h0m0s
status:
  childReferences:
  - apiVersion: tekton.dev/v1beta1
    kind: TaskRun
    name: pipelinerun-test-embedded-echo-good-morning
    pipelineTaskName: echo-good-morning
  conditions:
  - lastTransitionTime: "2022-11-30T17:40:47Z"
    message: 'Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped:
      0'
    reason: Running
    status: Unknown
    type: Succeeded
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - computeResources: {}
          image: ubuntu
          name: echo
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  startTime: "2022-11-30T17:40:47Z"

@JeromeJu
Copy link
Member Author

JeromeJu commented Nov 30, 2022

Embedded status:

  • full - The current default behavior of populating status.taskRuns and status.runs, without populating status.childReferences.

Updates about the findings:

  • Right now as v1beta1 is the stored version, with full or both embedded-status, taskRuns and Runs would be stored in etcd.
  • So when converting to v1, the taskRuns and runs would just be not converted.
  • When we create v1 pipelineRun, it's actually creating the TaskRun and Runs with full embedded-status

v1beta1

± |fix-pr-status-conversion → origin {6} U:2 ?:2 ✗| → k get pipelineruns.v1beta1.tekton.dev/pipelinerun-test-embedded -o yaml
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  creationTimestamp: "2022-11-30T17:24:26Z"
  generation: 1
  labels:
    tekton.dev/pipeline: pipelinerun-test-embedded
  name: pipelinerun-test-embedded
  namespace: default
  resourceVersion: "33378985"
  uid: 9f984f5e-a9e5-453d-b267-81acb1b15a91
spec:
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - image: ubuntu
          name: echo
          resources: {}
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  serviceAccountName: default
  timeout: 1h0m0s
status:
  completionTime: "2022-11-30T17:24:32Z"
  conditions:
  - lastTransitionTime: "2022-11-30T17:24:32Z"
    message: 'Tasks Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0'
    reason: Succeeded
    status: "True"
    type: Succeeded
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - image: ubuntu
          name: echo
          resources: {}
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  startTime: "2022-11-30T17:24:26Z"
  taskRuns:
    pipelinerun-test-embedded-echo-good-morning:
      pipelineTaskName: echo-good-morning
      status:
        completionTime: "2022-11-30T17:24:32Z"
        conditions:
        - lastTransitionTime: "2022-11-30T17:24:32Z"
          message: All Steps have completed executing
          reason: Succeeded
          status: "True"
          type: Succeeded
        podName: pipelinerun-test-embedded-echo-good-morning-pod
        startTime: "2022-11-30T17:24:26Z"
        steps:
        - container: step-echo
          imageID: docker.io/library/ubuntu@sha256:4b1d0c4a2d2aaf63b37111f34eb9fa89fa1bf53dd6e4ca954d47caebca4005c2
          name: echo
          terminated:
            containerID: containerd://ac17e55a5054deffc0fc3e12e4a5019ba9ab104718d1b790e595e02f8c60b05a
            exitCode: 0
            finishedAt: "2022-11-30T17:24:32Z"
            reason: Completed
            startedAt: "2022-11-30T17:24:32Z"
        taskSpec:
          steps:
          - image: ubuntu
            name: echo
            resources: {}
            script: |
              #!/usr/bin/env bash
              echo "Good Morning!"

v1

± |fix-pr-status-conversion → origin {6} U:2 ?:2 ✗| → k get pipelineruns.v1.tekton.dev/pipelinerun-test-embedded -o yaml
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"tekton.dev/v1","kind":"PipelineRun","metadata":{"annotations":{},"name":"pipelinerun-test-embedded","namespace":"default"},"spec":{"pipelineSpec":{"tasks":[{"name":"echo-good-morning","taskSpec":{"metadata":{"labels":{"app":"example"}},"steps":[{"image":"ubuntu","name":"echo","script":"#!/usr/bin/env bash\necho \"Good Morning!\"\n"}]}}]}}}
  creationTimestamp: "2022-11-30T18:22:49Z"
  generation: 1
  labels:
    tekton.dev/pipeline: pipelinerun-test-embedded
  name: pipelinerun-test-embedded
  namespace: default
  resourceVersion: "33413103"
  uid: a66e0cb6-ea97-43a5-a41c-3dcb77bde2fd
spec:
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - computeResources: {}
          image: ubuntu
          name: echo
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  taskRunTemplate:
    serviceAccountName: default
  timeouts:
    pipeline: 1h0m0s
status:
  childReferences:
  - apiVersion: v1beta1
    kind: TaskRun
    name: pipelinerun-test-embedded-echo-good-morning
    pipelineTaskName: echo-good-morning
  conditions:
  - lastTransitionTime: "2022-11-30T18:22:49Z"
    message: 'Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped:
      0'
    reason: Running
    status: Unknown
    type: Succeeded
  pipelineSpec:
    tasks:
    - name: echo-good-morning
      taskSpec:
        metadata:
          labels:
            app: example
        spec: null
        steps:
        - computeResources: {}
          image: ubuntu
          name: echo
          script: |
            #!/usr/bin/env bash
            echo "Good Morning!"
  startTime: "2022-11-30T18:22:49Z"

@JeromeJu
Copy link
Member Author

@JeromeJu
Copy link
Member Author

V1 PR yaml:

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: pipelinerun-test-embedded
spec:
  pipelineSpec:
    tasks:
      - name: echo-good-morning
        taskSpec:
          metadata:
            labels:
              app: "example"
          steps:
            - name: echo
              image: ubuntu
              script: |
                #!/usr/bin/env bash
                echo "Good Morning!"
                ```

@abayer
Copy link
Contributor

abayer commented Dec 1, 2022

Given that we're scheduled to flip the default from full to minimal on Jan 25, 2023, and remove full and both completely a release after the default change is released, it might make sense to hold off on swapping the storage to v1 until after we've at least changed the default, if not removed full/both completely.

@afrittoli
Copy link
Member

Even after we flip the default for the flag or remove the flag, there may still be v1beta1.PipelineRuns in clusters with full status. Given that usually users need to garbage collect PipelineRuns, this is probably not very likely, so what we could do is add to the release notes that upgrading to a version with v1 storage would lose the full status there.

Alternatively, we could do the same that we do for other removed fields, i.e. store them as annotations on v1 resources, so that someone uses a v1beta1 client to fetch the resource from a Tekton instance with v1 storage, the full status can still be restored.

@lbernick lbernick changed the title Information loss depending on embedded-status flag when converting ChildReferences to TaskRuns and Runs status Handle PipelineRun conversion when embedded-status flag is set to "full" or "both" Dec 2, 2022
@JeromeJu
Copy link
Member Author

JeromeJu commented Dec 2, 2022

The reconciler logics need to be updated once swapping the storage version to v1 to make sure:

  • the resources being correctly converted from v1beta1 to v1 regardless of feature flags of embeddedStatus
  • the controller behaviour of accepting pipelineRunStatus with embeddedStatusthat are changed back and forth from full and minimal

🙏 Thanks again for the guidance here from Andrea and Lee #5797 (comment)
#5797 (comment)

@JeromeJu
Copy link
Member Author

JeromeJu commented Dec 5, 2022

Discussed offline and many thanks to Andrew, Andrea, Dibyo and Xinru 🙏 .

Currently the approach moving forward is to serialize the status.taskRuns and status.runs into annotations when converting up from v1beta1 to v1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Status: Done
Development

No branches or pull requests

4 participants