52 Commits

Author SHA1 Message Date
bd09b7aa79 bump go module to version 4
Automated for .go files via gomove [1]:
`gomove github.com/containers/podman/v3 github.com/containers/podman/v4`

Remaining files via vgrep [2]:
`vgrep github.com/containers/podman/v3`

[1] https://github.com/KSubedi/gomove
[2] https://github.com/vrothberg/vgrep

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2022-01-18 12:47:07 +01:00
607cb80bf7 Fix cgroup mode handling in api server
Also change code to globably be consistent when refering to capatilized
Cgroup.

Fixed: https://github.com/containers/podman/issues/12550

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-01-14 12:32:35 -05:00
a95c01e0e4 pkg: use PROXY_VARS from c/common
Signed-off-by: Aditya Rajan <arajan@redhat.com>
2022-01-11 00:46:10 +05:30
2a524fcaec fix healthcheck timeouts and ut8 coercion
this commit fixes two bugs and adds regression tests.

when getting healthcheck values from an image, if the image does not
have a timeout defined, this resulted in a 0 value for timeout.  The
default as described in the man pages is 30s.

when inspecting a container with a healthcheck command, a customer
observed that the &, <, and > characters were being converted into a
unicode escape value.  It turns out json marshalling will by default
coerce string values to ut8.

Fixes: bz2028408

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-01-06 13:56:54 -06:00
1aa4e4d4d1 container creation: don't apply reserved annotations from image
Do not apply reserved annotations from the image to the container.
Reserved annotations are applied during container creation to retrieve
certain information (e.g., custom seccomp profile or autoremoval)
once a container has been created.

Context: #12671
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-12-23 13:40:46 +01:00
44d1618dd7 Add --unsetenv & --unsetenv-all to remove def environment variables
Podman adds a few environment variables by default, and
currently there is no way to get rid of them from your container.
This option will allow  you to specify which defaults you don't
want.

--unsetenv-all will remove all default environment variables.

Default environment variables can come from podman builtin,
containers.conf or from the container image.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-15 15:10:12 -05:00
fad14dafe1 faster image inspection
Vendor the latest HEAD in c/common to pull in changes for a faster
inspection of images.  Previously, only the size computation was
optional, now the one for the parent image is as well.

In many cases, the parent image is not needed but it takes around 10ms
on my local machine.  With this change, we cut off 10ms from many code
paths, most importantly, container creation.

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-10-08 14:47:33 +02:00
c6a896b0c7 Merge pull request #11808 from vrothberg/cache
pkg/specgen: cache image in generator
2021-10-01 10:57:13 -04:00
81aabc8054 Merge pull request #11686 from cdoern/podDeviceOptions
Pod Device-Read-BPS support
2021-10-01 10:53:14 -04:00
686b7ef7bf pkg/specgen: cache image in generator
To prevent expensive redundant lookups and inspects on the same image,
cache the image in the generator.  Note that once a given image has been
inspected, subsequent calls will use the libimage-internal cache.

[NO TESTS NEEDED] since it is no functional change.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-10-01 13:30:46 +02:00
5ea369adef libpod: add GetConfigNoCopy()
Add a new function to libpod to directly access the runtime
configuration without creating an expensive deep copy.  Further migrate
a number of callers to this new function.

This drops the number of calls to JSONDeepCopy from 4 to 1 in a simple
`podman run --rm -d busybox top`.

Future work: Please note that there are more callers of GetConfig() that
can me migrated to GetConfigNoCopy().

[NO TESTS NEEDED]

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-29 14:24:09 +02:00
2d86051893 Pod Device-Read-BPS support
added the option for the user to specify a rate, in bytes, at which they would like to be able
to read from the device being added to the pod. This is the first in a line of pod device options.

WARNING: changed pod name json tag to pod_name to avoid confusion when marshaling with the containerspec's name

Signed-off-by: cdoern <cdoern@redhat.com>
2021-09-28 21:20:01 -04:00
3c3fa6fac4 implement init containers in podman
this is the first pass at implementing init containers for podman pods.
init containersare made popular by k8s as a way to run setup for pods
before the pods standard containers run.

unlike k8s, we support two styles of init containers: always and
oneshot.  always means the container stays in the pod and starts
whenever a pod is started.  this does not apply to pods restarting.
oneshot means the container runs onetime when the pod starts and then is
removed.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2021-08-04 14:14:36 -05:00
e1ac0c3033 vendor containers/common@main
The `IgnorePlatform` options has been removed from the
`LookupImageOptions` in libimage to properly support multi-arch images.

Skip one buildah-bud test which requires updated CI images.  This is
currently being done in github.com/containers/podman/pull/10829 but
we need to unblock merging common and buildah into podman.

[NO TESTS NEEDED]

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-16 14:19:56 +02:00
da33fc45b6 Merge pull request #10583 from rhatdan/log
Support log_tag defaults from containers.conf
2021-06-24 05:47:10 -04:00
f2dff41dbc Support log_tag defaults from containers.conf
Fixes: https://github.com/containers/podman/issues/10204

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-23 12:54:25 -04:00
5fc622f945 create: support images with invalid platform
Much to my regret, there is a number of images in the wild with invalid
platforms breaking the platform checks in libimage that want to make
sure that a local image is matching the expected platform.

Imagine a `podman run --arch=arm64 fedora` with a local amd64 fedora
image.  We really shouldn't use the local one in this case and pull down
the arm64 one.

The strict platform checks in libimage in combination with invalid
platforms in images surfaced in Podman being able to pull an image but
failing to look it up in subsequent presence checks.  A `podman run`
would hence pull such an image but fail to create the container.

Support images with invalid platforms by vendoring the latest HEAD from
containers/common.  Also remove the partially implemented pull-policy
logic from Podman and let libimage handle that entirely.  However,
whenever --arch, --os or --platform are specified, the pull policy will
be forced to "newer".  This way, we pessimistically assume that the
local image has an invalid platform and we reach out to the registry.
If there's a newer image (i.e., one with a different digest), we'll pull
it down.

Please note that most of the logic has either already been implemented
in libimage or been moved down which allows for removing some clutter
from Podman.

[NO TESTS NEEDED] since c/common has new tests.  Podman can rely on the
existing tests.

Fixes: #10648
Fixes: #10682
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-06-23 15:42:13 +02:00
0f7d54b026 migrate Podman to containers/common/libimage
Migrate the Podman code base over to `common/libimage` which replaces
`libpod/image` and a lot of glue code entirely.

Note that I tried to leave bread crumbs for changed tests.

Miscellaneous changes:

 * Some errors yield different messages which required to alter some
   tests.

 * I fixed some pre-existing issues in the code.  Others were marked as
   `//TODO`s to prevent the PR from exploding.

 * The `NamesHistory` of an image is returned as is from the storage.
   Previously, we did some filtering which I think is undesirable.
   Instead we should return the data as stored in the storage.

 * Touched handlers use the ABI interfaces where possible.

 * Local image resolution: previously Podman would match "foo" on
   "myfoo".  This behaviour has been changed and Podman will now
   only match on repository boundaries such that "foo" would match
   "my/foo" but not "myfoo".  I consider the old behaviour to be a
   bug, at the very least an exotic corner case.

 * Futhermore, "foo:none" does *not* resolve to a local image "foo"
   without tag anymore.  It's a hill I am (almost) willing to die on.

 * `image prune` prints the IDs of pruned images.  Previously, in some
   cases, the names were printed instead.  The API clearly states ID,
   so we should stick to it.

 * Compat endpoint image removal with _force_ deletes the entire not
   only the specified tag.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-05 11:30:12 +02:00
5dded6fae7 bump go module to v3
We missed bumping the go module, so let's do it now :)

* Automated go code with github.com/sirkon/go-imports-rename
* Manually via `vgrep podman/v2` the rest

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 09:03:51 +01:00
cc846a8cd9 Support annotations from containers.conf
Currently podman does not use the annotations specified in the
containers.conf. This PR fixes this.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-09 13:18:18 -05:00
0f668aa085 workdir presence checks
A container's workdir can be specified via the CLI via `--workdir` and
via an image config with the CLI having precedence.

Since images have a tendency to specify workdirs without necessarily
shipping the paths with the root FS, make sure that Podman creates the
workdir.  When specified via the CLI, do not create the path, but check
for its existence and return a human-friendly error.

NOTE: `crun` is performing a similar check that would yield exit code
127.  With this change, however, Podman performs the check and yields
exit code 126.  Since this is specific to `crun`, I do not consider it
to be a breaking change of Podman.

Fixes: #9040
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-26 09:02:21 +01:00
f430467453 Set log driver for compatability containers
when using the compatibility api to create containers, now reflect the
use of k8s-file as json-file so that clients, which are
unaware of k8s-file, can work.  specifically, if the container is using
k8s-file as the log driver, we change the log type in container
inspection to json-file.  These terms are used interchangably in other
locations in libpod/podman.

this fixes log messages in compose as well.

[NO TESTS NEEDED]

Signed-off-by: baude <bbaude@redhat.com>
2021-01-20 13:07:31 -06:00
1c1e670d40 Use HTTPProxy settings from containers.conf
This PR takes the settings from containers.conf and uses
them.  This works on the podman local but does not fix the
issue for podman remote or for APIv2.  We need a way
to specify optionalbooleans when creating containers.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-11 17:35:39 -05:00
9dfc636fd6 Fix build for mips architecture follow-up
Follow-up to commit (1ad796677e1c). The build on mips is still
failing because SIGWINCH was not defined in the signal pkg.
Also stat_t.Rdev is unit32 on mips so we need to typecast.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-01-07 15:04:22 +01:00
4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
a4da384b55 Ensure that --net=host/pod/container/none warn with -p
Setting port mappings only works when CNI is configuring our
network (or slirp4netns, in the rootless case). This is not the
case with `--net=host`, `--net=container:`, and joining the
network namespace of the pod we are part of. Instead of allowing
users to do these things and then be confused why they do
nothing, let's match Docker and return a warning that your port
mappings will do nothing.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-11-04 13:42:58 -05:00
1d7cb7f477 Merge pull request #7798 from QiWang19/run-manifest
Use local image if input image is a manifest list
2020-09-30 18:38:07 +00:00
d24ec64887 Use local image if input image is a manifest list
If run&create image returns error: image contains manifest list, not a runnable image, find the local image that has digest matching the digest from the list and use the image from local storage for the command.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-09-30 10:38:02 -04:00
ac23ff55b8 We already set container=podman environment variable
Only need to set container, no need for containers

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-29 15:26:45 -04:00
60fe96118f Use environment from containers.conf
podman needs to use the environment settings in containers.conf
when setting up the containers.

Also host environment variables should be relative to server side
not the client.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-28 06:06:08 -04:00
afa823e4e7 Fix handling of working dir
Buildah and podman build can create images without a working dir.

FROM fedora
WORKDIR /test

If you build this image with caching twice, the second time the image
will not have a working dir.

Similarly if you execute

podman run --workdir /foobar fedora

It blows up since the workingdir is not created automatically.

Finally there was duplicated code for getting the workingdir
out of an image, that this PR removes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-10 12:46:05 -04:00
a5e37ad280 Switch all references to github.com/containers/libpod -> podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 08:23:45 -04:00
677ad10e07 Pids-limit should only be set if the user set it
Currently we are sending over pids-limits from the user even if they
never modified the defaults.  The pids limit should be set at the server
side unless modified by the user.

This issue has led to failures on systems that were running with cgroups V1.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-10 12:46:16 -04:00
8489dc4345 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules.  While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
`github.com/containers/libpod/v2`.  The renaming of the imports
was done via `gomove` [1].

[1] https://github.com/KSubedi/gomove

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:50:12 +02:00
c51c593ff6 Re-add resource limit warnings to Specgen
These were part of Podman v1.9, but were lost in the transition
to using Specgen to create containers. Most resource limits are
checked via the sysinfo package to ensure they are safe to use
(the cgroup is mounted, kernel support is present, etc) and
removed if not safe. Further, bounds checks are performed to
ensure that values are valid.

Ensure these warnings are printed client-side when they occur.
This part is a little bit gross, as it happens in pkg/infra and
not cmd/podman, which is largely down to how we implemented
`podman run` - all the work is done in pkg/infra and it returns
only once the container has exited, and we need warnings to print
*before* the container runs. The solution here, while inelegant,
avoid the need to extensively refactor our handling of run.

Should fix blkio-limit warnings that were identified by the FCOS
test suite.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-16 17:32:01 -04:00
10ace87ca9 Fix handling of ThrottleWriteIOPSDevice
This is causing the UBuntu tests to fail.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-05 08:11:37 -04:00
a4c607cc71 set binding tests to required
some small fix ups for binding tests and then make them required.

update containers-common

V2 bindings tests were failing because of changes introduced in commit
a2ad5bb.

Fix some typos.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>

in the case where the specgen attribute for Env and Labels are nil, we should should then make the map IF we have labels and envs that need to be added.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-08 09:05:37 -05:00
99bdafba99 podman: split env variables in env and overrides
There are three different priorities for applying env variables:

1) environment/config file environment variables
2) image's config
3) user overrides (--env)

The third kind are known to the client, while the default config and image's
config is handled by the backend.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-07 14:16:50 -04:00
23be7b5049 Merge pull request #6024 from baude/v2checkmediatypew
check image media/manifest type for healthchecks
2020-04-28 19:21:50 +02:00
a255075fe8 check image media/manifest type for healthchecks
before looking up a healthcheck in an image, check to make sure it is a dockerv2schema image.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-28 11:49:58 -05:00
a9aa9e2f78 pkg, specgen: do not hardcode user=0 in the config if not specified
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-28 15:25:59 +02:00
67ec4e1d27 Improve Entrypoint and Command support
We should not be overwriting the Specgen's Command and Entrypoint
when building the final command to pass in the OCI spec. Both of
these will be provided to Libpod for use in `podman inspect` and
committing containers, and both must be set to the user's input,
not overwritten by the image if unset.

Fix this by moving command generation into OCI spec generation
and not modifying the SpecGenerator when we do so.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-04-27 13:13:21 -04:00
1cd484e13f specgen: read healthchecks from the image
if there is no healthcheck configuration specified, read it from the
image.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-27 11:22:27 +02:00
a3acc4f977 podman: add support for --rootfs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-24 12:56:20 +02:00
1cd2b746d0 Modify namespace generation code for specgen
Namespaces have now been changed to properly handle all cases.
Spec handling code for namespaces was consolidated in a single
function.

Still missing:
- Image ports
- Pod namespaces likely still broken in Podmanv2

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-04-21 14:38:52 -04:00
224a5ce51e add entrypoint from image where needed
if the image specifies both the image and entrypoint, we need to account for that and preprend the entrypoint to the command.  this only happens if no user command and entrypoint were supplied.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-21 09:15:21 -05:00
75fdb753dd Handle annotations passed in via the client
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-21 05:18:39 -04:00
eb101936e6 Handle Linux Capabilities correctly
If user sets capabilities list we need handle minimal capabilities.

Also handle seccomp-policy being passed in.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 15:50:46 -04:00
a2ad5bb9e1 Add functions to return image informations
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 15:50:46 -04:00
ba430bfe5e podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-16 12:04:46 -05:00