731 Commits

Author SHA1 Message Date
08cd7ce41b specgen: use storageTypes instead of storage package
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-01-25 17:21:36 +01:00
5cc83da1c6 Pass the OCI runtime an empty entrypoint when there is no entrypoint
Some OCI runtimes (cf. [1]) may tolerate container images that don't
specify an entrypoint even if no entrypoint is given on the command
line. In those cases, it's annoying for the user to have to pass a ""
argument to podman.

If no entrypoint is given, make the behavior the same as if an empty ""
entrypoint was given.

[1] https://github.com/containers/crun-vm

Signed-off-by: Alberto Faria <afaria@redhat.com>
2024-01-23 10:10:44 +00:00
77389bd05c Add missing check for errors returned from SpecGenToOCI to MakeContainer.
This avoids nil pointer exceptions in the subsequent code that tries to access the runtimeSpec returned from SpecGenToOCI.

[NO NEW TESTS NEEDED]

Signed-off-by: Sebastian Mosbach <sm453@cam.ac.uk>
2024-01-18 11:37:16 +00:00
522934d5cf Replace strings.SplitN with strings.Cut
Cut is a cleaner & more performant api relative to SplitN(_, _, 2) added in go 1.18

Previously applied this refactoring to buildah:
https://github.com/containers/buildah/pull/5239

Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-11 13:50:15 +00:00
8bdf77aa20 Refactor: replace StringInSlice with slices.Contains
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 16:25:56 +02:00
2a2d0b0e18 chore: delete obsolete // +build lines
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-04 11:53:38 +02:00
4083ddbb00 Kube Generate - check options in bind-mount-options exist before accessing
Verify that the separator ':' was found before splitting the string

[NO NEW TESTS NEEDED]

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-12-26 18:13:41 +02:00
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
32c25c6026 pkg/specgen/generate: NOP verifyContainerResources() on freebsd
There is no point in calling into cgroup specific code as freebsd does
not support cgroups.

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
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
3b03e85471 Merge pull request #20789 from umohnani8/healthcheck
Don't update health check status during initialDelaySeconds
2023-12-01 13:12:50 +00: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
6d9d8f06ce Merge pull request #20517 from rhatdan/mask
Get masked paths and readonly masked patchs from containers/common @rhatdan
2023-11-29 02:12:37 +00:00
a2bf8c6d50 refactor(machine): improve machine marker value
1. Set the marker to the current virtual machine type instead of fixed qemu.
2. Update containers/common

[NO NEW TESTS NEEDED]

Signed-off-by: Black-Hole1 <bh@bugs.cc>
2023-11-28 21:47:12 +08:00
62060f3234 Get masked paths and readonly masked patchs from containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-19 10:01:20 -05: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
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
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
af0ef47f0c Add status messages to podman --remote commit
Fixes: https://github.com/containers/podman/issues/19947

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-01 14:31:09 -04:00
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
e966c86d98 container.conf: support attributed string slices
All `[]string`s in containers.conf have now been migrated to attributed
string slices which require some adjustments in Buildah and Podman.

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-27 12:44:33 +02:00
8a0968baa2 pkg/specgen: remove config_unsupported.go
This is not used at all but causes a libimage import for non linux
builds which causes bloat for them, with the new !remote tag this is no
longer possible and we have to remove it to fix the build.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-24 12:49:40 +02:00
29273cda10 lint: fix warnings found by perfsprint
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-20 16:27:46 +02:00
936e30f68b Use node hostname in kube play when hostNetwork=true
When the hostNetwork option is set to true in the k8s yaml,
set the pod's hostname to the name of the machine/node as is
done in k8s. Also set the utsns to host.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-10-19 12:22:58 -04:00
efe5e98d06 use FindInitBinary() for init binary
Use the new FindInitBinary() function to lookup the init binary, this
allows the use of helper_binaries_dir in contianers.conf[1]

[NO NEW TESTS NEEDED]

[1] https://github.com/containers/common/issues/1110

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-18 15:14:22 +02:00
17cebb3ff8 Add DefaultMode to kube play
Add support for DefaultMode for configMaps and secrets.
This allows users to set the file permissions for files
created with their volume mounts. Adheres to k8s defaults.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-09-29 11:58:38 -04:00
4212b4998d Merge pull request #19823 from Backfighter/fix-17028
Fix all ports exposed on host by kube play
2023-09-28 03:29:43 -04:00
40d3c3b9b0 Add Intel RDT support
Add --rdt-class=COS to the create and run command to enable the
assignment of a container to a Class of Service (COS). The COS
represents a part of the cache based on the Cache Allocation Technology
(CAT) feature that is part of Intel's Resource Director Technology
(Intel RDT) feature set. By assigning a container to a COS, all PID's of
the container have only access to the cache space defined for this COS.
The COS has to be pre-configured based on the resctrl kernel driver.
cat_l2 and cat_l3 flags in /proc/cpuinfo represent CAT support for cache
level 2 and 3 respectively.

Signed-off-by: Wolfgang Pross <wolfgang.pross@intel.com>
2023-09-27 16:44:13 +00:00
f52b02f406 Fix all ports exposed by kube play
Container ports defined with containerPort were exposed by default
even though kubernetes interprets them as mostly informative.
Closes #17028

Signed-off-by: Peter Werner <wpw.peter@gmail.com>
2023-09-23 19:53:46 +02:00
8d3010d06b specgen, rootless: fix mount of cgroup without a netns
commit cf364703fc3f94cd759cc683e3ab9083e8ecc324 changed the way
/sys/fs/cgroup is mounted when there is not a netns and it now honors
the ro flag.  The mount was created using a bind mount that is a
problem when using a cgroup namespace, fix that by mounting a fresh
cgroup file system.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-21 13:20:09 +02:00
f9aba28ca7 make golangci-lint happy
First do not lint pkg/domain/infra/abi with the remote tag as this is
only local code.

Then mark the cacheLibImage field as unused, this should be an unused
stub for the remote client so that we do not leak libimage.
The linter sees that with the remote tag so we need to silence that
warning.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-14 11:21:00 +02:00
c1b6effac5 add !remote tag to pkg/specgen/generate
These files should never be included on the remote client. There only
there to finalize the spec on the server side.

This makes sure it will not get reimported by accident and bloat the
remote client again.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-14 11:21:00 +02:00
3acee29cf4 pkg/specgen: do not depend on libimage for remote
This is the last place were the remote client pulls in libimage, with
this the podman-remote binary size decreases from 44788 KB to
39424 KB (not stripped).

This change simply fixes that by gating it behind the remote build tag.
Of course it would be a bit cleaner to never leak libimage into
pkg/specgen and only have it in pkg/specgen/generate. But this would be
much more involved with big chnages so I went with the easy and quick
way instead.

[NO NEW TESTS NEEDED]

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-14 11:20:59 +02:00
325736fcb7 Merge pull request #19914 from umohnani8/term
Add support for kube TerminationGracePeriodSeconds
2023-09-11 19:24:18 +02:00
19bd9b33dd libpod: move oom_score_adj clamp to init
commit 8b4a79a744ac3fd176ca4dc0e3ae40f75159e090 introduced
oom_score_adj clamping when the container oom_score_adj value is lower
than the current one in a rootless environment.  Move the check to
init() time so it is performed every time the container starts and not
only when it is created.  It is more robust if the oom_score_adj value
is changed for the current user session.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-11 17:04:37 +02:00
d9a85466a0 Add support for kube TerminationGracePeriodSeconds
Add support to kube play to support the TerminationGracePeriodSeconds
fiels by sending the value of that to podman's stopTimeout.
Add support to kube generate to generate TerminationGracePeriodSeconds
if stopTimeout is set for a container (will ignore podman's default).

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-09-10 16:41:24 -04:00
331b3c216d cmd, specgen: allow cgroup resources without --infra
When the infra container is not created, we can still set limits on
the pod cgroup.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:48 +02:00
83334fb4e7 specgen: allow --share-parent with --infra=false
This allows to use --share-parent with --infra=false, so that the
containers in the pod can share the parent cgroup.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:48 +02:00
6ee8f73d41 Merge pull request #19885 from rhatdan/kube
Add support for kube  securityContext.procMount
2023-09-08 06:56:05 -04:00
b83485022d Add support for kube securityContext\.procMount
Fixes: https://github.com/containers/podman/issues/19881

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-07 09:49:11 -04:00
2d7d8d1d10 Tmpfs should not be mounted noexec
The logic here makes little sense, basically the /tmp and /var/tmp are
always set noexec, while /run is not.  I don't see a reason to set any
of the three noexec by default.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-07 08:06:55 -04:00
30abd7f1af security: accept empty capabilities list
allow the image to specify an empty list of capabilities, currently
podman chokes when the io.containers.capabilities specified in an
image does not contain at least one capability.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-06 14:55:28 +02:00
8b4a79a744 linux, rootless: clamp oom_score_adj if it is too low
when running rootless, if the specified oom_score_adj for the
container process is lower than the current value, clamp it to the
current value and print a warning.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-04 14:44:14 +02:00
4cac1d3bcb Don't re-inspect an image
getImageFromSpec has just make exactly the same Inspect call.

[NO NEW TESTS NEEDED]: This adds no new functionality, and
it's hard to test that a duplicate call didn't happen without
(intrusive and hard-to-maintain) mocks.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-08-28 22:43:23 +02:00
c416e45766 Ignore the resource limits on cgroups V1 rootless systems
This is a regression for #18052.
When podman ignores the resource limits, s.ResourceLimits needs to be
nil.

[NO NEW TESTS NEEDED]

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-08-23 13:58:13 +09:00
f38668e322 Merge pull request #19622 from jakecorrenti/umask-on-play
Set default Umask for `podman kube play`
2023-08-22 06:39:58 -02:30
5eee8825e8 Set default Umask for podman kube play
Fixes a bug where `podman kube play` fails to set a container's Umask
to the default 0022, and sets it to 0000 instead.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-08-21 10:56:53 -04:00