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

Remove Updating labels and annotations… #6127

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Feb 8, 2023

Changes

Labels and Annotations on PipelineRun and TaskRun won't be mutated by the controller anymore. Usually, a controller doesn't modify the metadata of the object it reconcile.

This effectively remove the propagation of annotations and labels from Task to TaskRun, and Pipeline to PipelineRun.

This is an "attempt" to fix #5146 but it is mainly opened to start some discussion around it. Mainly the following :

One feature that we "want" is that labels and annotations from a Task and a TaskRun are both inherited by the Pod. Same goes for PipelineRun. Prior to this change, we get away with it by merging it at the TaskRun or PipelineRun level — which cause issues in the past (and still might), like #5297.
Even if this PR propose to remove this "feature", we still want the same behavior (aka a Pod gets its labels from both the Task and the TaskRun). Because we are only "caching" the spec of the Task in TaskRun.status (and same goes for PipelineRun), we would have to query the metadata for the Task each time. Using informers, it wouldn't cost that much, but we would run the same possible race as we did before and that's the reason we use TaskRun.status and PipelineRun.status as source of truth for the spec in all reconciler loop for a given object.

So the question is the following : Where should we store the Task (and Pipeline for PipelineRun) labels and annotations in a TaskRun object ? Because we have already release v1, we can only do "additive" changes, so, most likely, the only way would be to have a taskMetadata field in the status in addition to taskSpec.
But I am curious if anyone has any other ideas 👼🏼.

/cc @imjasonh @afrittoli @abayer @lbernick @jerop @chuangw6

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

Submitter Checklist

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

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot requested a review from abayer February 8, 2023 15:28
@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 8, 2023
@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Feb 8, 2023
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 8, 2023
Copy link
Member

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

Love it!

/lgtm


// Propagate annotations from Pipeline to PipelineRun. PipelineRun annotations take precedences over Pipeline.
pr.ObjectMeta.Annotations = kmap.Union(meta.Annotations, pr.ObjectMeta.Annotations)
// // Propagate labels from Pipeline to PipelineRun. PipelineRun labels take precedences over Pipeline.
Copy link
Member

Choose a reason for hiding this comment

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

These can just be dropped?

Copy link
Member Author

Choose a reason for hiding this comment

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

From there yes, overall no as written in the PR description.

Even if this PR propose to remove this "feature", we still want the same behavior (aka a Pod gets its labels from both the Task and the TaskRun). Because we are only "caching" the spec of the Task in TaskRun.status (and same goes for PipelineRun), we would have to query the metadata for the Task each time. Using informers, it wouldn't cost that much, but we would run the same possible race as we did before and that's the reason we use TaskRun.status and PipelineRun.status as source of truth for the spec in all reconciler loop for a given object.

So the question is the following : Where should we store the Task (and Pipeline for PipelineRun) labels and annotations in a TaskRun object ? Because we have already release v1, we can only do "additive" changes, so, most likely, the only way would be to have a taskMetadata field in the status in addition to taskSpec.
But I am curious if anyone has any other ideas 👼🏼.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 8, 2023
@lbernick
Copy link
Member

lbernick commented Feb 8, 2023

I'm curious why we can't separate out the labels/annotations propagation from the fix to #5146? i.e. if we just remove the call to update, and modify the labels of the TR/PR object passed to ReconcileKind, will knative update the object with the new metadata? Or does it only handle status updates?

Also want to better understand the race condition you're referring to. My understanding is that if a Task's labels change, we will re-reconcile the TaskRun, and update the TaskRun with the Task's new labels (and likewise for PipelineRuns). The issue described in #5297 was the PipelineRun controller replacing labels, but we've updated it to merge labels. Can you give an example scenario where the race condition you're describing occurs?

@vdemeester
Copy link
Member Author

vdemeester commented Feb 9, 2023

I'm curious why we can't separate out the labels/annotations propagation from the fix to #5146? i.e. if we just remove the call to update, and modify the labels of the TR/PR object passed to ReconcileKind, will knative update the object with the new metadata? Or does it only handle status updates?

@lbernick As you "hinted" in one of your question, this is because it only update the status 👼🏼. It doesn't update anything else (metadata or spec). The take on updating only the status is that, users are supposed to interact with metadata and spec and controllers with status (separation of concern, …). If it did, that PR would be green already (and the code I'm deleting here wouldn't have been required in the first place).

Also want to better understand the race condition you're referring to. My understanding is that if a Task's labels change, we will re-reconcile the TaskRun, and update the TaskRun with the Task's new labels (and likewise for PipelineRuns). The issue described in #5297 was the PipelineRun controller replacing labels, but we've updated it to merge labels. Can you give an example scenario where the race condition you're describing occurs?

If a Task label's change, it changes, nothing get's "reconciled" whatsoever. #5297 was not really "removing" things but overriding the content of the labels we "got" at the begining of the reconciler loop, even if, in the meantime, the PipelineRun itself was updated. But this is not the race I am talking about here.
The race I am talking about is if we choose "to query the metadata for the Task each time". If we decide to do that, we would be in the same situation as prior to use status.taskrunSpec as a source of truth. At time T, the Task would have labels "a, b and c", we start something and then we are in a new reconciler loop (new event), the labels could have been changed on the Task (now only "a and b"), and this could be seen as a race. It's less of a problem on metadata than on the spec, but still it could lead to confusing behaviour (if something acts on labels, …).

@lbernick
Copy link
Member

@lbernick As you "hinted" in one of your question, this is because it only update the status 👼🏼. It doesn't update anything else (metadata or spec). The take on updating only the status is that, users are supposed to interact with metadata and spec and controllers with status (separation of concern, …). If it did, that PR would be green already (and the code I'm deleting here wouldn't have been required in the first place).

Makes sense! I understand why you wouldn't want a controller to update the object's spec but why would it be bad for the controller to update labels? @imjasonh is there a recommended alternative pattern to use?

If a Task label's change, it changes, nothing get's "reconciled" whatsoever.

I'm not sure why I said this 🤦‍♀️ Curious if label changes in general trigger re-reconciles though?

#5297 was not really "removing" things but overriding the content of the labels we "got" at the begining of the reconciler loop, even if, in the meantime, the PipelineRun itself was updated. But this is not the race I am talking about here. The race I am talking about is if we choose "to query the metadata for the Task each time". If we decide to do that, we would be in the same situation as prior to use status.taskrunSpec as a source of truth. At time T, the Task would have labels "a, b and c", we start something and then we are in a new reconciler loop (new event), the labels could have been changed on the Task (now only "a and b"), and this could be seen as a race. It's less of a problem on metadata than on the spec, but still it could lead to confusing behaviour (if something acts on labels, …).

Makes sense, thanks for the explanation! I'm not sure off the top of my head of any solutions other than adding status.taskMetadata or something along those lines but can think a bit more

@vdemeester
Copy link
Member Author

I'm not sure why I said this Curious if label changes in general trigger re-reconciles though?

It would on the object(s) that are watched, so TaskRun or PipelineRun. There is no reconciler watching Task or Pipeline.

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 21, 2023
@tekton-robot
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 22, 2023
@tekton-robot
Copy link
Collaborator

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 21, 2023
@vdemeester
Copy link
Member Author

/remove-lifecycle rotten
Still need to rebase and rework a bit that one.. 😅

@tekton-robot tekton-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jul 3, 2023
@vdemeester vdemeester added this to the Pipeline v1 milestone Jul 3, 2023
@vdemeester vdemeester force-pushed the 5146-remove-label-and-annotation-merging branch from 6852977 to 996f60f Compare August 7, 2023 14:56
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2023
@tekton-robot
Copy link
Collaborator

New changes are detected. LGTM label has been removed.

@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 Aug 7, 2023
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from imjasonh after the PR has been reviewed.

The full list of commands accepted by this bot can be found 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

@vdemeester vdemeester changed the title wip: Remove Updating labels and annotations… Remove Updating labels and annotations… Aug 7, 2023
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 7, 2023
@vdemeester
Copy link
Member Author

Updated this, aside from some tests to be rewritten, it should be ready for review.
This removes the extra update we do during reconcilation, which means we rely solely on knative/pkg for updating the object (see #5146) and removes one possible "update" call during the loop.

/kind enhancement

@tekton-robot
Copy link
Collaborator

@vdemeester: The label(s) kind/enhancement cannot be applied, because the repository doesn't have them.

In response to this:

Updated this, aside from some tests to be rewritten, it should be ready for review.
This removes the extra update we do during reconcilation, which means we rely solely on knative/pkg for updating the object (see #5146) and removes one possible "update" call during the loop.

/kind enhancement

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vdemeester
Copy link
Member Author

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 7, 2023
@vdemeester vdemeester force-pushed the 5146-remove-label-and-annotation-merging branch from 996f60f to 9b4285b Compare August 7, 2023 15:04
Labels and Annotations on PipelineRun and TaskRun won't be mutated by
the controller anymore. Usually, a controller doesn't modify the
metadata of the object it reconcile.

This effectively remove the propagation of annotations and labels from
Task to TaskRun, and Pipeline to PipelineRun.

Instead, it stores the Task or Pipeline metadata in the corresponding
status field (`Status.PipelineMeta` for PipelineRun, and
`Status.TaskMeta` for TaskRun). Merging the two is done at the "lower"
object creation (aka when creating the `TaskRun` from `PipelineRun` or
when creating the `Pod` from `TaskRun`).

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the 5146-remove-label-and-annotation-merging branch from 9b4285b to c9831eb Compare August 7, 2023 15:59
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 7, 2023
@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/pod/pod.go 92.5% 91.6% -0.9
pkg/reconciler/taskrun/taskrun.go 85.3% 85.6% 0.3

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/pod/pod.go 92.5% 91.6% -0.9
pkg/reconciler/taskrun/taskrun.go 85.3% 85.6% 0.3

@tekton-robot
Copy link
Collaborator

@vdemeester: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-tekton-pipeline-unit-tests c9831eb link true /test tekton-pipeline-unit-tests
pull-tekton-pipeline-build-tests c9831eb link true /test pull-tekton-pipeline-build-tests
pull-tekton-pipeline-beta-integration-tests c9831eb link true /test pull-tekton-pipeline-beta-integration-tests
pull-tekton-pipeline-integration-tests c9831eb link true /test pull-tekton-pipeline-integration-tests
pull-tekton-pipeline-alpha-integration-tests c9831eb link true /test pull-tekton-pipeline-alpha-integration-tests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@jerop jerop added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 20, 2023
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 21, 2023
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 3, 2023
@tekton-robot
Copy link
Collaborator

@vdemeester: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jimmyjones2
Copy link
Contributor

Label propagation also causes issues with ArgoCD e.g
argoproj/argo-cd#5792 (comment)
argoproj/argo-cd#10982

@imjasonh imjasonh closed this May 23, 2024
@vdemeester vdemeester deleted the 5146-remove-label-and-annotation-merging branch July 3, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesnt merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reconcilers should rely on knative/pkg to Update TaskRuns and PipelineRuns
7 participants