refactor ♻️: Refactor memory variables and calculations #32
Reference in New Issue
Block a user
Delete Branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Renamed
_total_ram_mbtolog2ram_host_memtotal_mband updated the calculation accordingly. Updated variable names for memory checks in swap task.Review Summary
log2ram_host_memtotal_mb, which defaults to the current system memory or 4086MB if not available. This allows for dynamic adjustment of the log2ram size based on the host's total memory. While this change seems mostly logical and improves maintainability, there is a potential minor issue regarding the use ofhost_memtotal_mb | default(4086). If thehost_memtotal_mbvariable does not exist or is undefined for some reason, the default value will always be 4086MB. In case of insufficient memory on the host andhost_memtotal_mbis incorrectly set or missing, this may lead to excessive log2ram size allocation, which could potentially impact system performance. To mitigate this issue, you might consider adding a check for the availability ofhost_memtotal_mbbefore applying the default value.log2ram_host_memtotal_mbandlog2ram_ram_percent. This should not significantly affect the logic, security, performance, or maintainability of the script. However, it's worth noting that we are now dependent on these two new variables being set properly.ansible_memtotal_mbwithlog2ram_host_memtotal_mb. This change may improve consistency and accuracy in memory calculations, aslog2ram_host_memtotal_mbmight provide a more reliable value for the host's memory.@@ -37,6 +37,7 @@ log2ram_ram_percent: 10log2ram_min_size_mb: 128log2ram_max_size_mb: 1024log2ram_host_memtotal_mb: "{{ host_memtotal_mb | default(4086) }}"[Score: 2] Potential performance impact if
host_memtotal_mbis missing or incorrectly set and excessive log2ram size allocation occurs. Consider adding a check for the availability ofhost_memtotal_mbbefore applying the default value.