Commit Graph

16 Commits

Author SHA1 Message Date
Paul Holzinger d240865a45 lint: update golangci-lint to v1.56.2
Adds a couple of new linters with many new warnings:
- perfsprint (fixed in code, excluded for tests)
- revive (fix the problems, disabled the dot import check as we use it
  for ginkgo)
- inamedparam (disabled because it is opinionated)
- testifylint (great linter but we have like 1000+ issues that I have no
  time fixing now)

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-03-05 18:10:32 +01:00
Daniel J Walsh fdca9eb5eb Cleanup pkg/cgroups for compilation on freebsd
freebsd and other non linux systems do not support
dbus.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-03-01 05:34:28 -05:00
Oleksandr Redko 0e202b45a1 Refactor map init with short declaration syntax
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-06 19:28:43 +02:00
Oleksandr Redko 4dbd58b735 Refactor: replace raw loops with funcs from slices and maps
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 00:11:15 +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
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
Daniel J Walsh c0bc17fe8f Add back SystemCPUUsage
This function was accidently removed and is needed by podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-27 14:12:00 -04:00
Giuseppe Scrivano 7a928bbcc3 cgroups: remove unused files
they are a dup of the _linux.go version.  Move the linux-only
functions to the _linux.go file.

[NO NEW TESTS NEEDED]

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-27 14:46:37 +02:00
Giuseppe Scrivano 7fc3bc1a89 cgroups: rename function to readCgroupMapPath
the same format is used on cgroup v1, so no need to specify the
version in the function name.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-11 13:12:50 +02:00
Valentin Rothberg 8e842b2ec9 linters: enable unconvert
Useful micro optimizations.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-01 11:23:18 +02:00
Joni Korhonen 6ea33b815f cgroups_linux: use SessionBusPrivateNoAutoStartup
port Commit 10d63bf089 (cgroups: use SessionBusPrivateNoAutoStartup)
from cgroups.go to cgroups_linux.go

do not start up a dbus daemon if it is not already running.

[NO NEW TESTS NEEDED] the fix is in a dependency.

Signed-off-by: Joni Korhonen <joni.korhonen@gmail.com>
2023-08-15 12:20:06 +03:00
Valentin Rothberg e17483b871 bump to golangci-lint v1.50.0
Used `go fmt` rules to migrate away from deprecated functions, for
instance `gofmt -w -s -r 'ioutil.TempDir(a, b) -> os.MkdirTemp(a, b)'`

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-17 15:03:07 +02:00
Daniel J Walsh a5698c8b06 Fix stutters
Podman adds an Error: to every error message. So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-27 08:05:03 -04: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 7253aaf99f improve NewSystemd's capability for setting resources
in the first PR for improving cgroup creation, systemd was not included. This change is as simple as including a resource parameter in the `NewSystemd` function and leaving the creation
in podman to do the rest. Also, a new function has been added to convert spec.Linux limits into systemd properties

Signed-off-by: Charlie Doern <cdoern@redhat.com>
2022-06-17 14:16:48 -04: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