Commit Graph

4621 Commits

Author SHA1 Message Date
Marek Simek
e353bab7f5 fix: Handle healthcheck log corruption gracefully
The healthcheck log could be corrupted if the
process was interrupted mid-write. It could
lead to Podman crashing.

Write the log files atomically and diferentiate
between corrupted log and different errors in
consumers of readFromFileHealthCheckLog().
Add a system test for a corrupted log file.
Change incorrect log permissions to 0o600.

Fixes: https://redhat.atlassian.net/browse/RHEL-178222
Signed-off-by: Marek Simek <msimek@redhat.com>
2026-06-29 13:03:47 +02:00
Jan Rodák
60e90c14ec Merge pull request #28664 from givensuman/fix/generate-kube-healthcheck
Export container healthcheck as LivenessProbe in generate kube
2026-06-25 17:32:57 +02:00
Danish Prakash
de3341fd81 Merge pull request #28977 from jiwahn/fix-kube-oci-annotation-roundtrip
kube: alias OCI runtime annotations without underscores
2026-06-24 20:29:15 +05:30
Matt Heon
cbdb3126e9 Merge pull request #29016 from Luap99/exec-cleanup
fix cleanupExecBundle locking and some more exec releated cleanups
2026-06-24 09:46:40 -04:00
Mikhail Dmitrichenko
b8cc54238b libpod: close checkpoint export tar stream
chrootarchive.Tar returns an io.ReadCloser backed by the tar-producing
process.  The checkpoint export path copies from that stream into the
target file, but never closes the reader.

A successful copy reads the stream to EOF, so the producer normally exits.
On early errors, such as failing to create or chmod the target file, or a
copy error, the producer can be left without a consumer.

Close the tar stream after creating it so error paths release the pipe and
allow the producer to exit.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko00@bk.ru>
2026-06-24 13:30:13 +03:00
Devesh B
07289d6cd3 fix(kube): export container healthcheck as LivenessProbe in generate kube
Fixes: #22095

Now handles exporting a container's healthcheck configuration as a
`livenessProbe` in the generated Kubernetes YAML.

Co-authored-by: givensuman <givensuman@duck.com>
Co-authored-by: Jan Rodák <hony.com@seznam.cz>

Signed-off-by: Devesh B <98201065+DeveshB-1@users.noreply.github.com>
Signed-off-by: givensuman <givensuman@duck.com>

Update test/e2e/generate_kube_test.go

Co-authored-by: Jan Rodák <hony.com@seznam.cz>
Signed-off-by: given <givensuman@gmail.com>
2026-06-23 17:10:27 -04:00
Paul Holzinger
d9bab9caac libpod: correctly guard StartedTime access in runHealthCheck
The state must be synced from the db when we are locked otherwise it
contains incorrect values.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-23 18:59:30 +02:00
Paul Holzinger
cd6807c7c0 libpod: remove LegacyExecSessions
This have been deprecated in podman 1.9, it is safe to assume they are
no longer used by anyone one a recent version.

If someone would update from the old version to 6+ they would run into
much more issues already so this can be safely dropped IMO.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-23 18:47:08 +02:00
Paul Holzinger
ae04ee07b1 libpod: remove extra state lookup in HealthCheck()
Checking the state outside of locks is not safe and does not guarantee
us anything as the container could be stopped afterwards anyways.

So just skip the state check and then later in the exec logic we do the
same check again and return ErrCtrStateInvalid so just handle that
afterwards.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-23 18:47:07 +02:00
Paul Holzinger
f7b85f85a8 libpod: remove unused ExecStop
The function is never called so remove it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-23 18:10:32 +02:00
Paul Holzinger
8fa167ad93 libpod: remove locking rule from cleanupExecBundle
This is used incorrectly by execLightweight which called the function
unlocked which of course does not show up normally as only when there
is a race condition that makes the removal fail we go to unlock and then
the process panics as a double unlocked is not allowed.

While we could fix the caller such incorrect use is way to easy and
the unexpected lock/unlock cycle is basically never expected. Instead
just keep the container locked, that may prevent other commands from
doing something with the container in parallel but the error should be
rare enough to not matter most of the time. And we wait 5s max so it is
not a long time either.

To try to make the wait interval a bit faster poll every 50ms now as we
no longer have to the expensive locking and db sync each iteration.

Fixes: #29012

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-06-23 18:10:31 +02:00
Radostin Stoyanov
2c7aeab70b Freeze cgroup during live checkpoint
When checkpointing a container with --leave-running, libpod dumps the
container's memory via the OCI runtime (CRIU) first and only captures
the rootfs diff and named volumes afterwards. CRIU thaws the container
as soon as the memory dump finishes, so the processes inside the
container continue to run between the memory snapshot and the
file-system capture. As a result, the checkpoint can be inconsistent:
have CRIU images and a file system that reflect different points in time.

To fix this, we freeze the container's cgroup before invoking the OCI
runtime and thaw it again only after the checkpoint image/archive has
been written. The OCI runtime calls CRIU with the freezer cgroup and
restores it to its previous state once the dump completes, so a
container that was already frozen stays frozen across the dump and
the file system is captured at the same instant as the CRIU images.
This mirrors the approach other engines (e.g. CRI-O and containerd).

The default (stopping) checkpoint functionality is not affected by this
issue because CRIU leaves the tasks dead after the dump.

This patch also adds a regression test for the consistency of live
(--leave-running) checkpoints. The container runs a workload that
keeps an in-memory counter in sync with a value written to a file
on its root file system, maintaining the invariant that the on-disk
value never gets ahead of the in-memory counter.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2026-06-23 13:30:32 +01:00
Jiwoo Ahn
fb8a272fe3 kube: alias OCI runtime annotations without underscores
Fixes: #26871
Signed-off-by: Jiwoo Ahn <ikwydls1314@gmail.com>
2026-06-23 19:24:53 +09:00
Paul Holzinger
eb3c0f4c1a Merge pull request #28957 from shuaiyuanxx/exec-honor-console-size
exec: honor ConsoleSize so the terminal is sized at creation
2026-06-22 16:30:13 +02:00
Shuai Yuan
f5efef5043 exec: honor ConsoleSize so the terminal is sized at creation
The exec API accepts a ConsoleSize but it is dropped: the exec
pseudo-terminal is created at its default size and only corrected
afterwards by an asynchronous resize. A short-lived exec that reads its
window size at startup (e.g. `stty size`) can therefore observe the wrong
size, because the resize may arrive after the process has already read it.
docker applies the size at creation.

Carry the requested ConsoleSize through ExecConfig and into the exec OCI
process spec (process.consoleSize) so the runtime sizes the terminal
before the process starts, removing the race. The local and remote CLIs
capture the caller's terminal size when -t is given and pass it through
ExecOptions, matching the behavior of `podman run`.

Re-enable the previously flaky `podman exec` case in the interactive
system test, which this change makes deterministic.

Signed-off-by: Shuai Yuan <shuaiyuanzju@gmail.com>
2026-06-22 10:36:10 +08:00
Grzegorz Szczepanczyk
697fa0cc19 fix: clearer error for a privileged port on a specific IP (macOS)
With podman machine, gvproxy forwards published ports by binding them on
the host (not inside the VM) and runs unprivileged. macOS refuses to bind
a privileged port (< 1024) to a specific IP for a normal user, even though
binding all interfaces is fine, so publishing e.g. -p 127.0.0.1:80:80 used
to fail with an opaque "something went wrong with the request".

Pass the published ip:port into the gvproxy error helper and, when the body
says "permission denied" for a < 1024 port on a specific IP, return an
error that explains gvproxy binds on the host and suggests dropping the
host IP or using a port >= 1024. The raw body is kept for every other case.
Add unit tests for the helper.

Fixes: #28009

Signed-off-by: Grzegorz Szczepanczyk <g.szczepanczyk@getprintbox.com>
2026-06-19 13:25:09 +02:00
Matt Heon
df12c9806c Merge pull request #28214 from MayorFaj/feat/28189-volume-rename
feat: implement volume rename functionality
2026-06-18 14:47:35 -04:00
Tibor Dudlák
5d18575f41 fix: Update the typo in comment
Signed-off-by: Tibor Dudlák <Tibor.Dudlak@airbank.cz>
2026-06-18 14:56:24 +02:00
s3onghyun
8a43be8205 libpod: fix "to to" typo in container_top comment
Signed-off-by: s3onghyun <s3onghyun.hong@gmail.com>
2026-06-18 17:52:11 +09:00
Danish Prakash
c89c571efd Merge pull request #28928 from priyanshsao/fix-typo
fix: correct misspelled comment in container_inspect.go
2026-06-15 20:24:21 +05:30
Priyansh Sao
58d7314ee2 fix: correct misspelled comment in container_inspect.go
This replaces the misspelled word in comments "Exosed" with the correct spelling "Exposed" in the file container_inspect.go.

Fixes: #28927

Signed-off-by: Priyansh Sao <saopriyansh06@gmail.com>
2026-06-13 07:15:17 +00:00
Jan Rodák
b294a92a25 Add reasons to all staticcheck suppressions
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-06-12 10:12:40 +02:00
MayorFaj
d01b7ae534 libpod: add volume rename support
Add a podman volume rename command, REST API endpoint, and bindings for renaming volumes.

The rename updates both the VolumeConfig and VolumeState tables in a single transaction and moves the volume directory on disk, rolling back if the transaction fails. Renaming an anonymous volume converts it to a named volume. Volumes that are in use, mounted, or backed by a volume plugin or the image driver cannot be renamed.

Fixes: #28189
Signed-off-by: MayorFaj <mayorfaj@gmail.com>
2026-06-11 21:56:15 +01:00
Jan Rodák
7fe6abf197 Merge pull request #28879 from jiwahn/fix-event-attributes-labels
events: include labels in pod and volume attributes Fixes: #26480
2026-06-11 10:27:38 +02:00
Paul Holzinger
cefaa0ee44 Merge pull request #28712 from elezar/info-cdi-devices
info: report configured and discovered CDI devices
2026-06-10 14:34:35 +02:00
Jan Rodák
331946fd79 Merge pull request #28876 from solunolab/main
chore: fix some function names in comment
2026-06-10 07:30:30 +02:00
Kir Kolyshkin
3c4068bcd6 deps: bump go-criu to v8.2.0
I guess this was not done by renovate/dependabot because of major
version bump.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-06-09 11:51:46 -07:00
Jan Rodák
ee986cd7c9 Use MNT_DETACH for SHM unmount instead of retry loop
After checkpoint the SHM tmpfs can briefly return EBUSY while the
kernel releases mount propagation references. Use lazy unmount
instead of retrying, as suggested by review.

Fixes flake: `podman checkpoint/restore ip and mac handling`

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-06-09 14:57:27 +02:00
Jiwoo Ahn
ef2d2e4a58 events: include labels in pod and volume attributes
Fixes: #26480

Signed-off-by: Jiwoo Ahn <ikwydls1314@gmail.com>
2026-06-09 20:36:04 +09:00
solunolab
cba51d1de4 chore: fix some function names in comment
Signed-off-by: solunolab <solunolab@outlook.com>
2026-06-07 11:29:49 +08:00
Paul Holzinger
fab963e01c Merge pull request #28693 from kolyshkin/change-label
bump selinux to v1.15.1, use SetProcessKind
2026-06-03 18:42:58 +02:00
Giuseppe Scrivano
1c2a2ffe87 cmd, commit: register shutdown handler to unpause container
When --pause defaults to true, a Ctrl-C during commit would leave the
container paused.  Register a shutdown handler that unpauses the
container on SIGINT/SIGTERM so it is always restored to its running
state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2026-06-03 07:28:22 +02:00
Giuseppe Scrivano
db804fb1b9 cmd, commit: also pause stopping containers during commit
ContainerStateStopping is still a running state where processes are
active, so it should also be paused during commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2026-06-03 07:28:18 +02:00
Kir Kolyshkin
ad7b6be2b9 bump selinux to v1.15.1, use SetProcessKind
I was not able to find any external users of pkg/selinux but kept it
for now (and marked as deprecated) so we can remove it later.

PS pkg/selinux adds go:fix directives which are not (yet) recognized
by the gocheckcompilerdirectives linter, so add a temporary exception).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-06-02 11:18:34 -07:00
zhongchunhe.zch
af563a9a10 Some improvements for libpod.
Signed-off-by: zhongchunhe.zch <zhongchunhe.zch@qq.com>
2026-06-02 19:02:38 +08:00
Evan Lezar
e740848eb9 info: report configured and discovered CDI devices
Add CDI information to podman info and podman system info.

The host info now includes the configured CDI spec directories and the
currently discovered CDI devices. The devices are resolved when the info
endpoint is called and there is no need to refresh these in the background.

Also map the same data into the Docker-compatible /info response as CDISpecDirs and DiscoveredDevices.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2026-06-01 21:45:41 +02:00
zhongchunhe.zch
1e0be4dec5 Improvements for newConmonOCIRuntime() in libpod/oci_conmon_common.go
Creating lookup tables for runtime support is unnecessary, simply verify if the target string exists within the arrays.

Signed-off-by: zhongchunhe.zch <zhongchunhe.zch@qq.com>
2026-05-28 10:28:05 +08:00
Kir Kolyshkin
d4f60b5826 libpod: some modernize fixes for freebsd and darwin
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-22 14:15:49 -07:00
Kir Kolyshkin
bf78f80b00 Replace strings.Split(..)[0] with strings.Cut
These places were ignored by modernize, so I did some grepping and
editing.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-22 13:08:56 -07:00
Daniel J Walsh
f524bce46a Merge pull request #28753 from kolyshkin/os-is
Stop using os.Is{Exist,NotExist,Permission} checks
2026-05-22 05:18:45 -04:00
Tom Sweeney
3fb897f154 Merge pull request #28747 from kolyshkin/lint-nits
Remove unused nolint annotations
2026-05-21 19:58:34 -04:00
Kir Kolyshkin
7f7b35356f Replace os.Is* error checks with errors.Is
Using os.Is{Exist,NotExist,Permission} checks is not recommended in the
new code (see official documentation). While using it in the existing
code is OK, it may still result in a subtle errors later (for a specific
example of that, see [1]).

Replace those with errors.Is.

Generated by:

	gofmt -r 'os.IsExist(a) -> errors.Is(a, os.ErrExist)' -w .
	gofmt -r 'os.IsNotExist(a) -> errors.Is(a, os.ErrNotExist)' -w .
	gofmt -r 'os.IsPermission(a) -> errors.Is(a, os.ErrPermission)' -w .
	goimports -w .
	git diff vendor test/tools/vendor | patch -p1 -R

[1]: https://github.com/opencontainers/runc/pull/5061
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-21 13:09:42 -07:00
Kir Kolyshkin
a7886d1fe8 Remove unused nolint annotations
The interfacer linter was removed a few years ago.

Remove the annotations as well.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-20 15:02:25 -07:00
Jan Rodák
e598657244 Add pasta-based port forwarding for rootless bridge networks
Add rootless_port_forwarder="pasta" option that uses pesto to update
pasta's forwarding table via UNIX socket, preserving source IPs that
rootlessport's userspace proxy masks.

HostIP is stripped from port mappings in the netavark wrapper when
pasta forwarding is active because pesto handles host-side binding
while pasta's splice changes the destination IP that netavark DNAT
expects. Pesto binds both 0.0.0.0 and [::] for dual-stack support.

Fixes: https://redhat.atlassian.net/browse/RUN-2214
Fixes: https://github.com/containers/podman/issues/8193
Fixes: https://redhat.atlassian.net/browse/RUN-3587

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-05-20 14:24:47 +02:00
Brent Baude
3c4fb923f0 Merge pull request #28724 from SebTardif/fix/close-leaked-file-handles
Close leaked file handles in container config, CRIU stats, and playbook read
2026-05-19 15:56:27 -05:00
Paul Holzinger
6f048e6500 inspect: do not show <nil> as gateway
When a network is created without gateway, i.e. --internal --disable-dns
then the gateway will be nil. But converting a nil ip to string produces
"<nil>" which is not what we want as we like an empty string there to
signal that the network has no gateway.

Fixes: #28705

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-18 20:47:52 +02:00
Jan Rodák
517070e750 Merge pull request #28673 from kyounghunJang/feat/add-volume-prune-dry-run
volume prune: add dry-run support
2026-05-18 19:26:18 +02:00
Byounguk Lee
b50b9c0dbc events: support artifact events with refactored event forwarding
- libpod/events.go & libpod/runtime.go: Added the `Artifact` event type.
  Refactored and deduplicated event forwarding logic by introducing
  `spawnEventForwarder[T any]`, replacing separate goroutine loops for
  images and artifacts. Implemented graceful shutdown and resolved eventer
  initialization race conditions.
- libpod/events: Implemented event filtering by name/ID, updated journald
  and logfile readers/writers for artifact events, and added `Artifact` to
  `ToHumanReadable` formatting.
- cmd/podman: Added shell auto-completion for `artifact=` and `type=artifact` filters.
- docs/test: Documented the `artifact` event type, statuses, and filters in
  `podman-events.1.md`. Added an end-to-end test in `events_test.go` to verify
  event emissions.

Signed-off-by: Byounguk Lee <nimdrak@gmail.com>
2026-05-18 00:05:10 +00:00
Sebastien Tardif
846d1a1b05 Close leaked file handles in container config, CRIU stats, and playbook read
Add missing defer Close() calls in four locations:

- libpod/container.go: specFromState() opens the container config file
  but never closes it after reading, leaking one fd per call.

- libpod/container_internal_common.go: checkpoint() and restore() each
  open the bundle directory for CRIU statistics but never close it,
  leaking one fd per checkpoint/restore operation.

- pkg/machine/shim/host.go: Init() opens the playbook file but never
  closes it after ReadAll, leaking one fd per machine init.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-17 16:09:56 -07:00
KyounghoonJang
3d899a8c25 volume prune: add dry-run support
Add a --dry-run option to show which volumes would be pruned without removing them.

Related: #27838
Signed-off-by: KyounghoonJang <matkimchi_@naver.com>
2026-05-16 19:03:34 +09:00