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

Revisit enabling swap on zram by default #859

Open
dustymabe opened this issue Jun 10, 2021 · 17 comments
Open

Revisit enabling swap on zram by default #859

dustymabe opened this issue Jun 10, 2021 · 17 comments
Labels
jira for syncing to jira kind/enhancement

Comments

@dustymabe
Copy link
Member

We've recently been discussing swap-on-zram again (see systemd-oomd discussion).

In the past when we decided to wait we also said we would revisit.

This would probably consist of including the zram-generator-defaults package and then documenting how to opt-out.

@dustymabe
Copy link
Member Author

Also worth noting that Kubernetes has accepted the proposal to support swap in 1.22: kubernetes/kubernetes#53533

@dustymabe dustymabe added the meeting topics for meetings label Jun 15, 2021
@lucab
Copy link
Contributor

lucab commented Jun 16, 2021

The zram-generator-defaults RPM is effectively just a /usr/lib/systemd/zram-generator.conf file, and at least we could make sure the content of https://docs.fedoraproject.org/en-US/fedora-coreos/sysconfig-configure-swaponzram/ is aligned with that.

@jlebon
Copy link
Member

jlebon commented Jun 16, 2021

We discussed this in the meeting today. No concrete outcome. This seems very similar to #840.

ISTM like either we optimize for k8s and leave things disabled, or we optimize for the single node case and require k8s distros to disable things. Either way someone will have to do some work.

My personal opinion (without digging into the specific cases here) is: we don't ship with k8s, we ship standalone and should be ready to use as is. And in that capacity, there's an expectation that we feel and act like traditional Fedora (obviously apart of what makes FCOS FCOS). Setting up k8s already requires extra steps to set up the host, so this isn't really a heavy burden to carry (but I agree we should otherwise try to keep that burden to a minimum when it doesn't conflict with the single node case).

Edit: or maybe a simpler way to say this is just: we default to the single node case, but we're easily configurable for k8s.

@dustymabe
Copy link
Member Author

We discussed the cross section of this with the oomd change in the community meeting today.

@jdoss is working on doing some testing and we'll hear back from him next week.

We did make a small decision:

  * AGREED: since oomd works better with swap, let's tie the swaponzram
    proposal and the oomd proposals together. If we do one, we do the
    other.  (dustymabe, 16:50:58)

but we also decided to take a step back and discuss single node versus kubernetes defaults briefly first: #880

@dustymabe dustymabe removed the meeting topics for meetings label Jun 23, 2021
@jdoss
Copy link
Contributor

jdoss commented Jul 1, 2021

@jdoss is working on doing some testing and we'll hear back from him next week.

My coworker and I did the testing and posted it in the other issue: #840 (comment)

@miabbott miabbott added the jira for syncing to jira label Jul 29, 2021
@travier
Copy link
Member

travier commented Aug 12, 2021

https://kubernetes.io/blog/2021/08/09/run-nodes-with-swap-alpha/ > Alpha support in K8s 1.22

@travier
Copy link
Member

travier commented Sep 25, 2023

https://kubernetes.io/blog/2023/08/24/swap-linux-beta/ > Beta support in 1.28

@c4rt0 c4rt0 added the meeting topics for meetings label Feb 15, 2024
@jlebon
Copy link
Member

jlebon commented Feb 21, 2024

AFAICT, it's still in Beta in 1.29.

It'd be great to close this gap. We should dig into what the failure mode is nowadays when bringing up a cluster on top of nodes with swap (and the feature disabled). (E.g. is it a hard error? a warning?)

@prestist prestist removed the meeting topics for meetings label Feb 21, 2024
@prestist
Copy link
Contributor

We talked about this in the meeting today, @jlebon's comment. Additonally
ACTION: fifofonix to bring up a 1.28 cluster with zswap (@spresti:fedora.im, 17:35:26)

@kannon92
Copy link

kannon92 commented Mar 19, 2024

hello, I've been working on swap in kube for 1.30 with itamar. Please bring up any findings you have.

I did a test yesterday where I brought up a kubernetes dev cluster (local-up-cluster) with crio and LimitedSwap.

In 1.30, we are turning the feature on by default but disabling swap usage (NoSwap). We did not recommend zram at the moment but that was mostly due to lack of support for memory based swap on most OSes.

Some things we do wonder about is if we use zwap, do we have to worry about setting any cgroups differently from memory.swap.max?

@kannon92
Copy link

AFAICT, it's still in Beta in 1.29.

It'd be great to close this gap. We should dig into what the failure mode is nowadays when bringing up a cluster on top of nodes with swap (and the feature disabled). (E.g. is it a hard error? a warning?)

In kubernetes (kubelet) there is a config called --fail-swap-on. If swap is detected and this field is set to true, kubelet will fail to start.

We aren't changing this behavior in Kubernetes. So for swap enabled node, we would recommend setting --fail-swap-on=false.

Feature is enabled in 1.30 by default but we set a configuration to disallow pods to utilize swap.

@fifofonix
Copy link

Confirmed, as @kannon92 explained above that on k8s 1.28.3 kubelet exits when it detects zram. Error message below. I think the main ask was to understand this behaviour. I haven't tried to enable --fail-swap-on at this point.

E0325 22:53:14.934951   10211 run.go:74] "command failed" err="failed to run Kubelet: running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: [Filename\t\t\t\tType\t\tSize\t\tUsed\t\tPriority /dev/zram0                              partition\t4194300\t\t0\t\t100]"

@iholder101
Copy link

Confirmed, as @kannon92 explained above that on k8s 1.28.3 kubelet exits when it detects zram. Error message below. I think the main ask was to understand this behaviour. I haven't tried to enable --fail-swap-on at this point.

E0325 22:53:14.934951   10211 run.go:74] "command failed" err="failed to run Kubelet: running with swap on is not supported, please disable swap! or set --fail-swap-on flag to false. /proc/swaps contained: [Filename\t\t\t\tType\t\tSize\t\tUsed\t\tPriority /dev/zram0                              partition\t4194300\t\t0\t\t100]"

Can you please try again with --fail-swap-on=false?

@travier
Copy link
Member

travier commented Mar 27, 2024

Did you set the config as specified in https://kubernetes.io/blog/2023/08/24/swap-linux-beta/ ?

Additionally, you must disable the failSwapOn configuration setting, or the deprecated --fail-swap-on command line flag must be deactivated.

@fifofonix
Copy link

Initial tests with 1.28.3 applying the kubelet config changes you linked @travier allows worker nodes to operate successfully with zram. Full disclosure I did not run the entire cluster with these changes meaning controller nodes did not have zram enabled but I think this test is still valid?

@travier travier changed the title 2021: Revisit SwapOnZram Revisit enabling swap on zram by default (was: 2021: Revisit SwapOnZram) Apr 3, 2024
@jlebon jlebon changed the title Revisit enabling swap on zram by default (was: 2021: Revisit SwapOnZram) Revisit enabling swap on zram by default Apr 3, 2024
@jlebon
Copy link
Member

jlebon commented Apr 3, 2024

In 1.30, we are turning the feature on by default but disabling swap usage (NoSwap). We did not recommend zram at the moment but that was mostly due to lack of support for memory based swap on most OSes.

@kannon92 To be really clear, in 1.30, the kubelet will successfully start on a node with swap, with the default config (i.e. without failSwapOn: false/--fail-swap-on=false), but pods will not make any use of swap?

Some things we do wonder about is if we use zwap, do we have to worry about setting any cgroups differently from memory.swap.max?

Can you clarify? Are you asking whether pods should have different memory.swap.max settings from the root cgroup?

@kannon92
Copy link

kannon92 commented Apr 3, 2024

@kannon92 To be really clear, in 1.30, the kubelet will successfully start on a node with swap, with the default config (i.e. without failSwapOn: false/--fail-swap-on=false), but pods will not make any use of swap?

Yes.

Some things we do wonder about is if we use zwap, do we have to worry about setting any cgroups differently from memory.swap.max?

Can you clarify? Are you asking whether pods should have different memory.swap.max settings from the root cgroup?

Forgive me, I misunderstood zswap and zram. I actually tested this on fedora 39 and everything looks to be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira for syncing to jira kind/enhancement
Projects
None yet
Development

No branches or pull requests