115 Commits

Author SHA1 Message Date
ed930d9d7c Evict containers before removing via V2 API
Fixes #7535

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-09-18 10:05:07 -07:00
0d14d7b715 Merge pull request #7624 from QiWang19/policy-option
Supports import&run--signature-policy
2020-09-16 11:05:33 +02:00
2fcd1d7b4d Supports import&run--signature-policy
Enables podman create, pull, run, import to use --signature-policy option. Set it as hidden flag to be consistent with other commands.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-09-15 16:09:33 -04:00
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
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
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
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
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
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
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
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
41ccc045fb Merge pull request #6852 from skorhone/fix/6803_null_ports
Fix container inspect endpoint returning null for network settings / ports
2020-07-05 14:22:52 -04:00
e5bf56a48d Fix issue #6803 Container inspect endpoint returns null for NetworkSettings/Ports
Implement mapping for NetworkSettings/Ports for Container inspect endpoint

Signed-off-by: Sami Korhonen <skorhone@gmail.com>
2020-07-03 17:20:59 +03:00
22def2e2d9 Merge pull request #6838 from mheon/fix_panic_events
Fix `system service` panic from early hangup in events
2020-07-02 12:36:04 -04:00
9e4cf6ca51 Fix system service panic from early hangup in events
We weren't actually halting the goroutine that sent events, so it
would continue sending even when the channel closed (the most
notable cause being early hangup - e.g. Control-c on a curl
session). Use a context to cancel the events goroutine and stop
sending events.

Fixes #6805

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-02 09:57:39 -04:00
3aa22cb1be APIv2:fix: Handle docker volume force as expected
In response to input regarding the semantic difference for the `force`
parameter for volume removal between Docker and us, this change ensures
that we emulate the Dockr behaviour correctly when this parameter is
specified.

Signed-off-by: Matt Brindley <58414429+maybe-sybr@users.noreply.github.com>
2020-07-02 16:33:19 +10:00
cb61a2d858 APIv2: Add docker compatible volume endpoints
This change implements docker compatibile endpoint for interacting with
volumes. The code is mostly lifted from the `libpod` API handlers but
decodes and constructs data using types defined in the docker API
package.

Some notable support caveats with the current implementation:
  * we don't return the nullable `Status` or `UsageData` keys when
    returning volume information for inspect and create endpoints
  * we don't support filters when pruning
  * we return a fixed `0` for the `SpaceReclaimed` key when pruning
    since we have no insight into how much space was freed from runtime

Signed-off-by: Matt Brindley <58414429+maybe-sybr@users.noreply.github.com>
2020-07-02 16:33:19 +10:00
babc64b44b Fix a bug with APIv2 compat network remove to log an ErrNetworkNotFound instead of nil
Signed-off-by: Maximilian Müller <maxm123@techie.com>
2020-06-27 15:02:55 +02:00
18300573f9 Set syslog for exit commands on log-level=debug
We have a flag, --syslog, for telling logrus to log to syslog as
well as to the terminal. Previously, this flag also set the exit
command for containers to use `--syslog` (otherwise all output
from exit commands is lost). I attempted to replicate this with
Podman v2.0, but quickly ran into circular import hell (the flag
is defined in cmd/podman, I needed it in cmd/podman/containers,
cmd/podman imports cmd/podman/containers already, etc). Instead,
let's just set the syslog flag automatically on
`--log-level=debug` so we log exit commands automatically when
debug-level logs are requested. This is consistent with Conmon
and seems to make sense.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-24 13:09:34 -04:00
b20619e5b0 Allow recursive dependency start with Init()
As part of APIv2 Attach, we need to be able to attach to freshly
created containers (in ContainerStateConfigured). This isn't
something Libpod is interested in supporting, so we use Init() to
get the container into ContainerStateCreated, in which attach is
possible. Problem: Init() will fail if dependencies are not
started, so a fresh container in a fresh pod will fail. The
simplest solution is to extend the existing recursive start code
from Start() to Init(), allowing dependency containers to be
started when we initialize the container (optionally, controlled
via bool).

Also, update some comments in container_api.go to make it more
clear how some of our major API calls work.

Fixes #6646

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-06-18 09:34:04 -04:00
a76bf114d1 Merge pull request #6620 from jgallucci32/api-logs-separate
Move logs functionality to separate file for APIv2
2020-06-17 15:50:05 -04:00
585b14a9f8 Move logs functionality to separate file for APIv2
This simply moves the function for the log handler for
APIv2 to a separate file to be consistent with other parts
of the code base.

Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-17 11:48:53 -07:00
65c3a56602 fix misc remote build issues
address problem when multiple -t were sent.  and rework remote build's tarball if a context dir is given other than ".".

Fixes: #6578
Fixes: #6577

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-06-17 09:01:43 -05:00
af3c4d88b4 handlers/compat: fix lint error
Fix a lint error of an used parameter.  The error must have sneaked in
with a PR that was merged after the recent linter enablement.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-16 11:11:53 +02:00
6e0cf67874 Merge pull request #6590 from zhangguanzhang/master
Add the missing return in the API handlers' image_build method
2020-06-15 13:17:41 -04:00
200cfa41a4 Turn on More linters
- misspell
    - prealloc
    - unparam
    - nakedret

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-15 07:05:56 -04:00
f9abd33c23 Add the missing return
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-06-12 23:33:09 +08:00