Commit Graph

4435 Commits

Author SHA1 Message Date
Matt Heon
f5bc2abe4c Remove BoltDB state support
This also includes a number of significant changes to the SQLite
state made possible by removal of the legacy DB.

1. Enable database unit tests for SQLite state, with numerous
   tweaks to get tests passing. Most notable changes are to
   container removal - where we previously didn't return an error
   if there was no container to remove - and RemovePodContainers,
   which I don't think ever worked properly from my reading of
   the failures.
2. Removal of AddContainerToPod/RemoveContainerToPod. On SQLite,
   these functions are identical to AddContainer/RemoveContainer
   and there is no reason to retain duplicates.
3. Removal of SafeRewriteContainerConfig - it's identical to
   RewriteContainerConfig in SQLite, no reason to have duplicate
   entrypoints.

As an exciting side-note, this removes Podman's requirement that
containers and pods cannot share a name, which was a BoltDB
restriction only.

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2025-10-28 12:09:04 -04:00
Matt Heon
34166fc004 Bump Go version to v6
Tremendous amount of changes in here, but all should amount to
the same thing: changing Go import paths from v5 to v6.

Also bumped go.mod to github.com/containers/podman/v6 and updated
version to v6.0.0-dev.

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-10-23 11:00:15 -04:00
Matt Heon
9ea18b78fa Warn on boltdb use
We started logging this in 5.6. In 5.7, we up to a warning. The
upcoming 5.8 will up the warnings further to errors.

Required as we're removing BoltDB support in 6.0 next Spring.

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2025-10-22 09:24:43 -04:00
openshift-merge-bot[bot]
1a8eb18b2b Merge pull request #27310 from mheon/default-runtime-flags
Add support for runtime flags in containers.conf
2025-10-20 10:57:46 +00:00
Lokesh Mandvekar
74788a3fe1 fileperms: newer Go 1.13+ octal literal format
Problem: While removing cgroupsv1 code, I noticed my neovim Go config
automatically changed fileperms to the new octal format and I didn't
want that polluting my diffs.

Decision: I thought it best to switch to the new octal format in a dedicated PR.

Action:
- Cursor switched to new octal format for all fileperm ocurrences in Go
 source and test files.
- vendor/, docs/ and non-Go files were ignored.
- Reviewed manually.

Ref: https://go.dev/ref/spec#Go_1.13

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2025-10-16 14:11:29 -04:00
Rosvaldas Atstupėnas
0a20e22384 Add default runtime flags in config
Added a way to define default runtime flags in config.

Fixes: https://github.com/containers/common/issues/715

Default runtime flags should be defined as shown below:

[engine.runtimes_flags]
runsc = [
  "net-raw",
]

crun = [
  "debug",
]

Signed-off-by: Rosvaldas Atstupėnas <atstupenas.rosvaldas@gmail.com>
2025-10-16 13:51:46 -04:00
Brent Baude
cfd4cc0932 remove libartifact from podman
pkg/libartifact has been moved to common and as such needs to be removed
from podman and the new common vendored in along with required deps.

https://issues.redhat.com/browse/RUN-3618

Signed-off-by: Brent Baude <bbaude@redhat.com>
2025-10-16 09:55:59 -05:00
Matt Souza
090304a054 lint: reenable revive unused-parameter check
Signed-off-by: Matt Souza <medsouz99@gmail.com>
2025-10-01 10:42:08 -04:00
Mark Johnston
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
Paul Holzinger
4417e6269c use maps.Clone() over Copy() when possible
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:05 +02:00
Paul Holzinger
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
Paul Holzinger
78e5a521b0 inline some conditionals
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:04 +02:00
Paul Holzinger
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
Paul Holzinger
dc5a791f58 use bytes.SplitSeq where possible
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:04 +02:00
Paul Holzinger
b97525a78d use strings.SplitSeq where possible
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-10 16:17:04 +02:00
openshift-merge-bot[bot]
2745c9e50e Merge pull request #26912 from markjdb/main
Fix several FreeBSD integration problems
2025-09-05 09:44:01 +00:00
Matthew Heon
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
Mark Johnston
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
Mark Johnston
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
openshift-merge-bot[bot]
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
Paul Holzinger
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
Paul Holzinger
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
Jan Kaluza
a98154a978 Switch common, storage and image to monorepo.
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-09-01 12:33:04 +02:00
openshift-merge-bot[bot]
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
Jeff Mercer
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
Winter M
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
Paul Holzinger
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
openshift-merge-bot[bot]
55996138fa Merge pull request #26788 from mheon/deprecate_boltdb_notice
Add BoltDB deprecation notice
2025-08-11 19:43:58 +00:00
Matt Heon
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
Joshua Arrevillaga
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
TusharMohapatra07
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
Paul Holzinger
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
Matt Heon
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
Paul Holzinger
247c1dfb53 libpod: remove deadcode
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-26 19:37:16 +02:00
openshift-merge-bot[bot]
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
Matt Heon
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
Matt Heon
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
Paul Holzinger
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
Paul Holzinger
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
openshift-merge-bot[bot]
1e53cacb08 Merge pull request #26232 from 2004joshua/buildxInspect
podman buildx inspect
2025-06-12 08:02:31 +00:00
Giuseppe Scrivano
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
Giuseppe Scrivano
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
Giuseppe Scrivano
54afcdf6b3 libpod: fix file descriptor leak
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-06-11 13:22:03 +02:00
openshift-merge-bot[bot]
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
Sonny Sasaka
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
Joshua Arrevillaga
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
Paul Holzinger
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
openshift-merge-bot[bot]
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
openshift-merge-bot[bot]
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
Matthew Heon
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