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

kubelet: cgroupv2 disable memcg notifications #106332

Merged
merged 1 commit into from
Nov 13, 2021

Conversation

bobbypage
Copy link
Member

@bobbypage bobbypage commented Nov 10, 2021

What type of PR is this?

/kind bug

What this PR does / why we need it:

The kubelet memory notifier relies on reading
cgroup.event_control which is unsupported on cgroupv2. For now, let's
disable the memory notifier on cgroupv2.

Which issue(s) this PR fixes:

Fixes #106331

Special notes for your reviewer:

As a more short term solution, I propose to disable kernel memcg notifications on kubelet for cgroupv2 since it's currently not supported. Longer term, we should consider how we adapt kubelet eviction as a whole to take advtange of new cgroupv2 features.

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


The current memory notifier on cgroupv2 relies on reading
`cgroup.event_control` which is unsupported on cgroupv2. For now, let's
disable the feature on cgroupv2.
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. 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-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 10, 2021
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 10, 2021
@bobbypage
Copy link
Member Author

/hold

To get some feedback and perform some testing

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 11, 2021
Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@bobbypage
Copy link
Member Author

/assign @Dragoncell @mrunalp @giuseppe

@bobbypage
Copy link
Member Author

bobbypage commented Nov 11, 2021

Tested as follows, started a cluster on GCE with ubuntu cgroupv2 image with and without this change:

# ubuntu-2110 "Impish Indri" has cgroupv2 enabled
UBUNTU_IMAGE=$(gcloud compute images list --project="ubuntu-os-cloud" --no-standard-images --format=json | jq -r '.[] | select(.family=="ubuntu-2110") | .name')

KUBE_UBUNTU_INSTALL_CONTAINERD_VERSION=v1.5.7 \
  KUBE_UBUNTU_INSTALL_RUNC_VERSION=v1.0.2 \
  KUBE_MASTER_OS_DISTRIBUTION=ubuntu \
  KUBE_GCE_MASTER_IMAGE=${UBUNTU_IMAGE} \
  KUBE_GCE_MASTER_PROJECT=ubuntu-os-cloud \
  KUBE_NODE_OS_DISTRIBUTION=ubuntu \
  KUBE_GCE_NODE_IMAGE="${UBUNTU_IMAGE}" \
  KUBE_GCE_NODE_PROJECT=ubuntu-os-cloud \
  KUBE_KUBELET_EXTRA_ARGS="--kernel-memcg-notification=true" kubetest \
    --build \
    --up \
    --provider=gce \
    --gcp-node-image=ubuntu \
    --gcp-master-image=ubuntu \
    --gcp-zone=us-central1-c \
    --gcp-project=${GCP_PROJECT} \
    --gcp-nodes=1

Without this change (failed to update notifier due to reading non-existent cgroup.event_control file)

$ journalctl -u kubelet | grep "eviction"
Nov 11 00:36:37 e2e-test-porterdavid-minion-group-wsqk kubelet[6645]: I1111 00:36:37.426226    6645 memory_threshold_notifier.go:101] "Eviction manager: setting notifier to capacity" notifier="hard memory eviction threshold" capacity="9139312Ki"
Nov 11 00:36:37 e2e-test-porterdavid-minion-group-wsqk kubelet[6645]: I1111 00:36:37.426278    6645 eviction_manager.go:262] "Eviction manager: failed to update notifier" notifier="hard memory eviction threshold" err="no such file or directory"
Nov 11 00:36:37 e2e-test-porterdavid-minion-group-wsqk kubelet[6645]: I1111 00:36:37.426298    6645 memory_threshold_notifier.go:101] "Eviction manager: setting notifier to capacity" notifier="hard allocatable memory eviction threshold" capacity="7373584Ki"
Nov 11 00:36:37 e2e-test-porterdavid-minion-group-wsqk kubelet[6645]: I1111 00:36:37.426325    6645 eviction_manager.go:262] "Eviction manager: failed to update notifier" notifier="hard allocatable memory eviction threshold" err="no such file or directory"
Nov 11 00:36:37 e2e-test-porterdavid-minion-group-wsqk kubelet[6645]: I1111 00:36:37.426572    6645 eviction_manager.go:328] "Eviction manager: no resources are starved"

and with this change (no such errors):

Nov 11 01:07:20 e2e-test-porterdavid-minion-group-05km kubelet[4160]: I1111 01:07:20.364273    4160 memory_threshold_notifier.go:101] "Eviction manager: setting notifier to capacity" notifier="hard allocatable memory eviction threshold" capacity="7371440Ki"
Nov 11 01:07:20 e2e-test-porterdavid-minion-group-05km kubelet[4160]: I1111 01:07:20.365310    4160 eviction_manager.go:328] "Eviction manager: no resources are starved"
Nov 11 01:07:30 e2e-test-porterdavid-minion-group-05km kubelet[4160]: I1111 01:07:30.366155    4160 eviction_manager.go:237] "Eviction manager: synchronize housekeeping"
Nov 11 01:07:30 e2e-test-porterdavid-minion-group-05km kubelet[4160]: I1111 01:07:30.386698    4160 memory_threshold_notifier.go:101] "Eviction manager: setting notifier to capacity" notifier="hard memory eviction threshold" capacity="9134780Ki"
Nov 11 01:07:30 e2e-test-porterdavid-minion-group-05km kubelet[4160]: I1111 01:07:30.386719    4160 memory_threshold_notifier.go:101] "Eviction manager: setting notifier to capacity" notifier="hard allocatable memory eviction threshold" capacity="7371440Ki"
Nov 11 01:07:30 e2e-test-porterdavid-minion-group-05km kubelet[4160]: I1111 01:07:30.386949    4160 eviction_manager.go:328] "Eviction manager: no resources are starved"

@SergeyKanzhelev
Copy link
Member

/triage accepted
/priority important-soon

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 11, 2021
@SergeyKanzhelev SergeyKanzhelev moved this from Triage to Needs Reviewer in SIG Node PR Triage Nov 11, 2021
@mrunalp
Copy link
Contributor

mrunalp commented Nov 11, 2021

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobbypage, giuseppe, mrunalp

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 11, 2021
@bobbypage
Copy link
Member Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 11, 2021
// Instead long term, on cgroupv2 kubelet should rely on combining usage of memory.low on root pods cgroup with inotify notifications on memory.events and or PSI pressure.
// For now, let's return a fake "disabled" cgroup notifier on cgroupv2.
// https://github.com/kubernetes/kubernetes/issues/106331
if libcontainercgroups.IsCgroup2UnifiedMode() {
Copy link
Member

Choose a reason for hiding this comment

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

Should we not start the notifier at all in eviction_manager while enable kernelMemcgNotification
but on cgroupv2 ?

notifier, err := NewMemoryThresholdNotifier(threshold, m.config.PodCgroupRoot, &CgroupNotifierFactory{}, thresholdHandler)

Copy link
Member Author

@bobbypage bobbypage Nov 12, 2021

Choose a reason for hiding this comment

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

that would work too, but I choose to disable it in the NewCgroupNotifier, so calling Start() will be a no-op. I guess there's not big difference on where exactly to disable it.

The other reason it seems like eviction manager logic there is a bit "higher level" in general, and doesn't really have any cgroup related logic, so I wanted to keep this check contained in the lower level package closer to the other cgroup related logic.

@mrunalp
Copy link
Contributor

mrunalp commented Nov 13, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 13, 2021
@k8s-ci-robot k8s-ci-robot merged commit e4c7951 into kubernetes:master Nov 13, 2021
SIG Node PR Triage automation moved this from Needs Reviewer to Done Nov 13, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Nov 13, 2021
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/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

kubelet kernelMemcgNotification are not supported on cgroupv2
7 participants