Repository navigation
fix: switch the swap file on during the play - #34
Conversation
Nothing notified the swapon handler, so swap only became active after the next reboot, and mkswap was a handler too, so a play that failed before its end left the file unformatted for good: later runs saw the file and notified nothing. Format the file whenever it lacks the swap signature and enable it whenever it isn't active, as tasks right after it is created, so the steps that follow get the memory and an interrupted run is repaired.
MarkProminic
left a comment
There was a problem hiding this comment.
Please note that a Swap was already included in the base STARTcloud Image:
Please confirm this is not going to override or break the work done in the templating process for existing projects that would use the swap role(I can't think of any, but there may be)
|
Confirmed: the role only manages the swap file at swap_file_path and never touches the partition the base image carries, so this adds a second swap area rather than replacing anything; that is already the state after the first reboot today, the change only moves mkswap/swapon into the play. The /proc/swaps and dd checks match what disable.yml and the molecule verifier already do. One note: the 4086 offset assumes 4 KiB pages, same as the verifier; fine for every amd64 box here, just be aware of it. Approving. |
Written with Claude Opus 5.5
Fixes #30.
Change
The
swaprole created the swap file and its fstab entry, but swap only became active after the next reboot:mkswapwas a handler too. A play that failed before its end left the file unformatted for good, because later runs saw that the file existed (creates:) and notified nothing.Both steps are now tasks in
tasks/enable.yml, run right after the file is created and its permissions set:SWAPSPACE2signature, the same check the molecule verifier uses. A second run therefore changes nothing, and an unformatted file left by a failed run is repaired./proc/swaps. It's still skipped underswap_test_mode.The two unused handlers are removed. Permissions are now set before
mkswap, so the file is never formatted while it's world-readable.Testing
swap_test_mode: true, as in the molecule scenario:SWAPSPACE2).sysctl, which is unrelated to this change.swaponitself can't run in a container. On a Debian 12 EC2 instance where the old role had left/swapfileunformatted and inactive, running the samemkswapandswaponcommands enabled 4 GB of swap.prettier --checkandyamllintpass.