4036 Commits

Author SHA1 Message Date
db68764d8b Fix Docker API compatibility with network alias (#17167)
* Add BaseHostsFile to container configuration
* Do not copy /etc/hosts file from host when creating a container using Docker API

Signed-off-by: Gavin Lam <gavin.oss@tutamail.com>
2023-12-14 23:31:44 -05:00
5c7f745468 Remove deprecated field ContainerState.NetworkStatusOld
This field drags in a dependency on CNI and thereby blocks us from disabling CNI
support via a build tag

[NO NEW TESTS NEEDED]

Signed-off-by: Dan Čermák <dcermak@suse.com>
2023-12-12 17:09:39 +01:00
03d411abc0 libpod: split out cgroups call into linux specific file
So that we do not cause compile error on freebsd.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-12-07 11:24:47 +01:00
a687c38860 use rootless netns from c/common
Use the new rootlessnetns logic from c/common, drop the podman code
here and make use of the new much simpler API.

ref: https://github.com/containers/common/pull/1761

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-12-07 11:24:46 +01:00
67aae8e62e Merge pull request #20866 from giuseppe/add-preserve-fds-list
podman: new option --preserve-fd
2023-12-06 13:34:34 +00:00
100089f411 Merge pull request #20885 from IceWreck/userns-kube
Add support for the userns annotation in kube play
2023-12-05 13:55:20 +00:00
01d397a658 podman: new option --preserve-fd
add a new option --preserve-fd that allows to specify a list of FDs to
pass down to the container.

It is similar to --preserve-fds but it allows to specify a list of FDs
instead of the maximum FD number to preserve.

--preserve-fd and --preserve-fds are mutually exclusive.

It requires crun since runc would complain if any fd below
--preserve-fds is not preserved.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-12-05 10:16:41 +01:00
5af152ec29 Merge pull request #20874 from mheon/eval_symlinks_on_db_paths
Handle symlinks when checking DB vs runtime configs
2023-12-03 11:50:03 +00:00
04519234e8 Add support for the userns annotation in kube play
[NO NEW TESTS NEEDED]

Signed-off-by: Anchit Bajaj <ab@abifog.com>
2023-12-02 23:14:29 +01:00
f384bdf66b Handle symlinks when checking DB vs runtime configs
When Podman starts, it checks a number of critical runtime paths
against stored values in the database to make sure that existing
containers are not broken by a configuration change. We recently
made some changes to this logic to make our handling of the some
options more sane (StaticDir in particular was set based on other
passed options in a way that was not particularly sane) which has
made the logic more sensitive to paths with symlinks. As a simple
fix, handle symlinks properly in our DB vs runtime comparisons.

The BoltDB bits are uglier because very, very old Podman versions
sometimes did not stuff a proper value in the database and
instead used the empty string. SQLite is new enough that we don't
have to worry about such things.

Fixes #20872

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-12-02 15:48:47 -05:00
c47962802a Merge pull request #20657 from nalind/commit-config
RHEL-14922: accept a config blob alongside the "changes" slice when committing
2023-12-01 21:09:23 +00:00
5364fbd7e4 Merge pull request #20869 from dfr/freebsd-hostname
libpod: Detect whether we have a private UTS namespace on FreeBSD
2023-12-01 17:21:09 +00:00
3b03e85471 Merge pull request #20789 from umohnani8/healthcheck
Don't update health check status during initialDelaySeconds
2023-12-01 13:12:50 +00:00
45e53ed7b0 libpod: Detect whether we have a private UTS namespace on FreeBSD
Right now, we always use a private UTS namespace on FreeBSD. This should
be made optional but implementing that cleanly needs a FreeBSD extension
to the OCI runtime config. The process for that is starting
(https://github.com/opencontainers/tob/pull/133) but in the meantime,
assume that the UTS namespace is private on FreeBSD.

This moves the Linux-specific namespace logic to
container_internal_linux.go and adds a FreeBSD stub.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-12-01 12:37:39 +00:00
426db6fcc1 Accept a config blob alongside the "changes" slice when committing
When committing containers to create new images, accept a container
config blob being passed in the body of the API request by adding a
Config field to our API structures.  Populate it from the body of
requests that we receive, and use its contents as the body of requests
that we make.

Make the libpod commit endpoint split changes values at newlines, just
like the compat endpoint does.

Pass both the config blob and the "changes" slice to buildah's Commit()
API, so that it can handle cases where they overlap or conflict.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-11-30 09:00:52 -05:00
6b9221d852 Merge pull request #20837 from dfr/freebsd-vnet
libpod: Allow using just one jail per container on FreeBSD
2023-11-30 08:38:20 +00:00
5b3d82f9bc sqlite: set busy timeout to 100s
Only one process can write to the sqlite db at the same time, if another
process tries to use it at that time it fails and a database is locked
error is returned. If this happens sqlite should keep retrying until it
can write. To do that we can just set the _busy_timeout option. A 100s
timeout should be enough even on slower systems but not to much in case
there is a deadlock so it still returns in a reasonable time.

[NO NEW TESTS NEEDED] I think we strongly need to consider some form of
parallel stress testing to catch bugs like this.

Fixes #20809

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-11-29 18:07:29 +01:00
d4ac2f3dd5 libpod: Allow using just one jail per container on FreeBSD
In FreeBSD-14.0, it is possible to configure a jail's network settings
from outside the jail using ifconfig and route's new '-j' option. This
removes the need for a separate jail to own the container's vnet.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-11-29 16:18:34 +00:00
f35d1c1c25 Don't update health check status during initialDelaySeconds
When InitialDelaySeconds in the kube yaml is set for a helthcheck,
don't update the healthcheck status till those initial delay seconds are over.
We were waiting to update for a failing healtcheck, but when the healthcheck
was successful during the initial delay time, the status was being updated as healthy
immediately.
This is misleading to the users wondering why their healthcheck takes
much longer to fail for a failing case while it is quick to succeed for
a healthy case. It also doesn't match what the k8s InitialDelaySeconds
does. This change is only for kube play, podman healthcheck run is
unaffected.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-11-29 08:37:39 -05:00
83c08a2f5c Merge pull request #20609 from cgiradkar/19124_remove_event_fix
Set correct exitcode in remove events
2023-11-28 16:21:17 +00:00
2645f91bfe Merge pull request #20813 from Luap99/sqlite-removepodcontainers
sqlite: fix missing Commit() in RemovePodContainers()
2023-11-28 16:07:18 +00:00
9627d3043d Merge pull request #20810 from Luap99/sqlite-validate
sqlite: fix issue in ValidateDBConfig()
2023-11-28 16:04:42 +00:00
572f38c0db Set correct exitcode in remove events and change ContainerExitCode from int to int ptr
Added additional check for event type to be remove and set the correct exitcode.
While it was getting difficult to maintain the omitempty notation for Event->ContainerExitCode, changing the type from int to int ptr gives us the ability to check for ContainerExitCode to be not nil and continue operations from there.

closes #19124

Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
2023-11-28 13:31:18 +00:00
d7b970a4c4 sqlite: fix issue in ValidateDBConfig()
If a transaction is started it must either be committed or rolled back.
The function uses defer to call `tx.Rollback()` if there is an error
returned. However it also called `tx.Commit()` and afterwards further
errors can be returned which means it tries to roll back a already
committed transaction which cannot work.

This fix is to make sure tx.Commit() is the last call in that function.
see https://github.com/containers/podman/issues/20731

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-11-28 14:27:49 +01:00
e26f677b16 sqlite: fix missing Commit() in RemovePodContainers()
We have to Commit() the transaction. Note this is only in a rare pod
remove code path and very unlikely to ever be used.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-11-28 14:26:29 +01:00
c8f262fec9 Use idtools.SafeChown and SafeLchown everywhere
If we get an error chowning a file or directory to a UID/GID pair
for something like ENOSUP or EPERM, then we should ignore as long as the UID/GID
pair on disk is correct.

Fixes: https://github.com/containers/podman/issues/20801

[NO NEW TESTS NEEDED]

Since this is difficult to test and existing tests should be sufficient
to ensure no regression.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-27 20:41:56 -05:00
fe65f059ab libpod: drop dead code
these functions are not used anymore in the codebase, so drop them.

[NO NEW TESTS NEEDED] no new functionalities are added

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-24 11:19:02 +01:00
6c29a870f7 Merge pull request #20528 from giuseppe/consolidate-xdg-runtime-code
Consolidate XDG_RUNTIME code
2023-11-24 09:27:30 +00:00
cd21973f47 pkg/util: use code from c/storage
[NO NEW TESTS NEEDED] no new functionalities are added

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-23 21:36:42 +01:00
ddd6cdfd77 Ignore SELinux relabel on unsupported file systems
We were ignoreing relabel requests on certain unsupported
file systems and not on others, this changes to consistently
logrus.Debug ENOTSUP file systems.

Fixes: https://github.com/containers/podman/discussions/20745

Still needs some work on the Buildah side.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-22 09:25:38 -05:00
478afa728d vendor: update containers/{common,storage,image,buildah}
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-21 21:04:47 +01:00
ee5f582fbc Merge pull request #20356 from vrothberg/RUN-1935
new 'no-dereference' mount option
2023-11-21 14:40:03 +00:00
e40d70cecc new 'no-dereference' mount option
Add a new `no-dereference` mount option supported by crun 1.11+ to
re-create/copy a symlink if it's the source of a mount.  By default the
kernel will resolve the symlink on the host and mount the target.
As reported in #20098, there are use cases where the symlink structure
must be preserved by all means.

Fixes: #20098
Fixes: issues.redhat.com/browse/RUN-1935
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-11-21 13:17:58 +01:00
ae9b63fbf0 Check for imageID, not imageName
We are only using imageID on that branch, so it is
more consistent.

Should not change behavior; in callers, either
both are set or neither.

[NO NEW TESTS NEEDED]

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-20 19:06:44 +01:00
ff80e40adf Use NewStoreReference instead of ParseStoreReference
By construction, imageID is a full image ID, so avoid heuristics
by using a more specific API.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-20 18:26:38 +01:00
e9587f5e37 Don't re-assign imageID
By construction in callers, imageID is always a full ID,
so this assignment is always a no-op.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-20 18:24:28 +01:00
c850682208 Remove clearly dead code
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-20 16:57:28 +01:00
7d107b9892 Merge pull request #19879 from rhatdan/ulimits
Support passing of Ulimits as -1 to mean max
2023-11-10 10:47:43 +00:00
01fd9e906b Merge pull request #20620 from baude/codecleanup
Automatic code cleanups - JetBrains
2023-11-08 22:14:36 +00:00
78798cab00 Automatic code cleanups - JetBrains
A bunch of cleanups as suggested by linters/etc in JetBrains IDE.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-11-07 14:05:15 -06:00
c2de6d34ca Run codespell on podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-06 09:23:16 -06:00
942bcf34b8 Update container-device-interface (CDI) to v0.6.2
This updates the container-device-interface dependency to v0.6.2 and renames the import to
tags.cncf.io/container-device-interface to make use of the new vanity URL.

[NO NEW TESTS NEEDED]

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Evan Lezar <elezar@nvidia.com>
2023-11-04 01:12:06 +01:00
33753db47b vendor: update c/common
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-02 19:46:22 +01:00
d2a37222b9 freebsd: drop dead code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-02 14:55:33 +01:00
06a07c98e7 libpod: make removePodCgroup linux specific
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-02 14:55:33 +01:00
aefa9abf4b image: replace GetStoreImage with ResolveReference
GetStoreImage is deprecated after containers/image#2056

Signed-off-by: Aditya R <arajan@redhat.com>
2023-11-02 11:22:02 +05:30
18d6bb40d5 Support passing of Ulimits as -1 to mean max
Docker allows the passing of -1 to indicate the maximum limit
allowed for the current process.

Fixes: https://github.com/containers/podman/issues/19319

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-01 08:46:55 -04:00
b332ca7a02 libpod: fix /etc/hostname with --uts=host
when --uts=host is provided, the expectation is to use the hostname
from the host not the container name.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-31 13:02:17 +01:00
77d2658201 Merge pull request #20369 from cgiradkar/Issue-16759-docs
Define better error message for container name conflicts with external storage
2023-10-30 10:22:00 +00:00
4f6a8f0d50 Merge pull request #20483 from vrothberg/RUN-1934
container.conf: support attributed string slices
2023-10-27 17:49:13 +00:00