-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
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
- The PR introducing this change: Replace v1beta1.TaskObject with *v1beta1.Task in TaskRun Reconciler #6471
pipeline/pkg/reconciler/taskrun/resources/taskref.go
Lines 292 to 301 in e1c7828
func convertClusterTaskToTask(ctx context.Context, ct v1beta1.ClusterTask) (*v1.Task, error) { t := &v1beta1.Task{ TypeMeta: metav1.TypeMeta{ Kind: "Task", APIVersion: "tekton.dev/v1beta1", }, } t.Spec = ct.Spec t.ObjectMeta.Name = ct.ObjectMeta.Name pipeline/pkg/reconciler/taskrun/taskrun.go
Lines 361 to 364 in e1c7828
// Store the fetched TaskSpec on the TaskRun for auditing if err := storeTaskSpecAndMergeMeta(ctx, tr, taskSpec, taskMeta); err != nil { logger.Errorf("Failed to store TaskSpec on TaskRun.Statusfor taskrun %s: %v", tr.Name, err) } pipeline/pkg/reconciler/taskrun/taskrun.go
Lines 970 to 973 in e1c7828
// Propagate annotations from Task to TaskRun. TaskRun annotations take precedences over Task. tr.ObjectMeta.Annotations = kmap.Union(kmap.ExcludeKeys(meta.Annotations, tknreconciler.KubectlLastAppliedAnnotationKey), tr.ObjectMeta.Annotations) // Propagate labels from Task to TaskRun. TaskRun labels take precedences over Task. tr.ObjectMeta.Labels = kmap.Union(meta.Labels, tr.ObjectMeta.Labels) pipeline/pkg/reconciler/taskrun/taskrun.go
Lines 663 to 670 in e1c7828
if !reflect.DeepEqual(tr.ObjectMeta.Labels, newTr.ObjectMeta.Labels) || !reflect.DeepEqual(tr.ObjectMeta.Annotations, newTr.ObjectMeta.Annotations) { // Note that this uses Update vs. Patch because the former is significantly easier to test. // If we want to switch this to Patch, then we will need to teach the utilities in test/controller.go // to deal with Patch (setting resourceVersion, and optimistic concurrency checks). newTr = newTr.DeepCopy() newTr.Labels = kmap.Union(newTr.Labels, tr.Labels) newTr.Annotations = kmap.Union(kmap.ExcludeKeys(newTr.Annotations, tknreconciler.KubectlLastAppliedAnnotationKey), tr.Annotations) return c.PipelineClientSet.TektonV1().TaskRuns(tr.Namespace).Update(ctx, newTr, metav1.UpdateOptions{})
Steps to Reproduce the Problem
- 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:
- name: echo
image: ubuntu
script: |
#!/bin/sh
echo "Hello World!"
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: taskrun-task
namespace: default
spec:
taskRef:
kind: Task
name: task-demo
EOF
- Testing in Tekton Pipeline v0.44.0
Thetaskrun-clustertaskalso has the annotations and labels ofclustertask-demo.
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.44.0/release.yamlcat 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: ""
- Testing in Tekton Pipeline v0.56.0
Thetaskrun-clustertasklacks the annotations and labels ofclustertask-demo.
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/previous/v0.56.0/release.yamlcat 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
-
Kubernetes version:
Output of
kubectl version:
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
-
Tekton Pipeline version:
Output of
tkn versionorkubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'
v0.56.0
/kind bug