singularity
singularity copied to clipboard
Always start instance in cgroup, when possible.
Is your feature request related to a problem? Please describe.
A user must manually specify a cgroup on instance startup in order to make use of the new instance stats functionality.
Describe the solution you'd like
If cgroups are available on the system, an instance should always be started in a cgroup (without restrictions) so that instance stats can be monitored.
Additional context
cgroups options on the command line are currently handled in cmd/internal/cli/actions_linux.go in the execStarter function. There, a provided CgroupsTOMLFile is being parsed, and passed to the engine via engineConfig.SetCgroupsJSON.
In execStarter, we are handling an instance if the value of name is not "".
An example of how to check for cgroups support is in the internal/pkg/test/tool/require/require.go Cgroups function.
We need to set engineConfig.SetCgroupsJSON to an empty, but valid, cgroups config if:
- We are starting an instance
- A specific CgroupsTOMLFile has not been provided.
- Cgroups are available.
Because execStarter is growing very long, it would be best to refactor the cgroups handling code into a separate function, called from execStarter, for clarity and ease of maintenance.