Skip to content

Commit 3543d16

Browse files
committed
disable swap for system and user slices
1 parent 9bec0e9 commit 3543d16

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

jobs/e2e_node/crio/crio_cgroupv2_swap1g.ign

+5
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@
8181
"contents": "[Unit]\nDescription=Enable swap on CoreOS\nBefore=crio-install.service\n\n[Service]\nType=oneshot\nExecStart=/bin/sh -c \"sudo dd if=/dev/zero of=/var/swapfile count=1024 bs=1MiB \u0026\u0026 sudo chmod 600 /var/swapfile \u0026\u0026 sudo mkswap /var/swapfile \u0026\u0026 sudo swapon /var/swapfile \u0026\u0026 free -h\"\n\n[Install]\nWantedBy=multi-user.target\n",
8282
"enabled": true,
8383
"name": "swap-enable.service"
84+
},
85+
{
86+
"contents": "[Unit]\nDescription=Disable swap\nAfter=disableswap-system.service\n\n[Service]\nType=oneshot\nExecStart=/bin/sh -c \"sudo systemctl set-property system.slice MemorySwapMax=0\"\nExecStart=/bin/sh -c \"sudo systemctl set-property user.slice MemorySwapMax=0\"\n\n[Install]\nWantedBy=multi-user.target\n",
87+
"enabled": true,
88+
"name": "disable-swap.service"
8489
}
8590
]
8691
}

jobs/e2e_node/crio/templates/base/swap-1G.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,18 @@ systemd:
1414
1515
[Install]
1616
WantedBy=multi-user.target
17+
- name: disable-swap.service
18+
enabled: true
19+
contents: |
20+
[Unit]
21+
Description=Disable swap
22+
After=disableswap-system.service
23+
24+
[Service]
25+
Type=oneshot
26+
ExecStart=/bin/sh -c "sudo systemctl set-property system.slice MemorySwapMax=0"
27+
ExecStart=/bin/sh -c "sudo systemctl set-property user.slice MemorySwapMax=0"
28+
29+
[Install]
30+
WantedBy=multi-user.target
31+

jobs/e2e_node/crio/templates/crio_cgroupv2_swap1g.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,19 @@ systemd:
133133
Type=oneshot
134134
ExecStart=/bin/sh -c "sudo dd if=/dev/zero of=/var/swapfile count=1024 bs=1MiB && sudo chmod 600 /var/swapfile && sudo mkswap /var/swapfile && sudo swapon /var/swapfile && free -h"
135135
136+
[Install]
137+
WantedBy=multi-user.target
138+
- name: disable-swap.service
139+
enabled: true
140+
contents: |
141+
[Unit]
142+
Description=Disable swap
143+
After=disableswap-system.service
144+
145+
[Service]
146+
Type=oneshot
147+
ExecStart=/bin/sh -c "sudo systemctl set-property system.slice MemorySwapMax=0"
148+
ExecStart=/bin/sh -c "sudo systemctl set-property user.slice MemorySwapMax=0"
149+
136150
[Install]
137151
WantedBy=multi-user.target

jobs/e2e_node/swap/ubuntu-swap-1G-allocation.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ runcmd:
1717
- 'chmod 600 /swapfile'
1818
- 'mkswap /swapfile'
1919
- 'swapon /swapfile'
20+
- 'sudo systemctl set-property system.slice MemorySwapMax=0'
21+
- 'sudo systemctl set-property user.slice MemorySwapMax=0'
2022
- 'echo "/swapfile swap swap defaults 0 0" | tee -a /etc/fstab'
2123
- 'echo swap files'
2224
- 'swapon --show'

0 commit comments

Comments
 (0)