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

Filtered Informer is not configured fully. Too many pods are in the informer. #4398

Open
guillaumerose opened this issue Nov 26, 2021 · 12 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.

Comments

@guillaumerose
Copy link
Contributor

Expected Behavior

The informer should have only pods with label app.kubernetes.io/managed-by=tekton-pipelines or the value of the config default-managed-by-label-value

https://github.com/tektoncd/pipeline/blob/main/config/config-defaults.yaml#L52

Actual Behavior

The informer has too many pods in his memory.

Steps to Reproduce the Problem

  1. Modify the code of the pipeline controller to display the number of pods in the informer
go func() {
	for {
		pods, err := podInformer.Lister().List(labels.Everything())
		if err != nil {
			logger.Fatal(err)
		}
		logger.Error(len(pods))
		time.Sleep(time.Second)
	}
}()
  1. Create a TaskRun
  2. Create a pod with a label app.kubernetes.io/managed-by: not-tekton-at-all

Additional Info

The filteredinformerfactory is configured here:

ctx = filteredinformerfactory.WithSelectors(ctx, v1beta1.ManagedByLabelKey)

The podinformer is configured here:
podInformer := filteredpodinformer.Get(ctx, v1beta1.ManagedByLabelKey)

@guillaumerose guillaumerose added the kind/bug Categorizes issue or PR as related to a bug. label Nov 26, 2021
@vdemeester
Copy link
Member

One of the comment in the config-defaults for this is:

    # default-managed-by-label-value contains the default value given to the
    # "app.kubernetes.io/managed-by" label applied to all Pods created for
    # TaskRuns. If a user's requested TaskRun specifies another value for this
    # label, the user's request supercedes.

This is most likely why we are looking at all app.kubernetes.io/managed-by pods, because users could overwrite it in there task/taskrun to integrate it with their tooling.
Allowing this or not can be discussed (and is a bit linked to #4366) but as it's currently allowed, I don't see a straightforward way to fix this 🙃 . At least we filter out all pods that do not use app.kubernetes.io/managed-by labels.

/cc @imjasonh @bobcatfish @afrittoli @sbwsg

@ghost
Copy link

ghost commented Nov 29, 2021

Can we limit the lister to the default label and fork the logic so that a TaskRun with its own managed-by label causes us to skip the lister and query the cluster directly?

@vdemeester
Copy link
Member

Can we limit the lister to the default label and fork the logic so that a TaskRun with its own managed-by label causes us to skip the lister and query the cluster directly?

That might be problematic if pipeline is used "transparently" by some higher level tool. Assuming that I have a tool called foo that always setup this managed-by label, this would make the controller query the cluster a lot and could become a problem. That said, I do think we may want to have / introduce a label for us that cannot be overriden for this particular purpose. Either we disallow overriding app.kubernetes.io/manage-by or we come up with our "own" internal one ?

@imjasonh
Copy link
Member

Can we have two labels, one for Tekton's internal usage, and one for whatever service is built on top of Tekton that might want to hide the Tekton internals (configured by configmap as today)? Then we could have the informer filter by the Tekton-internal label.

Maybe we could use app.kubernetes.io/created-by: tekton-pipeline-controller? (see common labels)

@vdemeester
Copy link
Member

Can we have two labels, one for Tekton's internal usage, and one for whatever service is built on top of Tekton that might want to hide the Tekton internals (configured by configmap as today)? Then we could have the informer filter by the Tekton-internal label.

Maybe we could use app.kubernetes.io/created-by: tekton-pipeline-controller? (see common labels)

Yes, that was what I was thinking too in my last comment. And I missed app.kubernetes.io/created-by label somehow, but I think it's definitely a very good candidate for it. The only thing we need to make sure is to disallow (or prevent) this label to be overriden by the user (by adding it to the TaskRun or PipelineRun object), either silently or loudly 👼🏼

@guillaumerose
Copy link
Contributor Author

That sounds to be a good idea. I am wondering how it works for the upgrade 🤔

If a pipeline is done before the upgrade, it's fine.
If a pipeline is running, eg. pods don't have correct labels, after upgrade, the controller won't see them because of the new filter.

Am I correct? Do we need to roll this new label across multiples releases?

@vdemeester
Copy link
Member

Am I correct? Do we need to roll this new label across multiples releases?

Good question, we will need to be careful here on how we handle this, but yes we'll have to think of backward compatibility.

@lbernick
Copy link
Member

/priority important-longterm

@tekton-robot tekton-robot added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Dec 13, 2021
@nikhil-thomas
Copy link
Member

nikhil-thomas commented Dec 13, 2021

That sounds to be a good idea. I am wondering how it works for the upgrade 🤔

If a pipeline is done before the upgrade, it's fine. If a pipeline is running, eg. pods don't have correct labels, after upgrade, the controller won't see them because of the new filter.

Am I correct? Do we need to roll this new label across multiples releases?

This sounds like a problem for our operator to solve.

At present, the operator upgrades TektonPipeline, TektonTriggers etc immediately after an operator controller upgrade. The only check the operator has is version comparission (pipelines-info configMap) of Tektoncd Pipeline (on-cluster vs new release).

It could be straight forward to add a mechanism to delay (requeue) the upgrade if there are active taskRuns. This could be a decent starting point. We could improve this by adding a timeout for this requeue or by implementing a notion of 'maintenance window'.

@ghost ghost added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Jan 24, 2022
@ghost
Copy link

ghost commented Mar 21, 2022

/help cancel

Removing help wanted label because it sounds like it needs design input before it can more forward?

@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 Jun 22, 2022
@vdemeester
Copy link
Member

/lifecycle frozen

@tekton-robot tekton-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.
Projects
Status: Todo
Development

No branches or pull requests

6 participants