Commit Graph

1344 Commits

Author SHA1 Message Date
openshift-merge-bot[bot] 88b994902d
Merge pull request #21512 from Luap99/pasta-netname-removal
drop support for "pasta" as a network name
2024-02-08 17:17:55 +00:00
Matt Heon 72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

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

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
Matt Heon 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
Paul Holzinger 249474a84e
drop support for "pasta" as a network name
The pasta network mode has been added in podman v4.4 and this causes a
conflict with named networks that could also be called "pasta". To not
break anything we had special logic to prefer the named network over the
network mode. Now with 5.0 we can break this and remove this awkward
special handling from the code.

Containers created with 4.X that use a named network pasta will also
continue to work fine, this chnage will only effect the creation of new
containers with a named network pasta and instead always used the
network mode pasta. We now also block the creation of networks with the
name "pasta".

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-02-05 13:57:24 +01:00
openshift-merge-bot[bot] f7afaf9652
Merge pull request #21455 from vrothberg/resolve-endpoint
add new libpod/images/$name/resolve endpoint
2024-01-31 21:06:57 +00:00
Valentin Rothberg 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
openshift-merge-bot[bot] 1698fa0ad8
Merge pull request #21388 from ashley-cui/healthcheck
Return nil health when inspecting containers without healthchecks
2024-01-31 13:48:36 +00:00
Ashley Cui a1c47f0299 Return nil health when inspecting containers without healthchecks
When inspecting a container that does not define any health check, the health field should return nil. This matches docker behavior.

Signed-off-by: Ashley Cui <acui@redhat.com>
2024-01-30 23:09:13 -05:00
Matt Heon 174631f726 Convert SpecGen values to be nullable where possible
SpecGen is our primary container creation abstraction, and is
used to connect our CLI to the Libpod container creation backend.
Because container creation has a million options (I exaggerate
only slightly), the struct is composed of several other structs,
many of which are quite large.

The core problem is that SpecGen is also an API type - it's used
in remote Podman. There, we have a client and a server, and we
want to respect the server's containers.conf. But how do we tell
what parts of SpecGen were set by the client explicitly, and what
parts were not? If we're not using nullable values, an explicit
empty string and a value never being set are identical - and we
can't tell if it's safe to grab a default from the server's
containers.conf.

Fortunately, we only really need to do this for booleans. An
empty string is sufficient to tell us that a string was unset
(even if the user explicitly gave us an empty string for an
option, filling in a default from the config file is acceptable).
This makes things a lot simpler. My initial attempt at this
changed everything, including strings, and it was far larger and
more painful.

Also, begin the first steps of removing all uses of
containers.conf defaults from client-side. Two are gone entirely,
the rest are marked as remove-when-possible.

[NO NEW TESTS NEEDED] This is just a refactor.

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-01-30 10:42:24 -05:00
renovate[bot] 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
Philip Dubé 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
Tsubasa Watanabe 4f94c96b9b remote: fix podman-remote kube play --publish-all
Fix `podman kube play --publish-all` to work in remote environment.

Signed-off-by: Tsubasa Watanabe <w.tsubasa@fujitsu.com>
2023-12-29 12:41:54 +09:00
Gavin Lam 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
Urvashi Mohnani 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
Erik Sjölund a1cc99dd46 [CI:DOCS] compat api: fix formatting syntax
Reuse text from podman api

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

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2023-12-07 14:27:47 +01:00
Nalin Dahyabhai 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
Miloslav Trmač 4314b1c344 Fix transferring data using tar
Instead of relying on the remote server to create tar files
with the right account IDs (which the remote server doesn't
even know, when the client and server run under different accounts),
have the remote client ignore the account IDs when unpacking.

Then just hard-code 0 in the remote server, so that the remote
server's account identity does not leak in the tar file contents.

Compare https://github.com/containers/image/issues/1627 .

[NO NEW TESTS NEEDED] : https://github.com/containers/podman/pull/18563
suggests that existing tests already cover these code paths / properties.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-11-28 20:44:17 +01:00
Chetan Giradkar 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
Paul Holzinger 386c8d6bfc
swagger: document play kube annotations param
The annotations parameter was not documented, add it.

Fixes #20784

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-11-27 15:42:42 +01:00
Brent Baude 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
Giuseppe Scrivano 33753db47b
vendor: update c/common
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-11-02 19:46:22 +01:00
Daniel J Walsh 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
openshift-ci[bot] 377644640a
Merge pull request #20476 from rhatdan/build
podman build --remote URI Dockerfile should not be treated as file
2023-10-31 07:49:59 +00:00
Daniel J Walsh a1577ec7b0
podman build --remote URI Dockerfile shoud not be treated as file
Podman build --remote is translating https://path as if it was a file
path. This change will leave it as a URL so it can be parsed on the
server side.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-27 15:10:18 -04:00
Daniel J Walsh 91df369ae6
podman kube play --replace should force removal of pods and containers
Fixes: https://github.com/containers/podman/issues/20025

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-27 07:29:53 -04:00
Daniel J Walsh 3ce62d3cc4
Sort kube options alphabetically
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-27 07:25:44 -04:00
Philipp Fruck 0a2aae119e
docs(API): Fix compat network (dis-)connect
The endpoints to (dis-)connect networks from/to a container are
no longer no-ops. Furthermore, the 403 error handled since #20365
has been documented

Signed-off-by: Philipp Fruck <dev@p-fruck.de>
2023-10-24 17:37:17 +02:00
Giuseppe Scrivano f48a706abc
remote: exec: do not leak session IDs on errors
commit fa19e1baa2 partially introduced
the fix, but was merged too quickly and didn't work with remote.

Introduce a new binding to allow removing a session from the remote
client.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-19 11:34:36 +02:00
Daniel J Walsh b72bb11629
Add TERM iff TERM not defined in container when podman exec -t
Fixes: https://github.com/containers/podman/issues/20334

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-18 15:40:52 -04:00
openshift-ci[bot] 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
Philipp Fruck 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
openshift-ci[bot] 91264e7d2e
Merge pull request #19586 from rhatdan/ps
Fix output of podman --remote top
2023-10-17 19:12:27 +00:00
openshift-ci[bot] c909afb883
Merge pull request #20239 from jackgris/docker-api-error-response
fix: pull error response docker rest api compatibility
2023-10-17 18:51:37 +00:00
Daniel J Walsh 9637fed2fd
Fix output of podman --remote top
Allow users to specify

podman-remote top $cid -eo "pid comm"
or
podman-remote top $cid -eo pid,comm

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

didid#	new file:   test/system/085-top.bats

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-16 17:25:10 -04:00
Aditya R 5db3b753af
remote,build: wire unsetlabels
Signed-off-by: Aditya R <arajan@redhat.com>
2023-10-16 15:34:02 +05:30
Gabriel Pozo 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
Valentin Rothberg 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
Valentin Rothberg 76fec12274 api: break out compat image pull
Break out the code for pulling images via the compat API. The goal is to
make this code shareable between the compat and libpod API to allow for
a "compat mode" in the libpod pull endpoint.

[NO NEW TESTS NEEDED] as it should not change behavior.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-11 10:14:14 +02:00
Urvashi Mohnani 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
Giuseppe Scrivano 36bf905181
api: drop debug statement
remove what seems to be a debugging artifact.

[NO NEW TESTS NEEDED]

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-10-09 10:27:39 +02:00
openshift-ci[bot] e9d6ffa8f0
Merge pull request #20252 from vrothberg/privileged
containers.conf: add `privileged` field to containers table
2023-10-07 11:34:45 +00:00
Valentin Rothberg 362eca6691 containers.conf: add `privileged` field to containers table
As requested in containers/podman/issues/20000, add a `privileged` field
to the containers table in containers.conf.  I was hesitant to add such
a field at first (for security reasons) but I understand that such a
field can come in handy when using modules - certain workloads require a
privileged container.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-05 20:14:18 +02:00
Urvashi Mohnani 27f58803de [CI:DOCS] update kube play delete endpoint docs
Update the docs for the DELETE libpod/kube/play endpoint
to mention the resources removed when ran.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-10-04 14:51:14 -04:00
Paul Holzinger 8e5adde0b3
compat API: speed up network list
The network list compat API requires us to include all containers with
their ip addresses for the selected networks. Because we have no network
-> container mapping in the db we have to go through all containers
every time. However the old code did it in the most ineffective way
possible, it quered the containers from the db for each individual
network. The of course is extremely expensive. Now the other expensive
call is calling Inspect() on the container each time. Inspect does for
more than we need.

To fix this we fist query containers only once for the API call, then
replace the inspect call with directly accessing the network status.
This will speed things up a lot!
The reported scenario includes 100 containers and 25 networks,
previously it took 1.5s for the API call not it takes 24ms, that is a
more than a 62x improvement. (tested with curl)

[NO NEW TESTS NEEDED] We have no timing tests.

Fixes #20035

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-20 13:08:42 +02:00
Paul Holzinger 6b7f718b4b
wire in new buildah build options
Add support for --layerLabel.
Support for --cw is only added for the local client. I am not sure how
I would wire this over remote. The current code parse the options in
the frontend which hard codes the Tmpdir field to an incorrect value if
we would json marshal this vie remote API so it would not work in real
remote cases.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-14 11:21:00 +02:00
OpenShift Merge Robot 29f4572f9f
Merge pull request #19783 from mtrmac/ManifestListData-no-deps
Update c/common to remove a dependency on libimage
2023-08-29 14:44:59 +02:00
OpenShift Merge Robot 94969a063a
Merge pull request #19768 from chnrxn/patch-1
/_ping handler: return OSType http header
2023-08-29 13:25:18 +02:00
Miloslav Trmač a3c2d6ad2e Remove a dependency on libimage from pkg/bindings
... by updating for a c/common API change.

[NO NEW TESTS NEEDED]: Only moves unchanged code,
should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-08-29 12:45:55 +02:00
Miloslav Trmač 259ab85943 Remove a dependency on libimage from pkg/api/handlers
pkg/api/handlers is used for type definitions by pkg/bindings,
i.e. podman-remote; a libimage dependency means that podman-remote
would also include libimage.

Instead, move the ImageDataToImageInspect function close to the
only user (and make it private).

[NO NEW TESTS NEEDED]: Only moves unchanged code (apart from a required
warning fix), should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2023-08-28 23:05:30 +02:00
OpenShift Merge Robot 8bda49608f
Merge pull request #19696 from Luap99/api-stream-format
api docs: document stream format
2023-08-28 19:43:24 +02:00