Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

New feature: resizing existing swapfiles #55

Merged
merged 1 commit into from
May 4, 2016

Conversation

petems
Copy link
Owner

@petems petems commented Apr 23, 2016

  • Inspired by the work by @acjohnson
  • Uses the $::swapfile_sizes fact as a hash
  • Checks if a swapfile already exists in the hash
  • If it does, compares sizes
  • If the size differs over the margin given (defaulting to 5MB) then it swap off the swap and deletes it
  • Adding a before to the Exec means that it ensure's it'll get made before it.
  • Adds some specific functions to allow cleaner code in the resize_swapfile defined type

@petems
Copy link
Owner Author

petems commented Apr 23, 2016

@acjohnson here's a working implementation with stringify_facts false, I've got a CSV fact for getting it to work on older Puppet, let me try and fix that now 👍

@petems petems force-pushed the allow_resizing_of_swapfiles branch from 2851f55 to 36ab379 Compare April 23, 2016 13:25
@acjohnson
Copy link

Awesome, so two different facts depending on how stringify is configured.

Cool, is this working then? I'll test it if you think it's ready to test.

@petems
Copy link
Owner Author

petems commented Apr 25, 2016

@acjohnson I haven't quite got the non-stringify_facts part of it working yet, but I'm going to probably merge the stringify_facts false version to get the basics down, then get an acceptance test for hte other path and get the other version working 👍

@petems petems force-pushed the allow_resizing_of_swapfiles branch 13 times, most recently from 60099a4 to c403a66 Compare May 2, 2016 20:57
@petems petems force-pushed the allow_resizing_of_swapfiles branch from c403a66 to 4756a67 Compare May 2, 2016 23:43
* Inspired by the work by @acjohnson
* Uses the $::swapfile_sizes fact as a hash
* Checks if a swapfile already exists
* If it does, compares sizes
* If the size differs over the margin given (defaulting to 50MB) then `swapoff` the swap and deletes it
* The reason we have a margin is...
* The to_bytes method uses layman math for MB: 1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB.
* Adding a `before` to the Exec means that it ensure's it'll get made before it.
* Adds a some specific functions to get a difference with margin
* Cleaner than having to do (max($arg1, $arg2) - min($arg1,$arg2) - $margin)
* This approach currently doesn't work for `stringify_facts` is true, because the hash of swap files gets turned into a string.
* Right now this will error out, but I'm going to make a function to make a CSV fact for the future!
@petems petems force-pushed the allow_resizing_of_swapfiles branch from 4756a67 to fd0d8a2 Compare May 4, 2016 15:22
@petems petems merged commit 318a12e into master May 4, 2016
@petems petems mentioned this pull request May 4, 2016
@petems petems deleted the allow_resizing_of_swapfiles branch May 4, 2016 15:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants