community.mongodb
community.mongodb copied to clipboard
mongodb_linux: Check rhel7/8 thp settings
SUMMARY
The following tasks checks the transparent huge pages settings...
https://github.com/ansible-collections/community.mongodb/blob/master/roles/mongodb_linux/tasks/main.yml#L129
Looks like there could be a difference with how RHEL 7 and 8 display this data meaning it's broken.
In RHEL8 it's
cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never
RHEL7 the value is just a single word, i.e. "never" or "always"
ISSUE TYPE
- Bug Report
COMPONENT NAME
mongodb_linux
Either change the check to:
cat /sys/kernel/mm/transparent_hugepage/enabled | grep -o "\[never\]"
Or don't check at all and just enable the service!
I would go w/ the second option.
I guess this was done for idempotency reasons so it probably needs option 1
Check this on a couple of docker images and the output seems the same for RHEL 7/8 versions.
➜ ~ docker run -ti roboxes/rhel7 bash Unable to find image 'roboxes/rhel7:latest' locally latest: Pulling from roboxes/rhel7 5c526373c5e2: Pull complete Digest: sha256:27979023e0819ff152dd7c20f37d4204212faa11602d617c3065de05b99241f5 Status: Downloaded newer image for roboxes/rhel7:latest bash: /sbin/consoletype: No such file or directory [root@9337841b8ffd ~]# cat /sys/kernel/mm/transparent_hugepage/enabled always [madvise] never [root@9337841b8ffd ~]# exit exit ➜ ~ docker run -ti roboxes/rhel8 bash Unable to find image 'roboxes/rhel8:latest' locally latest: Pulling from roboxes/rhel8 57040e96b1fd: Pull complete Digest: sha256:855975aecdf9673542d7af8e896707c049dfde9c70419a5b098123ca760bfa08 Status: Downloaded newer image for roboxes/rhel8:latest [root@d4c5c4e5de2c ~]# cat /sys/kernel/mm/transparent_hugepage/enabled always [madvise] never
Attempted various older version of CentOS 7 and I can't find a single instance where this setting is a single word...
It's always like this...
Status: Downloaded newer image for centos:7.1.1503 [root@196b1c2dcf59 /]# cat /sys/kernel/mm/transparent_hugepage/enabled always [madvise] never
Yes... that is expected.
# cat /sys/kernel/mm/transparent_hugepage/enabled
always [madvise] never
# echo always > /sys/kernel/mm/transparent_hugepage/enabled
# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
I would go w/ second option but w/ an addition to the systemd unit file:
RemainAfterExit=yes
This will consider the unit running even if it's oneshot.
But still we are in a situation where someone can change the hugepages at runtime. For that we ought to setup a systemd timer.
This was originally reported by a user but I'm unable to recreate it as described, i.e. where RHEL7 just returns a single word for the thp setting. Therefore it seems sensible to proceed as @eRadical suggested... PR opened https://github.com/ansible-collections/community.mongodb/pull/526
Minor change needed for cmd due to some funny escaping going on...
cat /sys/kernel/mm/transparent_hugepage/enabled | grep -o '[never]'
Merging change.