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

Trim managedFields in controller-manager #118455

Merged
merged 3 commits into from
Aug 15, 2023

Conversation

linxiulei
Copy link
Contributor

@linxiulei linxiulei commented Jun 5, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Improve memory efficiency for kube-controller-manager

Which issue(s) this PR fixes:

Fixes #118454

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Improve memory usage of kube-controller-manager by dropping the `.metadata.managedFields` field that kube-controller-manager doesn't require.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 5, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @linxiulei. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/code-generation sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 5, 2023
@linxiulei
Copy link
Contributor Author

/cc @wojtek-t @apelisse @alexzielenski

@apelisse
Copy link
Member

apelisse commented Jun 5, 2023

cc @alexzielenski

@apelisse
Copy link
Member

apelisse commented Jun 5, 2023

The PR description could be improved since a single word doesn't describe it properly. And somehow I don't see any change related to ManagedFields, nor how it fixes the linked issue? Am I missing something?

@linxiulei linxiulei changed the title Managed fields Trim managedFields in controller-manager Jun 5, 2023
@nayihz
Copy link
Contributor

nayihz commented Jun 6, 2023

should we modify every informer according on your way which we don't use managedFileld?

@alexzielenski
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jun 6, 2023
@k8s-ci-robot k8s-ci-robot merged commit 1acd489 into kubernetes:master Aug 15, 2023
12 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Aug 15, 2023
dcbw added a commit to dcbw/ovn-kubernetes-1 that referenced this pull request Nov 13, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw pushed a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 15, 2023
kubernetes/kubernetes#118455

Kubernetes-commit: c86f562f29b6b7498ea962d2ac596e6d26ecd723
Kubernetes-commit: 9c4651bd0479b84f5e5913649207476717f3f13e
dcbw added a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 15, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw added a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 15, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw pushed a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 15, 2023
kubernetes/kubernetes#118455

Kubernetes-commit: c86f562f29b6b7498ea962d2ac596e6d26ecd723
Kubernetes-commit: 9c4651bd0479b84f5e5913649207476717f3f13e

Signed-off-by: Eric Lin <[email protected]>
dcbw added a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 15, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw added a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 15, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw added a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 15, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw added a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 22, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw pushed a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 22, 2023
kubernetes/kubernetes#118455

Kubernetes-commit: c86f562f29b6b7498ea962d2ac596e6d26ecd723
Kubernetes-commit: 9c4651bd0479b84f5e5913649207476717f3f13e

Signed-off-by: Eric Lin <[email protected]>
dcbw added a commit to dcbw/ovn-kubernetes that referenced this pull request Nov 22, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw pushed a commit to dcbw/ovn-kubernetes-1 that referenced this pull request Nov 29, 2023
kubernetes/kubernetes#118455

Kubernetes-commit: c86f562f29b6b7498ea962d2ac596e6d26ecd723
Kubernetes-commit: 9c4651bd0479b84f5e5913649207476717f3f13e

Signed-off-by: Eric Lin <[email protected]>
dcbw added a commit to dcbw/ovn-kubernetes-1 that referenced this pull request Nov 29, 2023
We don't care about them, so why cache them and use a ton
of memory.

Inspired by kubernetes/kubernetes#118455

Signed-off-by: Dan Williams <[email protected]>
dcbw pushed a commit to dcbw/ovn-kubernetes that referenced this pull request Dec 4, 2023
kubernetes/kubernetes#118455

Kubernetes-commit: c86f562f29b6b7498ea962d2ac596e6d26ecd723
Kubernetes-commit: 9c4651bd0479b84f5e5913649207476717f3f13e

Signed-off-by: Eric Lin <[email protected]>
vthapar added a commit to vthapar/submariner-addon that referenced this pull request Feb 12, 2024
Trim ManagedFields to reduce shared informer memory usage.
Currently it is only for kubernetes client based informers. Once
other generated clients use newer version of k8s/client-go [0.29]
we can apply the trim to them too.

Refer: kubernetes/kubernetes#118455

Signed-off-by: Vishal Thapar <[email protected]>
vthapar added a commit to vthapar/submariner-addon that referenced this pull request Feb 12, 2024
Trim ManagedFields to reduce shared informer memory usage.
Currently it is only for kubernetes client based informers. Once
other generated clients use newer version of k8s/client-go [0.29]
we can apply the trim to them too.

Refer: kubernetes/kubernetes#118455

Signed-off-by: Vishal Thapar <[email protected]>
vthapar added a commit to vthapar/submariner-addon that referenced this pull request Feb 15, 2024
Trim ManagedFields to reduce shared informer memory usage.
This requires informers generated with  newer version of k8s/client-go [0.29]
so currently it is done for following informers:
 - k8s
 - submarinerconfig

Rest informers should be updated once WithTransform() is available.

Refer: kubernetes/kubernetes#118455

Signed-off-by: Vishal Thapar <[email protected]>
openshift-merge-bot bot pushed a commit to stolostron/submariner-addon that referenced this pull request Feb 27, 2024
Trim ManagedFields to reduce shared informer memory usage.
This requires informers generated with  newer version of k8s/client-go [0.29]
so currently it is done for following informers:
 - k8s
 - submarinerconfig

Rest informers should be updated once WithTransform() is available.

Refer: kubernetes/kubernetes#118455

Signed-off-by: Vishal Thapar <[email protected]>
@liggitt
Copy link
Member

liggitt commented Apr 16, 2024

A data race on resync was just reported in use of WithTransform in #124337 that may affect this use

@wojtek-t
Copy link
Member

heh...
the problem is that for Resync operation we take object that is already existing in the store (DeltaFifo in this case).
And there is chance of touching (reading) that object at the same time.

We effectively can't call Transform for SYNC events here:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/cache/delta_fifo.go#L456

@liggitt
Copy link
Member

liggitt commented Apr 16, 2024

We effectively can't call Transform for SYNC events here:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/client-go/tools/cache/delta_fifo.go#L456

Or delete events where the object is DeletedFinalStateUnknown, and maybe also for Replace (the docs there are unclear - "In cases involving Replace(), such an object can come through multiple times.")

@wojtek-t
Copy link
Member

Or delete events where the object is DeletedFinalStateUnknown, and maybe also for Replace (the docs there are unclear - "In cases involving Replace(), such an object can come through multiple times.")

Good point on the DeletedFinalStateUnknown.

Regarding Replace() - this is probably true in theory, but in practice we only replace with a net new result of List call, so in practice it's not a problem [although we should clarify the contract there or sth]

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. area/code-generation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube-controller-manager should not cache managedFields
9 participants