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 Pipeline/Task to *Run label/annotation propagation 🥨 #4478

Merged

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Jan 13, 2022

Changes

Before this fix, we are "forgetting" the Task and Pipeline
metadata (Labels/Annotations) when using them in a Run (PipelineRun or
TaskRun).

It is however documented that those metadata get propagated to the
generated Pod, and even the code after storing the Spec is written
that way.

Because we only store the spec, the second time we were reconciling
the TaskRun or PipelineRun, we wouldn't fetch the referenced Task or
Pipeline anymore, and thus, we would not propagate them.

Fixes #4477

Signed-off-by: Vincent Demeester [email protected]

This most likely need an additional unit test or e2e test, I will be working on this 👼🏼

/kind bug
/cc @pritidesai @sbwsg @chmouel @bobcatfish

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 labels and annotation propagation from Task/Pipeline to TaskRun/PipelineRun and thus the generated Pod

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 13, 2022
@tekton-robot tekton-robot requested review from pritidesai and a user January 13, 2022 15:06
@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 13, 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.5% 83.6% 0.2
pkg/reconciler/taskrun/taskrun.go 80.1% 80.4% 0.3

@@ -1147,10 +1130,28 @@ func (c *Reconciler) makeConditionCheckContainer(ctx context.Context, rprt *reso
return &cc, err
}

func storePipelineSpec(ctx context.Context, pr *v1beta1.PipelineRun, ps *v1beta1.PipelineSpec) error {
func storePipelineSpecAndMergeMeta(ctx context.Context, pr *v1beta1.PipelineRun, ps *v1beta1.PipelineSpec, meta *metav1.ObjectMeta) error {
Copy link
Member

Choose a reason for hiding this comment

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

since we are updating this function here, please drop ctx since its not used in this function

Before this fix, we are "forgetting" the Task and Pipeline
metadata (Labels/Annotations) when using them in a Run (PipelineRun or
TaskRun).

It is however documented that those metadata get propagated to the
generated Pod, and even the code after storing the Spec is written
that way.

Because we only store the spec, the second time we were reconciling
the TaskRun or PipelineRun, we wouldn't fetch the referenced Task or
Pipeline anymore, and thus, we would not propagate them.

Signed-off-by: Vincent Demeester <[email protected]>
@vdemeester vdemeester force-pushed the fix-task-pipeline-run-propagation branch from ee6ec91 to 111d059 Compare January 14, 2022 14:41
@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 Jan 14, 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.5% 83.6% 0.2

@vdemeester
Copy link
Member Author

/retest

@ghost ghost added the needs-cherry-pick Indicates a PR needs to be cherry-pick to a release branch label Jan 19, 2022
@ghost ghost added this to the Pipelines v0.32 milestone Jan 19, 2022
@ghost
Copy link

ghost commented Jan 19, 2022

/lgtm

@tekton-robot tekton-robot assigned ghost Jan 19, 2022
@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 19, 2022
@chmouel
Copy link
Member

chmouel commented Jan 19, 2022

/lgtm

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
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 19, 2022
@tekton-robot tekton-robot merged commit d8425c2 into tektoncd:main Jan 19, 2022
@vdemeester vdemeester deleted the fix-task-pipeline-run-propagation branch January 20, 2022 09:18
@ghost ghost removed the needs-cherry-pick Indicates a PR needs to be cherry-pick to a release branch label Feb 4, 2022
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. kind/bug Categorizes issue or PR as related to a bug. 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.

Annotations and Labels from Task are not propagated to the Pod
4 participants