cgroups: Create generic handler for v1 and v2
We have separate cgroup handler implementations for cgroups-v1 and cgroups-v2, but much of this is duplicated other than the cgroup type.
Create a new genericHandler
to unify most of the logic for cgroups-v1
and v2. This is made generic over two parameters:
- T: The cgroup type,
cgroup1.Cgroup
or*cgroup2.Manager
. - H: The hierarchy or mountpoint passed when creating a cgroup. For
cgroup1.New
this is acgroup1.Hierarchy
, forcgroup2.New
this is astring
with the path to the cgroup's mountpoint.
Four generic functions are added for the operations that are easily abstracted over. Metrics and stats collection are not included as they involve significant version-specific logic.
Edited by Will Chandler (ex-GitLab)