troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
633 stars 63 forks source link

Support kernel without cgroups #188

Closed hongkongkiwi closed 2 years ago

hongkongkiwi commented 3 years ago

I don't have cgroups support in my kernel, when trying to start a service (this case chrony) I get these errors in the logs:

Aug 10 18:00:28 finit[1]: Starting chronyd[1256]
Aug 10 18:00:31 finit[1]: Service chronyd[1256] died, restarting (10/10)
Aug 10 18:00:31 finit[1]: group_init():Failed creating cgroup /sys/fs/cgroup/system/chronyd: No such file or directory
Aug 10 18:00:31 finit[1]: cgroup_leaf_init():Failed moving pid 1269 to group /sys/fs/cgroup/system/chronyd: No such file or directory

Could you add a ./configure option to disable cgroup support?

troglobit commented 3 years ago

Thanks for the report, I'll consider it.

hongkongkiwi commented 3 years ago

In my minimal kernel this just wasn't enabled (I'm running on a minimal embedded device), I had to do a bit of research to figure out why I was getting the error. Even though I wasn't using cgroup support in the finit config file.

I fixed the errors by adding these to my kernel config:

CONFIG_CGROUPS=y
CONFIG_CGROUP_SCHED=y
hongkongkiwi commented 3 years ago

Ah, I really found this is causing lots of issues.

I don't have cgroup v2, because I'm running an older kernel. So, there was an error when setting up the init, system & user cgroups because I don't have cpu.weight groups.

finit thought this was an error, and killed my service. To fix this, I've removed them from the cgroup.c file so it looks like this:

    /* Default (protected) groups, PID 1, services, and user/login processes */
       cgroup_add("init",   "",  1);
       cgroup_add("system", "", 1);
       cgroup_add("user",   "",  1);
    cgroup_config();

Now it seems that most services can start ok... atleast syslogd is working now (yay).

The next challenge I have is that finit <pid/SERVICE> conditions now do not fire. Perhaps this is related to some cgroup functions not being present?

troglobit commented 3 years ago

I've conferred with colleagues now, we will likely not add support disabling cgroups. The effort of supporting that use-case is not worth it to us since it's not in line with ours, or the project's, goals. There are older versions of Finit available that don't require cgroups.

hongkongkiwi commented 2 years ago

That's a shame, because as with many embedded devices, we are limited in the kernel version supported by our MCU vendor (4.9.14 in our case) and they are slow to update (or simply don't plan to), and so we don't have full cgroups v2 support.

If the goal is to support embedded systems, then not all of these will have kernel 5+.

This limits us to not being able to use finit, which is a shame as it's exactly the startup system I'm looking for. Much easier to use than s6-rc.

troglobit commented 2 years ago

OK, flattery¹ will get you far with me :-)

Also, that's a good point you're making. I've recently run into a terrible vendor kernel myself, and I'm also changing jobs soon, so I'm reopening this and having a final look at it before the big v4.2 release I was just about to drop. Thanks for checking back! __
¹ Re: s6

troglobit commented 2 years ago

There, fixed. Finit v4.2 should work much better.

hongkongkiwi commented 2 years ago

Thank you so much, I’ll give this a try! -- Sent from Gmail Mobile