4428 Commits

Author SHA1 Message Date
090304a054 lint: reenable revive unused-parameter check
Signed-off-by: Matt Souza <medsouz99@gmail.com>
2025-10-01 10:42:08 -04:00
602ba415c6 libpod: Implement getOnlineCPUs() on FreeBSD
Include an explicit container state check.  Otherwise the
containers/stats endpoint will return all-zero stats for a stopped
container even when in non-streaming mode, which breaks some consumers
of the API, particularly nomad's podman driver.

Implement the interface by just returning the number of host CPUs.  A
bit more sophisticated would be to fetch the jail's cpuset, but it's not
very important for now.

Signed-off-by: Mark Johnston <mark.johnston@klarasystems.com>
2025-09-18 14:24:35 +00:00
4417e6269c use maps.Clone() over Copy() when possible
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:05 +02:00
637de6022f libpod/oci_conmon_linux.go: fix false postive in linter
staticcheck claims the var value is not used but we use it for the
mount.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:05 +02:00
78e5a521b0 inline some conditionals
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:04 +02:00
8631032556 run modernize -fix ./...
Using golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize

+ some manual cleanup in libpod/lock/shm/shm_lock_test.go as it
  generated an unused variable
+ restored one removed comment

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:04 +02:00
dc5a791f58 use bytes.SplitSeq where possible
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:04 +02:00
b97525a78d use strings.SplitSeq where possible
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:04 +02:00
2745c9e50e Merge pull request #26912 from markjdb/main
Fix several FreeBSD integration problems
2025-09-05 09:44:01 +00:00
2c6dadd724 Fix a locking bug in that could cause a double-unlock
The `cleanupExecBundle` function was only meant to be called on a
locked container, as it does some state mutation operations. It
also has a timed wait (if the directory is busy and can't be
removed yet, give it a few milliseconds) in which it deliberately
yields the lock to not block the container for that time.

The `healthCheckExec()` function calls `cleanupExecBundle` out of
a `defer` block. This is after the `defer c.lock.Unlock()` so it
fires afterwards when the function returns, so we're normally
fine - the container is still locked when our defer runs. The
problem is that `healthCheckExec()` also unlocks the container
during the expensive exec operation, and can actually fail and
return while not holding the lock - meaning our `defer` can fire
on an unlocked container, leading to a potential double unlock
in `cleanupExecBundle`.

We could, potentially, re-lock the container after the exec
occurs, but we're actually waiting for a `select` to trigger to
end the function, so that's not a good solution. Instead, just
re-lock (if necessary) in the defer, before invoking
`cleanupExecBundle()`. The `defer c.lock.Unlock()` will fire
right after and unlock after us.

Fixes #26968

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2025-09-03 10:19:37 -04:00
2acf5c0119 libpod: Fix the jailName helper
At one point, we created multiple jails per container in order to enable
network configuration from outside the container jail.  On FreeBSD 14.x
and later this is not necessary and there is only one jail per
container.  In this case, return the correct jail name.

Signed-off-by: Mark Johnston <mark.johnston@klarasystems.com>
2025-09-02 16:17:18 +00:00
a250fee0ec libpod: Fix "top" support on FreeBSD
FreeBSD's ps ignores -J if -a is specified, so "podman top" would
effectively just run ps -a, not terribly useful.  But there's no need to
specify -a when specifying a selector such as -J (or -G or -U, etc.).

Signed-off-by: Mark Johnston <mark.johnston@klarasystems.com>
2025-09-02 16:17:18 +00:00
9d7a24e654 Merge pull request #26945 from Luap99/vol-opts
do not pass volume options as bind mounts options to runtime
2025-09-02 14:18:15 +00:00
46d757501a do not pass [no]copy as bind mounts options to runtime
Starting with runc 1.3.0 it errors when we pass unknown mount options to
the runtime, the copy/nocopy options are specific to podman when we
mount the volume and are not valid mount options for the runtime.

Fixes: #26938

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-01 12:48:43 +02:00
4e2a04dedc do not pass volume-opt as bind mounts options to runtime
Starting with runc 1.3.0 it errors when we pass unknown mount options to
the runtime, the volume-opt options are specifc to the volume we create
and should not be passed to the mount in the oci spec.

Fixes: #26938

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-01 12:48:43 +02:00
a98154a978 Switch common, storage and image to monorepo.
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-09-01 12:33:04 +02:00
cb59650a16 Merge pull request #26891 from winterqt/push-ozksmwkumrrs
fix(libpod): truncate long hostnames to correct maximum length
2025-08-28 12:55:27 +00:00
9c3652c188 Add support for criu's tcp-close functionality.
Fixes: #26676
Signed-off-by: Jeff Mercer <jeff.mercer@gmail.com>
2025-08-27 18:52:34 -04:00
2dd3111098 fix(libpod): truncate long hostnames to correct maximum length
Since #24675, we've been truncating hostnames derived from the container name
to 253 characters. However, if a user were to create a container with a long
name and not set a hostname, this would still fail.

Seemingly, the maximum length for hostnames is (and always(?) has been) 64, as
made evident by these headers from various kernel versions:

- https://elixir.bootlin.com/linux/v6.16/source/include/uapi/linux/utsname.h#L15
- https://elixir.bootlin.com/linux/v4.20/source/include/uapi/linux/utsname.h#L15
- https://elixir.bootlin.com/linux/v3.19.8/source/include/uapi/linux/utsname.h#L14

I've confirmed this issue (and fix) on Linux 6.1, but happy to do so on a more
recent kernel as well.

Signed-off-by: Winter M <winter@antithesis.com>
2025-08-22 17:52:00 -04:00
514e686b4c podman events: show network create/remove event with journald
In the journald driver there is a bug where the network event
attributes are not preserved. This causes the network driver to be
missing and that in turn causes the ToHumanReadable() function to print
an empty line. Fix it by making sure we preserve the network driver in
the event attributes.

Fixes: https://issues.redhat.com/browse/RHEL-109790

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-08-19 18:37:37 +02:00
55996138fa Merge pull request #26788 from mheon/deprecate_boltdb_notice
Add BoltDB deprecation notice
2025-08-11 19:43:58 +00:00
9a2dccf4f4 Add a deprecation notice for users of BoltDB
Right now, only log-level=info, so not shown by default. We can
continue to up this in subsequent releases to convince folks of
the urgency of switching.

Resolves https://issues.redhat.com/browse/RUN-3343

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-08-08 09:02:02 -04:00
930cd25739 Feat: Add log_path support in containers.conf
Added log_path variable in containers/common, User sets default log path in containers.conf under the `[containers]` section.
The directory has to exist beforehand. Container logs go under this directory, sub-directories named with the container id
and inside the sub-directory a ctr.log file will be created where the container logs for the corresponding container will go.
This path can be overridden by using the `--log-opt` flag.

Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
2025-08-07 17:04:13 -04:00
0666b4ffbf events: add support for label filter with key only
Fixes: #26702

Signed-off-by: TusharMohapatra07 <tusharmohapatra.gig@gmail.com>
2025-07-31 15:12:17 +05:30
c1cf4b0d89 podman rm: handle case where conmon was killed
When conmon was killed podman rm -f currently fails but running it again
then works which doesn't really makes sense. We should properly remove
the contianer even if conmon is dead.

In fact the code already handles ErrConmonDead as stop error when we
remove the container but this error was never thrown anywhere. To fix
this throw ErrConmonDead instead of ErrInternal because that is not an
intenral error if something else killed conmon.

With this we can correctly cleanup and remove the container. The fact
that this works on the first try is important for quadlet units as they
only run the ExecStopPost= command once to remove it.

Fixes: #26640

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-07-15 17:15:19 +02:00
13816eb86f Fix podman inspect to correctly handle log_size_max
When generating Conmon's command line, we read containers.conf to
get log_size_max and used it if the container didn't override it.
However, `podman inspect` only reads from the container's own
config, and ignores containers.conf. Unify the way we determine
maximum log size with a single function and use it for both
inspect and containers.conf, and add a test for this behavior.

Fixes https://issues.redhat.com/browse/RHEL-96776

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-07-03 16:04:48 -04:00
247c1dfb53 libpod: remove deadcode
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-26 19:37:16 +02:00
683e9b2c94 Merge pull request #26434 from mheon/import_export
Add remote support for `podman volume import` and `podman volume export`
2025-06-25 19:48:14 +00:00
98876454cb Refactor volume import to support the remote client
As with `volume export`, this was coded up exclusively in cmd/
instead of in libpod. Move it into Libpod, add a REST endpoint,
add bindings, and now everything talks using the ContainerEngine
wiring.

Also similar to `volume export` this also makes things work much
better with volumes that require mounting - we can now guarantee
they're actually mounted, instead of just hoping.

Includes some refactoring of `volume export` as well, to simplify
its implementation and ensure both Import and Export work with
readers/writers, as opposed to just files.

Fixes #26409

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-06-23 13:42:22 -04:00
63bf454d66 Refactor podman export to work with the remote client
Previously, our approach was to inspect the volume, grab its
mountpoint, and tar that up, all in the CLI code. There's no
reason why that has to be in the CLI - if we move it into
Libpod, and add a REST endpoint to stream the tar, we can
enable it for the remote client as well.

As a bonus, previously, we could not properly handle volumes that
needed to be mounted. Now, we can mount the volume if necessary,
and as such export works with more types of volumes, including
volume drivers.

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-06-14 07:42:38 -04:00
0ab8a3c576 artifact mount: add new name option to specify filename
An artifact without the title annoation just gets the digest as name
which is less than ideal. While it is a decent default to avoid
conflicts users would like to configure the name.

With the name=abc option we will call the file abc in case of a signle
artifact and otherwise we use abc-x where x is the layer index starting
at 0 to avoid conflicts.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-14 12:25:21 +02:00
21f34601eb artifact mount: improve single blob behavior
If the artifact has a single blob then use the dst path directly as
mount in case it does not exist.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-14 09:16:06 +02:00
1e53cacb08 Merge pull request #26232 from 2004joshua/buildxInspect
podman buildx inspect
2025-06-12 08:02:31 +00:00
1141ae4a87 libpod: log file doesn't need to be executable
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-06-11 13:22:14 +02:00
9922bddb1f libpod: do not dereference nil pointer
on errors the event pointer is nil.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-06-11 13:22:14 +02:00
54afcdf6b3 libpod: fix file descriptor leak
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-06-11 13:22:03 +02:00
17e9ada37d Merge pull request #26272 from sonnysasaka/check-quicker
Skip layer digests for podman system check --quick
2025-06-05 18:47:01 +00:00
971321228c Skip layer digests for podman system check --quick
podman system check --quick currently only skips layer contents, but
practically it's not much quicker than without the flag.

This changes the flag to also skip checking layer digests which speed up
the check significantly.

In some cases, it is useful to opt for a quicker check if we prioritize
detecting and fixing severe corruption and can tolerate minor damage.

The check option is derived from CRI-O's internal repair:
9e4d86d823/internal/lib/container_server.go (L860)

Signed-off-by: Sonny Sasaka <sonnysasaka@gmail.com>
2025-06-05 17:00:50 +00:00
87450b8f8b podman buildx inspect support
Added support for "podman buildx inspect". The goal was to replicate the default output from "docker buildx inspect" as
much as possible but a problem encountered was podman not supporting BuildKit. To replicate the output I resorted to
printing the statements with default values but only changed the driver name to use podman instead of docker. Since
there was no buildkit, gave it the value of "N/A" to depict it's not supported. For Platforms, I resorted to using
the emulated architectures found on your linux system + the host architecture of your local machine or podman server. The
bootstrap flag was also added but is considered a NOP since there is no buildkit container to run before running inspect.
An extra field was added to the HostInfo struct so when you run "podman info" the emulated architectures will show, this
was used so you can grab the information from the podman engine.

Fixes #13014

Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
2025-06-03 11:07:08 -04:00
75dc508e98 libpod: don't force only network search domains
We like to append the host servers in that case so that we do not only
force dns.podman.

Fixes: #24713
Fixes: https://issues.redhat.com/browse/RHEL-83787

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-02 18:45:11 +02:00
5e4adb661c Merge pull request #26174 from fpoirotte/kube_cpuset_cgroup
Support --cpuset-cpus and --cpuset-mems in podman kube play
2025-05-30 14:37:57 +00:00
dad0b294d4 Merge pull request #26217 from mheon/fix_26168
Fix SQLite volume lookup queries matching too liberally
2025-05-28 18:42:06 +00:00
b276e7ef21 Fix SQLite volume lookup queries matching too liberally
Specifically, this does two things:

1. Turn on case-sensitive LIKE queries. Technically, this is not
specific to volumes, as it will also affect container and pod
lookups - but there, it only affects IDs. So `podman rm abc123`
will not be the same as `podman rm ABC123` but I don't think
anyone was manually entering uppercase SHA256 hash IDs so it
shouldn't matter.

2. Escape the _ and % characters in volume lookup queries. These
are SQLite wildcards, and meant that `podman volume rm test_1`
would also match `podman volume rm testa2` (or any character in
place of the underscore). This isn't done with pod and container
lookups, but again those just use LIKE for IDs - so technically
`podman volume rm abc_123` probably works and removes containers
with an ID matching that pattern... I don't think that matters
though.

Fixes #26168

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2025-05-28 13:10:10 -04:00
a484f78c44 Merge pull request #26209 from jankaluza/26190
Recreate the Rootfs in mountStorage for infra-container.
2025-05-28 14:35:04 +00:00
e0b08fcfa3 Recreate the Rootfs in mountStorage for infra-container.
After the system reboot, the Rootfs for infra-container can
be removed. This can happen when it is stored on tmpfs.

This commit recreates the infra-container directory which is
used for Rootfs for infra-container before mounting it.

Fixes: #26190

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-05-27 16:31:44 +02:00
051be9b2d2 libpod: Don't exclude running deps from the container graph inputs
getAllDependencies() skips recursing into dependencies that are already
running, but BuildContainerGraph() expects a *complete* set of inputs
and returns an error if any are missing. Thus, podman will fail to start
a container with already-running direct dependencies that, in turn, have
their own dependencies.

None of the other callers of BuildContainerGraph() omit anything from
their list of containers, so follow the same approach here, and just
let startNode figure out if a start is actually needed.

Fixes: containers/podman-compose#921

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
2025-05-26 20:29:53 -05:00
5bfdb25b26 Support --cpuset-<cpus/mems> in podman kube play
This commit adds two new annotations named
io.podman.annotations.cpuset/$ctrname and
io.podman.annotations.memory-nodes/$ctrname

The first one allows restricting a container's execution to specific
CPU cores while the second restricts memory allocations to specific
NUMA memory nodes. They are also added automatically when the
--cpuset-cpus and --cpuset-mems options are used.

Fixes: containers#26172

Signed-off-by: François Poirotte <clicky@erebot.net>
2025-05-22 11:45:01 +02:00
953e385bd2 libpod: fix mount order for "/" volume
The count function for / and /proc results in the same value so the
order is not guaranteed. We must ensure that a / mount is always first
in the spec so that other mounts are not overshadowed by it.

Fixes: #26161

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-20 15:52:27 +02:00
637c264e2e fix issues found by nilness
The conditions are always true so they can be removed. And in the case
of exportCheckpoint() the scope means addToTarFiles was overwritten and
thus when it looped over it later the slice was always empty.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-13 17:20:10 +02:00
077649f9d0 Fix: Use SIGKILL instead of SIGTERM when ExecStopContainer timeout is 0
Aligns behavior with documentation stating SIGKILL should be sent immediately if the timeout is zero.

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-05-12 17:01:42 +02:00