tektoncd / pipeline

A cloud-native Pipeline resource.
https://tekton.dev
Apache License 2.0
8.51k stars 1.78k forks source link

TaskRuns using ClusterTask don't sync the Annotations and Labels of the ClusterTask #7601

Closed l-qing closed 9 months ago

l-qing commented 10 months ago

Expected Behavior

TaskRuns that use ClusterTask can also synchronize Annotations and Labels in v0.56.0 Consistent with the behavior of Pipeline version v0.44.0

Actual Behavior

In version v0.56.0, the behavior of ClusterTask is inconsistent with that of tasks. And also inconsistent with the behavior of ClusterTask in version v0.44.0.

Refs

Steps to Reproduce the Problem

  1. Prepare a YAML file test.clustertask.taskrun.yaml.
    
    cat <<EOF > test.clustertask.taskrun.yaml
    apiVersion: tekton.dev/v1beta1
    kind: ClusterTask
    metadata:
    name: clustertask-demo
    annotations:
    foo: bar
    labels:
    foo: bar
    spec:
    steps:
    - name: echo
      image: ubuntu
      script: |
        #!/bin/sh
        echo "Hello World!"
    ---
    apiVersion: tekton.dev/v1beta1
    kind: TaskRun
    metadata:
    name: taskrun-clustertask
    namespace: default
    spec:
    taskRef:
    kind: ClusterTask
    name: clustertask-demo

apiVersion: tekton.dev/v1beta1 kind: Task metadata: name: task-demo namespace: default annotations: foo: bar labels: foo: bar spec: steps:

  1. Testing in Tekton Pipeline v0.44.0 The taskrun-clustertask also has the annotations and labels of clustertask-demo.

    • kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.44.0/release.yaml
    • cat test.clustertask.taskrun.yaml | kubectl replace --force -f -
    • Result: kubectl get taskrun -n default taskrun-task taskrun-clustertask -o yaml
apiVersion: v1
items:
- apiVersion: tekton.dev/v1
  kind: TaskRun
  metadata:
    annotations:
      foo: bar
      pipeline.tekton.dev/release: 6db52ca
    creationTimestamp: "2024-01-23T09:32:46Z"
    generation: 1
    labels:
      app.kubernetes.io/managed-by: tekton-pipelines
      foo: bar
      tekton.dev/task: task-demo
    name: taskrun-task
    namespace: default
    resourceVersion: "7452"
    uid: bcc4eae1-425c-46ca-b899-777adaea1737
  spec:
    serviceAccountName: default
    taskRef:
      kind: Task
      name: task-demo
    timeout: 1h0m0s
  status:
    completionTime: "2024-01-23T09:38:39Z"
    conditions:
    - lastTransitionTime: "2024-01-23T09:38:39Z"
      message: All Steps have completed executing
      reason: Succeeded
      status: "True"
      type: Succeeded
    podName: taskrun-task-pod
    startTime: "2024-01-23T09:32:46Z"
    steps:
    - container: step-echo
      imageID: docker.io/library/ubuntu@sha256:e6173d4dc55e76b87c4af8db8821b1feae4146dd47341e4d431118c7dd060a74
      name: echo
      terminated:
        containerID: containerd://b19a40f3b8c1ba822259c53cd23328ccab277158d2a974c1b4fdf724915d0666
        exitCode: 0
        finishedAt: "2024-01-23T09:38:39Z"
        reason: Completed
        startedAt: "2024-01-23T09:38:39Z"
    taskSpec:
      steps:
      - computeResources: {}
        image: ubuntu
        name: echo
        script: |
          #!/bin/sh
          echo "Hello World!"
- apiVersion: tekton.dev/v1
  kind: TaskRun
  metadata:
    annotations:
      foo: bar
      pipeline.tekton.dev/release: 6db52ca
    creationTimestamp: "2024-01-23T09:32:46Z"
    generation: 1
    labels:
      app.kubernetes.io/managed-by: tekton-pipelines
      foo: bar
      tekton.dev/clusterTask: clustertask-demo
    name: taskrun-clustertask
    namespace: default
    resourceVersion: "7454"
    uid: cc20b2a6-4e62-4c0b-830f-abe5076cfed6
  spec:
    serviceAccountName: default
    taskRef:
      kind: ClusterTask
      name: clustertask-demo
    timeout: 1h0m0s
  status:
    completionTime: "2024-01-23T09:38:39Z"
    conditions:
    - lastTransitionTime: "2024-01-23T09:38:39Z"
      message: All Steps have completed executing
      reason: Succeeded
      status: "True"
      type: Succeeded
    podName: taskrun-clustertask-pod
    startTime: "2024-01-23T09:32:46Z"
    steps:
    - container: step-echo
      imageID: docker.io/library/ubuntu@sha256:e6173d4dc55e76b87c4af8db8821b1feae4146dd47341e4d431118c7dd060a74
      name: echo
      terminated:
        containerID: containerd://47ed41054816b0e19be79fb1b3cfa38395648d01ae652a2360692859d2c2ac05
        exitCode: 0
        finishedAt: "2024-01-23T09:38:38Z"
        reason: Completed
        startedAt: "2024-01-23T09:38:38Z"
    taskSpec:
      steps:
      - computeResources: {}
        image: ubuntu
        name: echo
        script: |
          #!/bin/sh
          echo "Hello World!"
kind: List
metadata:
  resourceVersion: ""
  1. Testing in Tekton Pipeline v0.56.0 The taskrun-clustertask lacks the annotations and labels of clustertask-demo.

    • kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.56.0/release.yaml
    • cat test.clustertask.taskrun.yaml | kubectl replace --force -f -
    • Result: kubectl get taskrun -n default taskrun-task taskrun-clustertask -o yaml
apiVersion: v1
items:
- apiVersion: tekton.dev/v1
  kind: TaskRun
  metadata:
    annotations:
      foo: bar
      pipeline.tekton.dev/release: e1c7828
    creationTimestamp: "2024-01-23T09:55:07Z"
    generation: 1
    labels:
      app.kubernetes.io/managed-by: tekton-pipelines
      foo: bar
      tekton.dev/task: task-demo
    name: taskrun-task
    namespace: default
    resourceVersion: "13671"
    uid: 60ba69a0-fdcb-4856-9ce3-f2b35fa411c6
  spec:
    serviceAccountName: default
    taskRef:
      kind: Task
      name: task-demo
    timeout: 1h0m0s
  status:
    completionTime: "2024-01-23T09:55:19Z"
    conditions:
    - lastTransitionTime: "2024-01-23T09:55:19Z"
      message: All Steps have completed executing
      reason: Succeeded
      status: "True"
      type: Succeeded
    podName: taskrun-task-pod
    provenance:
      featureFlags:
        AwaitSidecarReadiness: true
        Coschedule: workspaces
        DisableAffinityAssistant: false
        DisableCredsInit: false
        EnableAPIFields: beta
        EnableCELInWhenExpression: false
        EnableKeepPodOnCancel: false
        EnableParamEnum: false
        EnableProvenanceInStatus: true
        EnableStepActions: false
        EnableTektonOCIBundles: false
        EnforceNonfalsifiability: none
        MaxResultSize: 4096
        RequireGitSSHSecretKnownHosts: false
        ResultExtractionMethod: termination-message
        RunningInEnvWithInjectedSidecars: true
        ScopeWhenExpressionsToTask: false
        SendCloudEventsForRuns: false
        SetSecurityContext: false
        VerificationNoMatchPolicy: ignore
    startTime: "2024-01-23T09:55:07Z"
    steps:
    - container: step-echo
      imageID: docker.io/library/ubuntu@sha256:e6173d4dc55e76b87c4af8db8821b1feae4146dd47341e4d431118c7dd060a74
      name: echo
      terminated:
        containerID: containerd://b1e7dc91fad33fb5f9610ba811887b61ad1646de678aaad096118f5318174dec
        exitCode: 0
        finishedAt: "2024-01-23T09:55:18Z"
        reason: Completed
        startedAt: "2024-01-23T09:55:18Z"
    taskSpec:
      steps:
      - computeResources: {}
        image: ubuntu
        name: echo
        script: |
          #!/bin/sh
          echo "Hello World!"
- apiVersion: tekton.dev/v1
  kind: TaskRun
  metadata:
    annotations:
      pipeline.tekton.dev/release: e1c7828
    creationTimestamp: "2024-01-23T09:55:07Z"
    generation: 1
    labels:
      app.kubernetes.io/managed-by: tekton-pipelines
      tekton.dev/clusterTask: clustertask-demo
    name: taskrun-clustertask
    namespace: default
    resourceVersion: "13652"
    uid: 1baf9ca8-a108-4a0b-8c75-1bcb0cc520c8
  spec:
    serviceAccountName: default
    taskRef:
      kind: ClusterTask
      name: clustertask-demo
    timeout: 1h0m0s
  status:
    completionTime: "2024-01-23T09:55:17Z"
    conditions:
    - lastTransitionTime: "2024-01-23T09:55:17Z"
      message: All Steps have completed executing
      reason: Succeeded
      status: "True"
      type: Succeeded
    podName: taskrun-clustertask-pod
    provenance:
      featureFlags:
        AwaitSidecarReadiness: true
        Coschedule: workspaces
        DisableAffinityAssistant: false
        DisableCredsInit: false
        EnableAPIFields: beta
        EnableCELInWhenExpression: false
        EnableKeepPodOnCancel: false
        EnableParamEnum: false
        EnableProvenanceInStatus: true
        EnableStepActions: false
        EnableTektonOCIBundles: false
        EnforceNonfalsifiability: none
        MaxResultSize: 4096
        RequireGitSSHSecretKnownHosts: false
        ResultExtractionMethod: termination-message
        RunningInEnvWithInjectedSidecars: true
        ScopeWhenExpressionsToTask: false
        SendCloudEventsForRuns: false
        SetSecurityContext: false
        VerificationNoMatchPolicy: ignore
    startTime: "2024-01-23T09:55:07Z"
    steps:
    - container: step-echo
      imageID: docker.io/library/ubuntu@sha256:e6173d4dc55e76b87c4af8db8821b1feae4146dd47341e4d431118c7dd060a74
      name: echo
      terminated:
        containerID: containerd://89e19e8b87b53226889212ee8f2af1e09bb51fad125a9261acc53ba0c10f5cc3
        exitCode: 0
        finishedAt: "2024-01-23T09:55:16Z"
        reason: Completed
        startedAt: "2024-01-23T09:55:16Z"
    taskSpec:
      steps:
      - computeResources: {}
        image: ubuntu
        name: echo
        script: |
          #!/bin/sh
          echo "Hello World!"
kind: List
metadata:
  resourceVersion: ""

Additional Info

Client Version: v1.29.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.26.0
WARNING: version difference between client (1.29) and server (1.26) exceeds the supported minor version skew of +/-1
v0.56.0

/kind bug

l-qing commented 10 months ago

/assign