539 Commits

Author SHA1 Message Date
127a8060ab Ignore docker's end point config when the final network mode isn't bridge.
Closes #21754

Signed-off-by: Romain Geissler <romain.geissler@amadeus.com>
2024-02-23 21:11:25 +00:00
a3a1b44c31 libpod/events: Update event time format and add timeNano
Add new event type in cmd/podman to better match the docker format.

Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-02-22 11:32:48 +01:00
45b701b125 chore(deps): update dependency setuptools to ~=69.1.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-02-13 19:38:50 +00:00
dbfa201c9a new testimage and systemd-image
Simply because it's been a while since the last testimage
build, and I want to confirm that our image build process
still works.

Added /home/podman/healthcheck. This saves us having to
podman-build on each healthcheck test. Removed now-
unneeded _build_health_check_image helper.

testimage: bump alpine 3.16.2 to 3.19.0

systemd-image: f38 to f39
  - tzdata now requires dnf **install**, not reinstall
    (this is exactly the sort of thing I was looking for)

PROBLEMS DISCOVERED:
  - in e2e, fedoraMinimal is now == SYSTEMD_IMAGE. This
    screws up some of the image-count tests (CACHE_IMAGES).

  - "alter tarball" system test now barfs with tar < 1.35.

TODO: completely replace fedoraMinimal with SYSTEMD_IMAGE
in all tests.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2024-02-09 05:26:07 -07:00
6e0decbe03 Send container stats over API on a per-interface basis
This mirrors how the Docker API handles things, allowing us to be
more compatible with Docker and more verbose on the Libpod API.
Stats are given as per network interface in the container, but
still aggregated for `podman stats` and `podman pod stats`
display (so the CLI does not change, only the Libpod and Compat
APIs).

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-06 17:05:07 -05:00
b028f6aa75 add new libpod/images/$name/resolve endpoint
Podman Desktop [1] is looking into improving the user experience which
requires to know the source of an image.  Consider the user triggers an
image pull and Podman Desktop wants to figure out whether the image name
refers to a Red Hat registry, for instance, to prompt installing the RH
auth extension.

Since the input values of images may be a short name [2], Podman Desktop
has no means to figure out the (potential) source of the image.  Hence,
add a new `/resolve` endpoint to allow external callers to figure out
the (potential) fully-qualified image name of a given value.

With the new endpoint, Podman Desktop can ask Podman directly to resolve
the image name and then make an informed decision whether to prompt the
user to perform certain tasks or not.  This for sure can also be used
for any other registry (e.g., Quay, Docker Hub).

[1] https://github.com/containers/podman-desktop/issues/5771
[2] https://www.redhat.com/sysadmin/container-image-short-names

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2024-01-31 16:20:16 +01:00
3e6bfb6e99 Update module github.com/docker/docker to v25
[NO NEW TESTS NEEDED]

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2024-01-24 13:21:28 +01:00
126670d5dd Fix push endpoint stream
The push binding endpoint wasn't actually writing the
output data to the stream when quiet=false and there
was no push error.
Do not hard code quiet=true anymore, take into account the
user input.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-12-13 13:01:21 -05:00
7f4b0f2087 apiv2 tests: fix race
Test flaking because (I think) one-second resolution isn't
good enough for --since. Use NS resolution.

Also, more test-name cleanup: strip off timestamps in 'since='.
This yields consistent test names in logs, which makes it easier
for me to categorize flakes.

Fixes: #20896

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-12-04 09:18:25 -07: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
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
75638a72a8 If API calls for kube play --replace, then replace pod
Currently if user specifies podman kube play --replace, the
pod is removed on the client side, not the server side.  If
the API is called with replace=true, the pod was not being removed
and this called the API to fail. This PR removes the pod if it
exists and the caller specifies replace=true.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-22 13:31:24 -05:00
a6510d9310 Merge pull request #20725 from ashley-cui/updatemain
Bump main to 5.0.0-dev
2023-11-21 13:05:18 +00:00
be24633300 Bump to v5.0.0-dev
Signed-off-by: Ashley Cui <acui@redhat.com>
2023-11-20 15:10:17 -05:00
e75fbe54e2 Update dependency setuptools to v69
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-20 18:13:43 +00:00
c13b8e3c9c compat API: fix image-prune --all
Docker deals with the --all flag on the client side while Podman does it
on the server side.  Hence, make sure to not set the dangling filter
with two different values in the backend.

Fixes: #20469
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-25 10:58:00 +02:00
ed58ea7849 Merge pull request #20422 from sstosh/api-skip-cgroupv1
test/apiv2: adapt apiv2 test on cgroups v1 environment
2023-10-24 11:23:51 +00:00
2e57746ffd test/apiv2: adapt apiv2 test on cgroups v1 environment
Some apiv2 tests are now support on cgroups v1 environment.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-10-24 11:52:03 +09:00
6d99cb5cd6 test fixes for c/common tag chnages
Tag now does a prepend internally instead of append with the names. Thus
the order changed which needs some test changes.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-23 15:45:46 +02:00
02757ab20d Merge pull request #20391 from sstosh/nanocpu-api-test
test/apiv2/20-containers.at: fix NanoCPUs tests on cgroups v1
2023-10-18 13:39:18 +00:00
a1982c043d Merge pull request #20365 from p-fruck/fix/api-compat-network-connected
fix(API): Catch ErrNetworkConnected for compat
2023-10-18 08:55:31 +00:00
c65d1c02b9 test/apiv2/20-containers.at: fix NanoCPUs tests on cgroups v1
* rootful: NanoCpus needs to set more than 10000000 on cgroups v1.
* rootless: Resource limits that include NanoCPUs are not supported and ignored.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2023-10-18 16:56:18 +09:00
ad53190253 fix(api): Ensure compatibality for network connect
When trying to connect a container to a network and the connection
already exists, an error should only be raised if the container is
already running (or is in the `ContainerStateCreated` transition)
to mimic the behavior of Docker as described here:
https://github.com/containers/podman/pull/15516#issuecomment-1229265942
For running and connected containers 403 is returned which fixes #20365

Signed-off-by: Philipp Fruck <dev@p-fruck.de>
2023-10-17 22:56:32 +02:00
b9f2c4d171 fix: pull error response docker rest api compatibility
This is related to the issue #20013

Signed-off-by: Gabriel Pozo <jackgris2@gmail.com>
2023-10-13 20:19:18 -03:00
8b46e852ef api: add compatMode paramenter to libpod's pull endpoint
Add a new `compatMode` parameter to libpod's pull endpoint. If set, the
streamed JSON payload is identical to the one of the Docker compat
endpoint and allows for a smooth integration into existing tooling such
as podman-py and Podman Desktop, some of which already have code for
rendering the compat progress data.

We may add a libpod-specific parameter in the future which will stream
differnt progress data.

Fixes: issues.redhat.com/browse/RUN-1936?
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-11 10:58:05 +02:00
d18369ee88 Check for image with /libpod/containers/create
The libpod containers create endpoint wasn't checking whether
the image existed before creating the container. If the image
doesn't exist, it should return a 404 status code but it was
failing and returning a 500 status code.
This fix matches the behavior of the compat endpoint.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-10-09 13:07:24 -04:00
98e6dda697 Add label! filter and tests to containers and pods
Thanks to Ed Santiago <santiago@redhat.com> for tests.

Signed-off-by: xtex <xtexchooser@duck.com>
2023-09-16 18:46:33 +08:00
1211518e82 chore(deps): update dependency setuptools to ~=68.2.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-07 02:07:32 +00:00
94969a063a Merge pull request #19768 from chnrxn/patch-1
/_ping handler: return OSType http header
2023-08-29 13:25:18 +02:00
8bda49608f Merge pull request #19696 from Luap99/api-stream-format
api docs: document stream format
2023-08-28 19:43:24 +02:00
1b45fd7239 /_ping handler: return OSType http header
The docker client expects to read the OSType header from the `/_ping` response in order to determine the OS type of the server, for example, when running `docker run --device=/dev/fuse ...`

https://github.com/moby/moby/blob/master/client/ping.go#L57

Signed-off-by: chnrxn <cohawk@yahoo.com>
2023-08-28 22:28:16 +08:00
584c1e70d0 Merge pull request #19704 from rhatdan/timeout
Set StopTimeout for compat API if not set by client
2023-08-25 05:28:26 -04:00
f32e954b8a Set StopTimeout for service-container started under podman kube play
Fixes: https://github.com/containers/podman/issues/19139

Service containers are defaulting to 0 seconds for Timeout rather then
the settings in containers.conf.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-08-24 13:24:41 -04:00
d2ec127c13 Set StopTimeout for compat API if not set by client
Currently containers created via DOCKER API without specifying
StopTimeout are defaulting to 0 seconds. This change should
default them to setting in containers.conf normally 10 seconds.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-08-24 13:24:41 -04:00
7c9c969815 API attach: return vnd.docker.multiplexed-stream header
The attach API used to always return the Content-Type
`vnd.docker.raw-stream`, however docker api v1.42 added the
`vnd.docker.multiplexed-stream` type when no tty was used.

Follow suit and return the same header for docker api v1.42 and libpod
v4.7.0. This technically allows clients to make a small optimization as
they no longer need to inspect the container to see if they get a raw or
multiplexed stream.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-08-24 16:22:28 +02:00
60e58f0594 test/apiv2/60-auth.at: use doesnotexists.podman.io
`exist.io` actually does exist and is not under our control.  To prevent
flakes, change it to something on `podman.io`.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-24 16:22:02 +02:00
6a3f09e8a7 Update dependency setuptools to ~=68.1.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-15 20:35:31 +00:00
f33b01b731 fix: Docker API compatible bool deserialization
In Docker anything but "", "0", "no", "false", "none" (ignoring case) is considered to be true.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2023-08-14 15:09:14 +02:00
4cb2d48ca4 Revert "compat,build: pull must accept string"
This reverts commit 5b148a0a68360892f57603b77e73c69e32fb7b7e.

Reverting to treating the `pull` query parameter as a boolean.
Because of deceiving Docker API documentation it was assumed that the
parameter is pull-policy, however that is not true. Docker does treat
`pull` as a boolean. What is interesting is that Docker indeed accepts
strings like `always` or `never` however Docekr both of these strings
treat as `true`, not as pull-policy. As matter of the fact it seems
there is no such a thing as pull-policy in Docker.

More context https://github.com/containers/podman/issues/17778#issuecomment-1673931925

Signed-off-by: Matej Vasek <mvasek@redhat.com>
2023-08-14 15:01:53 +02:00
1e54539432 Add support for passing container stop timeout as -1 (infinite)
Compat api for containers/stop should take -1 value

Add support for `podman stop --time -1`
Add support for `podman restart --time -1`
Add support for `podman rm --time -1`
Add support for `podman pod stop --time -1`
Add support for `podman pod rm --time -1`
Add support for `podman volume rm --time -1`
Add support for `podman network rm --time -1`

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-08-04 08:36:45 -04:00
f2794f9a82 API: kill: return 409 on invalid state
If the container isn't running, make sure to return 409 as specified in
the Docker API [1] and the Podman reference.

[1] https://docs.docker.com/engine/api/v1.43/#tag/Container/operation/ContainerKill

Fixes: #19368
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-07-31 11:17:58 +02:00
bb72016f58 Merge pull request #19066 from Luap99/ps
top: do not depend on ps(1) in container
2023-07-14 13:17:59 +02:00
eb2bf7a075 Merge pull request #19183 from eriksjolund/add_missing_return
Add missing return after utils.InternalServerError()
2023-07-13 15:53:48 +02:00
2b2c4453f1 Fix container errors not being sent via pod removal API
When I reworked pod removal to provide more detailed errors
(including per-container errors, not just a single multierror
with all errors squashed), I made it part of the struct returned
by the REST API and assumed that would be enough to get errors
through to clients. Unfortunately, in case of an overarching
error removing the pod (as any error with any container would
cause), we don't send the response struct that would include the
container errors - we just send a standardized REST error. We
could work around this with custom, potentially backwards
incompatible error handling for the REST pod delete endpoint, or
we could just do what was done before, and package up all the
errors in a multierror to send to the other side. Of those
options, the multierror seems far simpler.

Fixes #19159

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-07-12 14:50:15 -04:00
6ec261e7ac Add missing return after utils.InternalServerError()
Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2023-07-12 20:47:16 +02:00
0dcfe6e069 Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-07-11 16:44:22 -04:00
597ebeb60f top: do not depend on ps(1) in container
This ended up more complicated then expected. Lets start first with the
problem to show why I am doing this:

Currently we simply execute ps(1) in the container. This has some
drawbacks. First, obviously you need to have ps(1) in the container
image. That is no always the case especially in small images. Second,
even if you do it will often be only busybox's ps which supports far
less options.

Now we also have psgo which is used by default but that only supports a
small subset of ps(1) options. Implementing all options there is way to
much work.

Docker on the other hand executes ps(1) directly on the host and tries
to filter pids with `-q` an option which is not supported by busybox's
ps and conflicts with other ps(1) arguments. That means they fall back
to full ps(1) on the host and then filter based on the pid in the
output. This is kinda ugly and fails short because users can modify the
ps output and it may not even include the pid in the output which causes
an error.

So every solution has a different drawback, but what if we can combine
them somehow?! This commit tries exactly that.

We use ps(1) from the host and execute that in the container's pid
namespace.
There are some security concerns that must be addressed:
- mount the executable paths for ps and podman itself readonly to
  prevent the container from overwriting it via /proc/self/exe.
- set NO_NEW_PRIVS, SET_DUMPABLE and PDEATHSIG
- close all non std fds to prevent leaking files in that the caller had
  open
- unset all environment variables to not leak any into the contianer

Technically this could be a breaking change if somebody does not
have ps on the host and only in the container but I find that very
unlikely, we still have the exec in container fallback.

Because this can be insecure when the contianer has CAP_SYS_PTRACE we
still only use the podman exec version in that case.

This updates the docs accordingly, note that podman pod top never falls
back to executing ps in the container as this makes no sense with
multiple containers so I fixed the docs there as well.

Fixes #19001
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2215572

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-07-10 13:32:55 +02:00
d0505d6bac pkg/api: top return error to client
Wait before sending status code 200 for the first top call and if that
fails return a proper error code.

This was leading to some confusion in [1] because podman just reported
200 but did not wirte anything back.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2215572

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-23 16:48:57 +02:00
63dfe842bb compat API create/pull: fix error handling
Make sure that the create endpoint does not always return 200 even in
case of a failure.  Some of the code had to be massaged since encoding a
report implies sending a 200.

Fixes: #15828
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-21 16:37:27 +02:00
d545418945 compat API push: fix error handling
Make sure that the push endpoint does not always return 200 even in case
of a push failure.  Some of the code had to be massaged since encoding a
report implies sending a 200.

Fixes: #18751
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-06-21 16:35:55 +02:00