Skip to content

Conversation

@vdemeester
Copy link
Member

Changes

Closes #8827

Let's make sure we are not propagating app.kubernetes.io/managed-by
annotation to Pods. Doing it can lead to weird behavior, for example
with applied with Helm, or if some admission controller is looking for
pipeline's Pods and do not get it if the TaskRun or PipelineRun
was created with an app.kubernetes.io/managed-by.

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

/kind bug

Submitter Checklist

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

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • 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). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Pod created by the Pipeline controller will now always have app.kubernetes.io/managed-by set to the default configuration. Prior to this change, it would be overriden by the value of that label set on TaskRun (or PipelineRun).

@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 25, 2025
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 25, 2025
@vdemeester vdemeester added this to the v1.3.0 (LTS) milestone Jun 25, 2025
@vdemeester
Copy link
Member Author

cc @twoGiants @afrittoli @waveywaves

@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 93.3% 93.3% 0.1

Let's make sure we are not propagating `app.kubernetes.io/managed-by`
annotation to Pods. Doing it can lead to weird behavior, for example
with applied with Helm, or if some admission controller is looking for
pipeline's Pods and do not get it if the `TaskRun` or `PipelineRun`
was created with an `app.kubernetes.io/managed-by`.

Signed-off-by: Vincent Demeester <[email protected]>
@vdemeester vdemeester force-pushed the 8827-no-managedby-on-pods branch from d23e33c to 07bcc83 Compare June 25, 2025 14:29
@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 93.3% 93.3% 0.1

Copy link
Member

@twoGiants twoGiants left a comment

Choose a reason for hiding this comment

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

Looks good 😸 👍

I found one typo and have a question/idea about the location of the change. It can be left as it is but maybe there is a better place, see my comment below.

// KubectlLastAppliedAnnotationKey is the key used by kubectl to store its last applied configuration (using kubectl apply)
KubectlLastAppliedAnnotationKey = "kubectl.kubernetes.io/last-applied-configuration"

// KubernetesLastAppliedAnnotationKey is the key used by tools to tell who is managing an object
Copy link
Member

Choose a reason for hiding this comment

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

Small typo: // KubernetesLastAppliedAnnotationKey => // KubernetesManagedByAnnotationKey

labels[pipeline.TaskRunLabelKey] = s.Name
labels[pipeline.TaskRunUIDLabelKey] = string(s.UID)
// Enforce app.kubernetes.io/managed-by to be the value configured
labels[tknreconciler.KubernetesManagedByAnnotationKey] = defaultManagedByLabelValue
Copy link
Member

Choose a reason for hiding this comment

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

Just thinking out loud: could this live in the pipelinerun reconciler when the TaskRun is created with it's labels and annotations? For example here in getTaskRunLabels line 1408. Then those labels should be correctly propagated down to the pod right?

And the same for excluding the annotation. You could enforce it here in the getTaskrunAnnotations line 1358.

Then no change to pod would be necessary and the source of truth remains the place where the labels and annotations are set in the first place.

Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure, for me no matter what is there on TaskRun and PipelineRun, we really do not want this particular label to be propagated. So the quickest path to it was to do it when we create the Pod.

Copy link
Member

Choose a reason for hiding this comment

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

You could also add a test which checks that the Annotation was not set.

And because this PR resolves a bug we could add a comment with the issue reference to the added tests mentioning that those test checks against a resolved bug from #8827.

},
Annotations: podAnnotations,
Labels: makeLabels(taskRun),
Labels: makeLabels(taskRun, defaultManagedByLabelValue),
Copy link
Member

Choose a reason for hiding this comment

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

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: twoGiants, waveywaves

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 Jun 27, 2025
@waveywaves
Copy link
Member

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 27, 2025
@tekton-robot tekton-robot merged commit fa2dc29 into tektoncd:main Jun 27, 2025
31 of 32 checks passed
@vdemeester vdemeester deleted the 8827-no-managedby-on-pods branch June 27, 2025 18:29
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/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

Status: Done

4 participants