30 Commits

Author SHA1 Message Date
a9852aa8ff utils: Enable cgroup utils for FreeBSD
This probably makes sense when using podman-remote and it lets the unit
tests pass which makes 'make localunit' happy.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-11-14 14:22:36 +00:00
d968f3fe09 Replace deprecated ioutil
Package `io/ioutil` was deprecated in golang 1.16, preventing podman from
building under Fedora 37.  Fortunately, functionality identical
replacements are provided by the packages `io` and `os`.  Replace all
usage of all `io/ioutil` symbols with appropriate substitutions
according to the golang docs.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-09-20 15:34:27 -04:00
49cb288df3 hack/test/utils: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

[NO NEW TESTS NEEDED]

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-05 12:13:33 +02:00
5c39797624 utils: move the cgroup if root on cgroupv2
if we are running on cgroupv2, force the creation of a sub-cgroup even
when we are at the root for the cgroup v2 unified mount.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-06-30 14:34:18 +02:00
94e82121bf Support running podman under a root v2 cgroup
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-05-21 09:28:52 -05:00
2a8e435671 enable staticcheck linter
Fix many problems reported by the staticcheck linter, including many
real bugs!

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-04-22 12:51:29 +02:00
ea08765f40 go fmt: use go 1.18 conditional-build syntax
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-18 09:11:53 +01:00
bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00
0999245e40 utils: reintroduce moveToCgroup
commit ee62711136339c5daf38e38859227d85b06fc32a introduced the
regression.

It was mistakenly removed as part of a cleanup, but this code is
needed by another code path, where we move conmon for the exec session
to the same cgroup used by conmon for the process.

Closes: https://github.com/containers/podman/issues/12535

[NO NEW TESTS NEEDED] it fixes a regression in the CI

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-12-08 09:31:31 +01:00
2130d18539 Update vendor or containers/common moving pkg/cgroups there
[NO NEW TESTS NEEDED] This is just moving pkg/cgroups out so
existing tests should be fine.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-12-07 06:17:11 -05:00
ee62711136 utils: use podman-pause-$RANDOM.scope name
we try hard to re-use the existing podman-pause.scope name when it
already exists, causing any sort of race errors when the already
existing scope is terminating.

There is no such a requirement though, so just try with a random
name.

Closes: https://github.com/containers/podman/issues/12065

[NO NEW TESTS NEEDED] it fixes a race in the CI

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-11-17 10:13:33 +01:00
eea5d25126 utils: return error message from StartTransientUnit
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-20 09:42:35 +02:00
02e59c6683 utils.RunUnderSystemdScope(): always close Conn
Make sure we close our private connection to the bus, even if we're not
successful in in using it to ask systemd to move a unit's processes to a
specific control group.

[NO TESTS NEEDED]

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-08-23 17:23:17 -04:00
969cc3237b utils: move message from warning to debug
if a pid could not be moved to a new cgroup, print a debug message
instead of a warning.

Closes: https://github.com/containers/podman/issues/10674

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-06-16 08:49:57 +02:00
5174797316 utils: improve error message
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-06-16 08:49:56 +02:00
5dded6fae7 bump go module to v3
We missed bumping the go module, so let's do it now :)

* Automated go code with github.com/sirkon/go-imports-rename
* Manually via `vgrep podman/v2` the rest

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 09:03:51 +01:00
660a06f2f7 utils: takes the longest path on cgroup v1
now getCgroupProcess takes the longest path on cgroup v1, instead of
complaining if the paths are different.

This should help when --cgroups=split is used on cgroup v1 and the
process cgroups look like:

$ cat /proc/self/cgroup
11:pids:/user.slice/user-0.slice/session-4.scope
10:blkio:/
9:cpuset:/
8:devices:/user.slice
7:freezer:/
6:memory:/user.slice/user-0.slice/session-4.scope
5:net_cls,net_prio:/
4:hugetlb:/
3:cpu,cpuacct:/
2:perf_event:/

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-11 16:46:42 +01:00
1b5f3ed24d utils: create parent cgroups
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-11 09:38:36 +01:00
9196a5ce36 utils: ignore unified on cgroupv1 if not present
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-11 09:38:35 +01:00
f4fd25a005 utils: skip empty lines
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-02-11 09:38:34 +01:00
95b4478fb4 Fix some nit
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-12-04 09:20:42 +08:00
9a33e064a1 podman, exec: move conmon to the correct cgroup
move the conmon process to the conmon cgroup also on exec.

The previous implementation would fail to move the conmon process as
the systemd unit already exists so its creation would fail.

When the unit cannot be created, attempt to directly join the cgroup
instead.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-12-03 10:03:39 +01:00
4878dff3e2 Remove excessive error wrapping
In case os.Open[File], os.Mkdir[All], ioutil.ReadFile and the like
fails, the error message already contains the file name and the
operation that fails, so there is no need to wrap the error with
something like "open %s failed".

While at it

 - replace a few places with os.Open, ioutil.ReadAll with
   ioutil.ReadFile.

 - replace errors.Wrapf with errors.Wrap for cases where there
   are no %-style arguments.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-10-05 15:30:37 -07:00
a5e37ad280 Switch all references to github.com/containers/libpod -> podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 08:23:45 -04:00
8489dc4345 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules.  While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
`github.com/containers/libpod/v2`.  The renaming of the imports
was done via `gomove` [1].

[1] https://github.com/KSubedi/gomove

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:50:12 +02:00
f54408bf06 utils: fix parsing of cgroup with : in the name
a cgroup can have ':' in its name.  Make sure the parser doesn't split
more than 3 fields and leave untouched the ':' in the cgroup name.

commit 6ee5f740a4ecb70636b888e78b02065ee984636c introduced the issue.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-30 15:49:33 +02:00
6ee5f740a4 podman: add new cgroup mode split
When running under systemd there is no need to create yet another
cgroup for the container.

With conmon-delegated the current cgroup will be split in two sub
cgroups:

- supervisor
- container

The supervisor cgroup will hold conmon and the podman process, while
the container cgroup is used by the OCI runtime (using the cgroupfs
backend).

Closes: https://github.com/containers/libpod/issues/6400

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-25 17:16:12 +02:00
450361fc64 update systemd & dbus dependencies
Update the outdated systemd and dbus dependencies which are now provided
as go modules.  This will further tighten our dependencies and releases
and pave the way for the upcoming auto-update feature.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-03-10 18:34:55 +01:00
b94a5e2410 utils: use the user session for systemd
when running as rootless, use the user session bus.  It is already
implemented in the pkg/cgroups so just re-use it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-09-12 08:35:26 +02:00
0b6bb6a3d3 enable podman-remote on windows
build a podman-remote binary for windows that allows users to use the
remote client on windows and interact with podman on linux system.

Signed-off-by: baude <bbaude@redhat.com>
2019-04-30 15:28:39 -05:00