398 Commits

Author SHA1 Message Date
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
4dbfac6cde [CI:DOCS] apiv2 fix volumes not inculded field
Do not use volume from docker since UsageData field is not need. It's nullable in docker API and expensive to add.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-07-29 12:08:51 -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
ba6a182155 Remove 'experimental' from API doc
The v2.0 reference [page](http://docs.podman.io/en/latest/Reference.html)
lists the API as experimental.  Removed that word and reworked the first
paragraph a bit based on verbiage that @mheon put together for the
API intro blog.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-07-25 13:57:40 -04: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
be5219ab95 Merge pull request #7035 from ashley-cui/api_gen
Fix Generate API swagger title/description
2020-07-21 11:21:59 -04:00
5d25d1808a Fix Generate API title/description
generate kube title and descritopn was same as play kube for apiv2 docs

Signed-off-by: Ashley Cui <acui@redhat.com>
2020-07-21 10:03:25 -04: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
cf64e3cad8 Remove hijacked connections from active connections list
StateHijacked is a terminal state. If hijacked connection
is registered as an active connection, connection will
never be unregistered. This causes two issues

First issue is that active connection counters are off.

Second issue is a resource leak caused by connection
object that is stored to a map.

After this patch hijacked connections are no longer
visible in counters. If a counter for hijacked
connections is required, podman must track
connections returned by Hijacker.Hijack()

It might make sense to develop abstraction layer for
hijacking - and move all hijacking related code to a
separate package. Hijacking code is prone to resource
leaks and it should be thoroughly tested.

Signed-off-by: Sami Korhonen <skorhone@gmail.com>
2020-07-09 22:16:07 +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
610118d9bf Add support for Filter query parameter to list images api
Docker api version 1.24 uses a query parameter named Filter
for filtering images by names. In more recent versions of
api name filter is in filters query parameter with other
filters

This patch adds a mapping that translates Filter query
parameter to Filters={"reference": [""]}

Signed-off-by: Sami Korhonen <skorhone@gmail.com>
2020-07-07 13:05:16 +03: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
50157b2d33 Created timestamp returned by imagelist should be in unix format
In the API, we are currently returning the image time of creation
as a string, in time.Time format. The API is for a 64 bit integer
representing Unix time.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-30 13:59:30 -04:00
c2a0ccd394 Merge pull request #6747 from giuseppe/fix-user-volumes
container: move volume chown after spec generation
2020-06-30 12:01:40 -04:00
b32172e20b container: move volume chown after spec generation
move the chown for newly created volumes after the spec generation so
the correct UID/GID are known.

Closes: https://github.com/containers/libpod/issues/5698

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-29 17:58:50 +02:00
cbae41f75f Merge pull request #6763 from maxm123/master
Fix error handling problem in APIv2 network remove
2020-06-29 04:59:34 -04: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
f0ca17650e Ensure umask is set appropriately for 'system service'
We need a umask of 0022 to ensure containers are created
correctly, but we set a different one prior to starting the
server (to ensure the unix socket has the right permissions).
Thus, we need to set the umask after the socket has been bound,
but before the server begins accepting requests.

Fixes #6787

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-26 10:07:20 -04: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
c07df63c45 Merge pull request #6741 from maybe-sybr/maybe/apiv2/fix-volume-create-code
APIv2: Return `StatusCreated` from volume creation
2020-06-24 09:32:39 -04:00
179731bb14 Merge pull request #6738 from maybe-sybr/maybe/apiv2/fix-network-compat-urls
APIv2:fix: Remove `/json` from compat network EPs
2020-06-24 09:29:53 -04:00
3430ca4df0 APIv2: Return StatusCreated from volume creation
The swagdoc in `register_volumes.go` already correctly notes that a 201
should be returned upon success, so we only need to change the handler
to match the spec.

Signed-off-by: Matt Brindley <58414429+maybe-sybr@users.noreply.github.com>
2020-06-24 15:08:20 +10:00
5fbac502bd APIv2:fix: Remove /json from compat network EPs
Signed-off-by: Matt Brindley <58414429+maybe-sybr@users.noreply.github.com>
2020-06-24 12:20:49 +10:00
bfcfdfcb74 APIv2:doc: Fix swagger doc to refer to volumes
Signed-off-by: Matt Brindley <58414429+maybe-sybr@users.noreply.github.com>
2020-06-24 11:37:00 +10:00
2abcd4f1de libpod/containers/json: alias last -> limit
Support both `last` and `limit` for in the containers listing endpoint.
We intended to use `limit` which is also mentioned in the docs, but the
implementation ended up using `last` as the http parameter; likely being
caused by the CLI using `--last`.  To avoid any regression, we decided
for supporting both and aliasing `last`.

Fixes: #6413
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-22 16:55:48 +02: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
70f6cf7ffa Merge pull request #6634 from baude/v2buildfixes
fix misc remote build issues
2020-06-17 15:36:02 -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
78ad57ebd3 Merge pull request #6636 from mheon/add_warnings
Re-add resource limit warnings to Specgen
2020-06-17 16:51:51 +02: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
4fb0f56063 Merge pull request #6638 from jwhonce/issues/6548
[CI:DOCS] Fixes #6548
2020-06-17 11:20:51 +02:00
64d3508a94 [CI:DOCS] Fixes #6548
* Update swagger documentation

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-06-16 15:57:38 -07:00