316 Commits

Author SHA1 Message Date
8a8bae8299 Refactor API version values
* API-Version header now Major.Minor to support tools parsing this
   header
 * Libpod Version updated to 2.0.0 to reflect changes in API field
   values
 * API-Version and Libpod-API-Version headers are now included in all
   results

Fixes #7327

 * Header support tested against goland 2020.2 and
    https://www.jetbrains.com/help/idea/docker.html plugin

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-09-15 11:29:45 -07:00
0be5836e49 Merge pull request #7637 from vrothberg/fix-7263
events endpoint: header: do not wait for events
2020-09-15 17:19:45 +02:00
0b7cb2c6b2 events endpoint: header: do not wait for events
Do not wait for events to occur before writing the OK header.
Events can take an unknown amount of time to occur and clients
do not need to wait until then to know if the connection is
good.

Fixes: #7263
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-15 14:28:38 +02:00
146c68f3ac Refactor API build endpoint to be more compliant
* Refactor/Rename channel.WriteCloser() to encapsulate the channel
* Refactor build endpoint to "live" stream buildah output channels
  over API rather then buffering output
* Refactor bindings/tunnel build because endpoint changes
  * building tar file now in bindings rather then depending on
    caller
* Cleanup initiating extra image engine
* Remove setting fields to zero values (less noise in code)
* Update tests to support remote builds

Fixes #7136
Fixes #7137

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-09-14 13:46:59 -07:00
526f01cdf5 Fix up errors found by codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-11 06:14:25 -04:00
3d33923374 Merge pull request #7536 from Luap99/api-network-filter
APIv2 Add network list filtering
2020-09-10 10:15:01 -04:00
9c4c883d79 Merge pull request #7572 from vrothberg/fix-7135
remote kill: don't wait for the container to stop
2020-09-09 12:22:08 -04:00
1b2b068ce8 Merge pull request #7569 from zhangguanzhang/fix-apiv2-top-response-two-value
fix APIv2 pods top of non-exist pod gets two response value
2020-09-09 09:12:40 -04:00
0533bc3588 compat kill: only wait for 0 signal and sigkill
Docker does not wait unconditionally.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-09 14:55:42 +02:00
fce2eaa6ca remote kill: don't wait for the container to stop
Invert the branch logic to match the comment.  Docker seems to wait for
the container while Podman does not.

Enable the remote-disabled system test as well.

Fixes: #7135
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-09 14:38:28 +02:00
a4ffed91da fix APIv2 pods top of non-exist pod gets two response value
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-09-09 18:50:17 +08:00
7fea46752c support multi-image (docker) archives
Support loading and saving tarballs with more than one image.
Add a new `/libpod/images/export` endpoint to the rest API to
allow for exporting/saving multiple images into an archive.

Note that a non-release version of containers/image is vendored.
A release version must be vendored before cutting a new Podman
release.  We force the containers/image version via a replace in
the go.mod file; this way go won't try to match the versions.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-08 08:47:19 +02:00
5b8f3f2f1f APIv2 Add network list filtering
Add the filter option to the libpod endpoint.
Add support for the name filter on the docker endpoint.

Add apiv2 tests for the network list endpoints.
Enable podman network integration tests for remote.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-07 15:39:41 +02:00
ebfea2f4f8 APIv2 add generate systemd endpoint
Add support for generating systemd units
via the api and podman-remote.

Change the GenerateSystemdReport type to return the
units as map[string]string with the unit name as key.

Add `--format` flag to `podman generate systemd`
to allow the output to be formatted as json.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-02 22:06:19 +02:00
97780a110b Merge pull request #7436 from rhatdan/variant
Add support for image pull overrides
2020-08-28 16:02:56 -04:00
3c6603a2f8 Add support for variant when pulling images
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-28 09:36:11 -04:00
580c39fea8 Ensure pod REST API endpoints include ctr errors
The APIv2 pod endpoints that operate on multiple containers, such
as Start, Kill, Pause, Unpause, do not report errors encountered
by individual containers, because they incorrectly assume that
any error is fatal. The documentation for the Libpod API calls
notes, however, that ErrPodPartialFail will *always* be returned
if any container failed; so we need to ignore that error and
continue to collating and returning container errors.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-27 15:04:22 -04:00
b13af4537f Merge pull request #7451 from mheon/fix_7195
Send HTTP Hijack headers after successful attach
2020-08-27 12:57:33 -06:00
2ea9dac5e1 Send HTTP Hijack headers after successful attach
Our previous flow was to perform a hijack before passing a
connection into Libpod, and then Libpod would attach to the
container's attach socket and begin forwarding traffic.

A problem emerges: we write the attach header as soon as the
attach complete. As soon as we write the header, the client
assumes that all is ready, and sends a Start request. This Start
may be processed *before* we successfully finish attaching,
causing us to lose output.

The solution is to handle hijacking inside Libpod. Unfortunately,
this requires a downright extensive refactor of the Attach and
HTTP Exec StartAndAttach code. I think the result is an
improvement in some places (a lot more errors will be handled
with a proper HTTP error code, before the hijack occurs) but
other parts, like the relocation of printing container logs, are
just *bad*. Still, we need this fixed now to get CI back into
good shape...

Fixes #7195

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-27 12:50:22 -04:00
fa6ba68026 fix apiv2 will create containers with incorrect commands
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-24 23:07:30 +08:00
fb4977b936 fix /libpod/pods/json returns null when there are no pods
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-21 17:48:14 +08:00
c4b2078508 Clean up pods before returning from Pod Stop API call
This should help alleviate races where the pod is not fully
cleaned up before subsequent API calls happen.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-17 11:04:26 -04:00
569854d634 Unconditionally retrieve pod names via API
The ListContainers API previously had a Pod parameter, which
determined if pod name was returned (but, notably, not Pod ID,
which was returned unconditionally). This was fairly confusing,
so we decided to deprecate/remove the parameter and return it
unconditionally.

To do this without serious performance implications, we need to
avoid expensive JSON decodes of pod configuration in the DB. The
way our Bolt tables are structured, retrieving name given ID is
actually quite cheap, but we did not expose this via the Libpod
API. Add a new GetName API to do this.

Fixes #7214

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-10 10:15:51 -04:00
3173a18f6f Merge pull request #7215 from vrothberg/flatten-the-curve
images: speed up lists
2020-08-08 07:14:37 -04:00
8827100b98 image list: speed up
Listing images has shown increasing performance penalties with an
increasing number of images.  Unless `--all` is specified, Podman
will filter intermediate images.  Determining intermediate images
has been done by finding (and comparing!) parent images which is
expensive.  We had to query the storage many times which turned it
into a bottleneck.

Instead, create a layer tree and assign one or more images to nodes that
match the images' top layer.  Determining the children of an image is
now exponentially faster as we already know the child images from the
layer graph and the images using the same top layer, which may also be
considered child images based on their history.

On my system with 510 images, a rootful image list drops from 6 secs
down to 0.3 secs.

Also use the tree to compute parent nodes, and to filter intermediate
images for pruning.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-08-07 12:14:11 +02:00
7eca5571dc Merge pull request #7204 from baude/issue7197
Missing return after early exit
2020-08-04 14:16:40 +02:00
246603041c docker-compose uses application/tar
even though the official documentation suggests that application/x-tar should be used for tar files, it seems docker-compose uses application/tar.  we now accept them and issue a warning.

Fixes: #7185

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-03 14:19:21 -05:00
ab77487814 Missing return after early exit
the exists code was plagued by a missing return statement meant to trigger an early exit.

Fixes: #7197

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-03 13:58:41 -05:00
96ece0ca56 Merge pull request #7188 from zhangguanzhang/network-404
API returns 500 in case network is not found instead of 404
2020-08-03 09:13:40 -04:00
41358f5ea0 Merge pull request #7158 from rhatdan/commit
Handle single character images
2020-08-03 09:08:02 -04:00
45b100d21c API returns 500 in case network is not found instead of 404
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-02 22:21:28 +08:00
54256fbe78 Make search --no-trunc work for podman remote
The HTTP API for image search was still lacking support of the NoTrunc
parameter.

Signed-off-by: Ralf Haferkamp <rhafer@suse.com>
2020-07-31 15:39:57 +02:00
bcbb5f9963 API: Fix 'podman image search` missing description
`podman image search` returned wrong results for the image "Description" as
it was mapped to the wrong field ("ID") in the search results.
Basically cherry-picked into the api from
commit cf5c63b5c492e41d72b6e3b6d75b5f39b0a957fd.

Signed-off-by: Ralf Haferkamp <rhafer@suse.com>
2020-07-31 15:39:57 +02:00
0785d6af15 Handle single character images
Currently you can only specify multiple character for image names
when executing podman-remote commit

podman-remote commit a b
Will complete, but will save the image without a name.

podman-remote commit a bb
Works.

This PR fixes and now returns an error if the user doees not specify an
image name to commit to.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-30 17:42:15 -04:00
23294c9cf6 Return NamesHistory when returning remote images
We are returning bogus data in podman-remote images --format json.
This change will match the same data returned my podman images --format json.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-29 14:17:56 -04:00
288ebec6e7 Merge pull request #6909 from rhatdan/podman
Switch all references to github.com/containers/libpod -> podman
2020-07-28 10:12:55 -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
f657e5551e compat/info.go: TrimPrefix(CGroupsVersion, "v")
For compatibility with Docker: 846b7e24ba/api/swagger.yaml (L4528-L4534)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-07-28 18:17:13 +09:00
5ee35ca783 API events: fix parsing error
Fix an error where an absent "filters" parameter led to JSON parsing
errors.

Fixes: #7078
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-27 10:02:55 +02:00
417cc41398 Merge pull request #6742 from maybe-sybr/maybe/apiv2/fix-container-create-with-volumes
APIv2:fix: Get volumes from `Binds` when creating
2020-07-24 17:04:26 +02:00
dea93c27d2 events endpoint: backwards compat to old type
The versions Docker that the compat endpoints currently support are
using another type for the `filters` parameter than later versions
of Docker, which the libpod/events endpoint is also using.

To prevent existing deplopyments from breaking while still achieving
backward compat, we now support both types for the filters parameter.

Tested manually.

Fixes: #6899
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-20 15:05:04 +02:00
d856e87f40 events endpoint: fix panic and race condition
Fix a potential panic in the events endpoint when parsing the filters
parameter.  Values of the filters map might be empty, so we need to
account for that instead of uncondtitionally accessing the first item.

Also apply a similar for race conditions as done in commit f4a2d25c0fca:

	Fix a race that could cause read errors to be masked.  Masking
	such errors is likely to report red herrings since users don't
	see that reading failed for some reasons but that a given event
	could not be found.

Another race was the handler closing event channel, which could lead to
two kinds of panics: double close, send to close channel.  The backend
takes care of that.  However, make sure that the backend stops working
in case the context has been cancelled.

Fixes: #6899
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-20 11:37:05 +02:00
fc81d2acea The compat create endpoint should 404 on no such image
This matches Docker behavior, and will make the Docker frontend
work with `podman system service` (Docker tries to create, then
if that fails with 404 sends a request to pull the image).

Fixes #6960

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-16 14:20:39 -04:00
6535c8b9e8 Fix handling of entrypoint
If a user specifies an entrypoint of "" then we should not use the images
entrypoint.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-14 13:10:03 -04:00
324a02ec60 Fix: Correct connection counters for hijacked connections
This patch fixes connection counters for v2 endpoints

Idletracker was moved to a new package to prevent package cycle.
Hijacking code still remains in wrong place and should be moved
later to isolated package

Signed-off-by: Sami Korhonen <skorhone@gmail.com>
2020-07-09 22:17:27 +03:00
8b07ae3278 Fix: Hijacking v2 endpoints to follow rfc 7230 semantics
After this patch v2 hijacking endpoints, exec/start and
containers/attach follow rfc 7230 specification.

Connection will only be upgraded, if client specifies upgrade
headers:

For tcp connections:

Connection: Upgrade
Upgrade: tcp

For unix socket connections:

Connection: Upgrade
Upgrade: sock

There are currently no checks if upgrade type actually matches with
available protocols. Implementation just protocol that client
requested

Signed-off-by: Sami Korhonen <skorhone@gmail.com>
2020-07-09 22:16:16 +03:00
059bd37511 Merge pull request #6835 from zhangguanzhang/master
fix API: Create container with an invalid configuration
2020-07-09 19:28:38 +02:00
09dc77aedf log API: add context to allow for cancelling
Add a `context.Context` to the log APIs to allow for cancelling
streaming (e.g., via `podman logs -f`).  This fixes issues for
the remote API where some go routines of the server will continue
writing and produce nothing but heat and waste CPU cycles.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-09 15:13:07 +02:00
9fe3153c0c APIv2:fix: Get volumes from Binds when creating
This change ensures that we pull volume bind specification strings from
the correct spot in the POSTed data when creating containers. We should
probably canity check that the mapping keys in `Volumes` are a superset
of the binds listed in `HostConfig.Binds` but this cheap change removes
an annoying behaviour where named volumes or host mount would be
silently replaced with newly created anonymous volumes.

Signed-off-by: Matt Brindley <58414429+maybe-sybr@users.noreply.github.com>
2020-07-09 17:45:12 +10:00
2086e22624 fix API: Create container with an invalid configuration
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-07-09 10:26:04 +08:00