cneira / jail-task-driver

nomad task driver that uses FreeBSD jails
BSD 3-Clause "New" or "Revised" License
36 stars 2 forks source link

jail resource allocation report #16

Open cneira opened 4 years ago

cneira commented 4 years ago

Currently running top inside a jail, it will report the host total memory instead of the memory allowed for the jail to use. nomads need to know how much memory is currently the container using to be able to calculate to which node the allocation will be send. This is not a problem on illumos as a zone has it own memory counter to keep track of this.

Crest commented 1 year ago

FreeBSD does have rctl(8) (it has to be enabled by setting the kern.racct.enable loader tunable to 1 from /boot/loader.conf). The mechanism to apply resource limits to jails is compiled into the default FreeBSD kernel configuration. What's missing is the of glue logic to update the resource limit database through the task driver.

cneira commented 1 year ago

FreeBSD does have rctl(8) (it has to be enabled by setting the kern.racct.enable loader tunable to 1 from /boot/loader.conf). The mechanism to apply resource limits to jails is compiled into the default FreeBSD kernel configuration. What's missing is the of glue logic to update the resource limit database through the task driver.

The problem is not resource limits, resource limits do work. To notice the problem just create jail cap memory to 1GB, then login inside the jail and execute top, there you will see the whole host memory amount instead of the 1GB that the jail was provisioned with, work must be done in the kernel to add vmmeter per jail, I started a while ago to do it but have not the motivation to go further to completion here is what I had at the moment :

https://gitlab.com/cneira1/freebsd/-/commit/cae3ff52b58c932effcd91e82c644e16d9ded604