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

Fix Task(Run)/Pipeline(Run) metadata propagation #4638

Merged

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Mar 3, 2022

Changes

For annotations and labels, do not override the Run metadata with the
definition (Pipeline/Task) if they are the same. If an annotation or
label is present in both Pipeline and PipelineRun, the value in the
Run type takes precedence (same for Task and TaskRun).

Closes #4636

Signed-off-by: Vincent Demeester vdemeest@redhat.com

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in or deleted (only if no user facing changes)

Release Notes

Fix Task(Run)/Pipeline(Run) metadata propagation,  If an annotation or
label is present in both Pipeline and PipelineRun, the value in the
Run type takes precedence (same for Task and TaskRun)

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Mar 3, 2022
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 3, 2022
@vdemeester
Copy link
Member Author

/hold
Needs a small update of the docs and a test update.

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 83.9% 83.6% -0.3
pkg/reconciler/taskrun/taskrun.go 80.5% 80.0% -0.5

@vdemeester vdemeester force-pushed the 4636-no-override-on-propagation branch from ddc0a26 to 02fd0de Compare March 3, 2022 10:29
@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 3, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 83.9% 83.9% 0.1
pkg/reconciler/taskrun/taskrun.go 80.5% 80.6% 0.1

@vdemeester vdemeester force-pushed the 4636-no-override-on-propagation branch from 02fd0de to d930f78 Compare March 3, 2022 11:06
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 83.9% 83.9% 0.1
pkg/reconciler/taskrun/taskrun.go 80.5% 80.6% 0.1


- For standalone `TaskRuns` (that is, ones not executing as part of a `Pipeline`), labels
propagate from the [referenced `Task`](taskruns.md#specifying-the-target-task), if one exists, to
the corresponding `TaskRun`, and then to the associated `Pod`.
the corresponding `TaskRun`, and then to the associated `Pod`. The same as above applies.

- For `Conditions`, labels propagate to the corresponding `TaskRuns`, and then to the associated `Pods`.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a doc for the same behavior on labels, should we rewrite this one to be labels and annotations ?
/cc @pritidesai @afrittoli @bobcatfish

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup indeed, lets be specific and document labels and annotations both. Also the doc can be updated to include an example!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@pritidesai
Copy link
Member

@Tomcli @rafalbigaj please confirm this new behavior for your use cases 🙏

@Tomcli
Copy link
Contributor

Tomcli commented Mar 3, 2022

For Kubeflow pipeline on Tekton, we were expecting PipelineRun labels/annotations to take precedences over its child resources. @rafalbigaj I believe that was your expected behavior as well?

@vdemeester vdemeester force-pushed the 4636-no-override-on-propagation branch from d930f78 to b3cbe87 Compare March 8, 2022 08:51
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 8, 2022
@vdemeester
Copy link
Member Author

/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 8, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 83.9% 83.9% 0.1
pkg/reconciler/taskrun/taskrun.go 80.5% 80.6% 0.1

@vdemeester
Copy link
Member Author

/retest

1 similar comment
@vdemeester
Copy link
Member Author

/retest

docs/labels.md Outdated Show resolved Hide resolved
@vdemeester vdemeester force-pushed the 4636-no-override-on-propagation branch from b3cbe87 to 9500f24 Compare March 9, 2022 08:40
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 83.9% 83.9% 0.1
pkg/reconciler/taskrun/taskrun.go 80.5% 80.6% 0.1

@vdemeester
Copy link
Member Author

/retest

docs/labels.md Outdated
the associated `Pods`. If a annotation is present in both `Pipeline` and
`PipelineRun`, the annotation in `PipelineRun` takes precedence.

- Labels from `Tasks` referenced by `TaskRuns` within a `PipelineRun` propagate to the corresponding `TaskRuns`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last copy past issue here 🤣

Copy link
Member

@pritidesai pritidesai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you @vdemeester 👍

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 11, 2022
For annotations and labels, do not override the Run metadata with the
definition (Pipeline/Task) if they are the same. If an annotation or
label is present in both Pipeline and PipelineRun, the value in the
Run type takes precedence (same for Task and TaskRun).

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the 4636-no-override-on-propagation branch from 9500f24 to 0c07604 Compare March 11, 2022 10:26
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/pipelinerun.go 83.9% 83.9% 0.1
pkg/reconciler/taskrun/taskrun.go 80.5% 80.6% 0.1

Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @vdemeester 😀

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 15, 2022
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, pritidesai

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot merged commit 9ca734d into tektoncd:main Mar 15, 2022
@hrivera-ntap
Copy link

hrivera-ntap commented Apr 4, 2022

@vdemeester : I noticed a side effect of this change that I was wondering if it was expected behavior.

It's stated that PipelineRuns take precedence over Pipeline labels and annotations (L&As) and TaskRuns take precedence over Task labels and annotations. In v0.34.1, I'm seeing that the TaskRuns that are created by the PipelineRuns inherit the L&As of the respective PipelineRun that created it, which has the side effect of overriding any of the explicit L&As that i set on the associated Tasks. The following is my general workflow.

TaskObj.Metadata.Labels["entity"] = "task"
PipelineObj.Metadata.Labels["entity"] = "pipeline"
PipelineObj.Spec.Tasks = [TaskObj]

PipelineRunObj.Metadata.Labels["entity"] = "pipelinerun"
PipelineRunObj.Spec.PipelineRef = PipelineObj

When i inspect the pod associated to the TaskRun that is produced in reference to TaskObj, I see that the pod has the "entity" label set to the value "pipelinerun", instead of "task".

I could probably code around this, but I wanted to confirm whether the cross-over metadata propagation between PipelineRun -> TaskRun was by design and was not overlooked as a potential bug.

Thanks!
-R

@vdemeester vdemeester deleted the 4636-no-override-on-propagation branch April 4, 2022 19:03
@vdemeester
Copy link
Member Author

Hey @hrivera-ntap, yes this is by design, the value from the Run taks precedence over the one defined in the Task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unwanted annotation propagation from Pipeline to PipelineRun
6 participants