Commit Graph

11 Commits

Author SHA1 Message Date
Kir Kolyshkin 163ec20d8a pkg/cgroups: apply De Morgan's law
This fixes the following staticcheck warning:

> pkg/cgroups/utils_linux.go:224:25: QF1001: could apply De Morgan's law (staticcheck)
> 		if parts[2] == "/" && !(unifiedMode && parts[1] == "") {
> 		                      ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-26 09:36:14 -07:00
Kir Kolyshkin d524bfaf6a pkg/cgroups: simplify write
Fix the following staticcheck warning:

> pkg/cgroups/utils_linux.go:264:18: QF1012: Use fmt.Fprintf(...) instead of WriteString(fmt.Sprintf(...)) (staticcheck)
> 				if _, err := f.WriteString(fmt.Sprintf("%d\n", pid)); err != nil {
> 				             ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-26 09:36:14 -07:00
Kir Kolyshkin 4e99731fe5 deps: switch to opencontainers/cgroups
The new opencontainers/cgroups repo used to be part of runc.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-12 15:51:55 -07:00
Giuseppe Scrivano 7bf4b98cd3 pkg/cgroups: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-10 12:23:07 +02:00
Oleksandr Redko ba4c7c98bb chore: remove outdated build constraints
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-03 22:56:00 +02:00
Paul Holzinger 8b81a2471f add new pkg/systemd to contain podman systemd cgroup code
In podman we have code to move a process into a new systemd cgroup. This
code lived in the podman utils package. Because the new rootlessnetns
must call into that move this code to c/common.

Instead of dumping this again into a "util" package create a systemd
package which should have a better name. Also move the cgroup code
directly into pkg/cgroup. I am sure we can do some cleanup there in a
followup to prevent duplication.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-12-05 15:28:19 +01:00
Daniel J Walsh cf924569ce UserConnection is used by non linux platforms
Take this oppurtunity to remove Get prefix on functions in cgroups.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-31 09:16:26 -04:00
Valentin Rothberg 14bddff8d5 linters: enable mirror
Useful micro optimizations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:20:53 +02:00
Valentin Rothberg 1fa8b65281 linters: enable forbidigo
Selectively disable cases that I cannot touch or don't bother spending
time on.  Future cases will be avoided.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:08:17 +02:00
Sascha Grunert 426d69c00f Switch to golang native error wrapping
`github.com/pkg/errors` is deprecated since quite some time so we now
use the native error wrapping for more idiomatic golang.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-12 10:54:07 +02:00
cdoern 7f76a6b52d use runc cgroup creation logic
switch c/common to use runc cgroup creation so that we can use resource limits

This entails importing the newly refactored runc code to manage reading from and writing to cgroup.
vendoring in directly an unreleased runc commit from opencontainers/runc#3452

Signed-off-by: cdoern <cdoern@redhat.com>
2022-06-07 22:17:40 -04:00