aws / amazon-ec2-hibinit-agent

Apache License 2.0
18 stars 20 forks source link

percentage-of-ram and target-size-mb not working as expected #47

Closed judouk closed 1 month ago

judouk commented 2 months ago

I am using a Rocky8 installation on an AWS EC2 m5a.large instance I have ec2-hibinit-agent-1.0.9-1.el8.noarch installed

My /etc/hibinit-config.cfg contains

[swap]
# If there's no swap then we create it to be equal to the specified
# percentage of RAM or to the target size, whichever is greater
percentage-of-ram = 100
target-size-mb = 4000

My host has 8GB installed but the swap file is created as 4GB

# free -m
              total        used        free      shared  buff/cache   available
Mem:           7536         580        5723          11        1232        6700
Swap:             0           0           0

# ls -l /swap
-rw-------. 1 root root 4194304000 Aug 28 16:44 /swap

Looking at the logs, it seems to contradict itself. I need 7912648704....so I allocate 4194304000 !!!

Aug 28 16:50:59 workstation /hibinit-agent[29654]: Will check if swap is at least: 7536 megabytes
Aug 28 16:50:59 workstation /hibinit-agent[29654]: There's enough space (97088696320 present, 7912648704 needed) for the swap file on the device: /
Aug 28 16:50:59 workstation /hibinit-agent[29654]: Allocating 4194304000 bytes in /swap

For now, I've updated my configuration to use target-size-mb = 8192 but this feels like a bug

deborshi1988 commented 1 month ago

As provided in the comment of /etc/hibinit-config.cfg , we take into account which one is greater.

For your configuration , the percentage-of-ram = 100 was provided , so we have gone ahead with validating .

But you are correct in pointing out that there is an inconsistency. We should be allocating the same size as we are validating. We will track this issue.