Skip to content

Commit

Permalink
disable swap for system and user slices
Browse files Browse the repository at this point in the history
  • Loading branch information
kannon92 committed Nov 5, 2024
1 parent 9bec0e9 commit 3543d16
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jobs/e2e_node/crio/crio_cgroupv2_swap1g.ign
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
"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",
"enabled": true,
"name": "swap-enable.service"
},
{
"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",
"enabled": true,
"name": "disable-swap.service"
}
]
}
Expand Down
15 changes: 15 additions & 0 deletions jobs/e2e_node/crio/templates/base/swap-1G.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ systemd:
[Install]
WantedBy=multi-user.target
- name: disable-swap.service
enabled: true
contents: |
[Unit]
Description=Disable swap
After=disableswap-system.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "sudo systemctl set-property system.slice MemorySwapMax=0"
ExecStart=/bin/sh -c "sudo systemctl set-property user.slice MemorySwapMax=0"
[Install]
WantedBy=multi-user.target
14 changes: 14 additions & 0 deletions jobs/e2e_node/crio/templates/crio_cgroupv2_swap1g.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,19 @@ systemd:
Type=oneshot
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"
[Install]
WantedBy=multi-user.target
- name: disable-swap.service
enabled: true
contents: |
[Unit]
Description=Disable swap
After=disableswap-system.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "sudo systemctl set-property system.slice MemorySwapMax=0"
ExecStart=/bin/sh -c "sudo systemctl set-property user.slice MemorySwapMax=0"
[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions jobs/e2e_node/swap/ubuntu-swap-1G-allocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ runcmd:
- 'chmod 600 /swapfile'
- 'mkswap /swapfile'
- 'swapon /swapfile'
- 'sudo systemctl set-property system.slice MemorySwapMax=0'
- 'sudo systemctl set-property user.slice MemorySwapMax=0'
- 'echo "/swapfile swap swap defaults 0 0" | tee -a /etc/fstab'
- 'echo swap files'
- 'swapon --show'
Expand Down

0 comments on commit 3543d16

Please sign in to comment.