Commit Graph

85 Commits

Author SHA1 Message Date
Valentin Rothberg 593eb7625a golangci: enable goimports
Enable the goimports linter and fix reports.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-03-05 20:03:44 +01:00
Brent Baude 0904873100 rework apiv2 wait endpoint|binding
added the ability to wait on a condition (stopped, running, paused...) for a container.  if a condition is not provided, wait will default to the stopped condition which uses the original wait code paths.  if the condition is stopped, the container exit code will be returned.

also, correct a mux issue we discovered.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-28 09:36:53 -06:00
Brent Baude 306b44380f binding tests for volumes
add binding tests for volumes: inspect(get), create, remove, prune, and list

implement filters ability for volumes

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-27 13:11:42 -06:00
Brent Baude d92b9b8859 more image binding tests
add two additional bindings tests for image usage.

add ability to use search filter on the endpoint.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-23 11:01:21 -06:00
Brent Baude f0df07b593 add more image tests for go bindings
adding more image tests for go bindings.  one big change is that the params were converted from map[string]string to url.values to account for the ability to send []string as query params

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-21 16:11:39 -06:00
Brent Baude ea153c8e2e search endpoint failure correction
when returning an invalid search, a return was omitted triggering a null on the consumer end.

Fixes: #5228

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-21 12:53:39 -06:00
OpenShift Merge Robot 585649df46
Merge pull request #5178 from marusak/expose_cpu
stats: Expose CPU usage in API
2020-02-21 11:04:16 -05:00
OpenShift Merge Robot aae8874204
Merge pull request #5262 from schubter/signal-decode
APIv2: Fixed syscall.Signal not convertable by decoder
2020-02-21 07:33:22 -05:00
OpenShift Merge Robot 3e5699224b
Merge pull request #5251 from sujil02/pod-test
Add test to validate the pod bindings api
2020-02-20 17:06:36 +01:00
Brent Baude d65ff6b3ec apiv2 container create using specgen
this uses the specgen structure to create containers rather than the outdated createconfig.  right now, only the apiv2 create is wired up.  eventually the cli will also have to be done.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-19 15:20:15 -06:00
Sujil02 3db43dcce3 Add test to validate the pod bindings api
Include test to validate pod create, start, stop, restart,
pause, unpause, list, and inspect api bindings.
Also includes bug fixes that resulted in invalid api responses.

Signed-off-by: Sujil02 <sushah@redhat.com>
2020-02-19 16:05:27 -05:00
OpenShift Merge Robot aa1bb0b579
Merge pull request #5259 from schubter/apiv2-create-image
APIv2: Fixed CreateImageFromImage not respecting supplied Tag parameter
2020-02-19 17:30:37 +01:00
Andreas Schubert 3aa32dff1d
Fixed syscall.Signal not convertable by decoder
Signed-off-by: Andreas Schubert <schubter@gmail.com>
2020-02-19 15:04:24 +01:00
Andreas Schubert 1e4129a19d
Fixed typo in KillContainer
Signed-off-by: Andreas Schubert <schubter@gmail.com>
2020-02-19 13:48:10 +01:00
Andreas Schubert 6e5cf818e9
Fixed CreateImageFromImage not respecting supplied Tag parameter
Signed-off-by: Andreas Schubert <schubter@gmail.com>
2020-02-19 10:36:44 +01:00
OpenShift Merge Robot 1bed53b02c
Merge pull request #5247 from schubter/5242
APIv2: fixes decoder issue
2020-02-19 03:45:02 +01:00
Andreas Schubert 4b96c3b2c8
adds missing query struct tags and exports the fields
Signed-off-by: Andreas Schubert <schubter@gmail.com>
2020-02-18 21:10:55 +01:00
Jhon Honce 024ddda123 Update mux rules to allow slashes in image names
%2F escaping is also supported.
Return better response on bad search terms

Fixes #5229

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-02-18 09:38:37 -07:00
Matej Marusak 98774e1476 stats: Expose CPU usage in API
`stats.CPU` is a number representing CPU usage in percents. It is possible
to calculate it from other exposed fields (once they are implemented
correctly) but why to do it, when this is already calculated.

This does not break API, it just adds another field.

Signed-off-by: Matej Marusak <mmarusak@redhat.com>
2020-02-17 20:05:14 +01:00
Jhon Honce c0c44ae8a3 Fix handler and systemd activation errors
On panic from handler: log warning and stack trace, report
InternalServerError to client

When using `podman system service` make determining the listening endpoint deterministic.

  // When determining _*THE*_ listening endpoint --
  // 1) User input wins always
  // 2) systemd socket activation
  // 3) rootless honors XDG_RUNTIME_DIR
  // 4) if varlink -- adapter.DefaultVarlinkAddress
  // 5) lastly adapter.DefaultAPIAddress

Fixes #5150
Fixes #5151

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-02-17 10:29:32 -07:00
Sascha Grunert 93358ef915
Refactor image tree for API usage
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-02-17 11:12:35 +01:00
OpenShift Merge Robot 92dbcb8841
Merge pull request #5217 from mheon/rework_label_parsing
Rework label parsing
2020-02-15 12:50:48 +01:00
Matthew Heon 36a0ed9702 Rework label parsing
We attempted to share all logic for parsing labels and
environment variables, which on the surface makes lots of sense
(both are formatted key=value so parsing logic should be
identical) but has begun to fall apart now that we have added
additional logic to environment variable handling. Environment
variables that are unset, for example, are looked up against
environment variables set for the process. We don't want this for
labels, so we have to split parsing logic.

Fixes #3854

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-02-14 16:06:20 -05:00
OpenShift Merge Robot 9e9b157aa9
Merge pull request #5214 from baude/apiv2loglibpod
apiv2 libpod container logs
2020-02-14 21:21:35 +01:00
OpenShift Merge Robot ca303586b3
Merge pull request #5216 from baude/bindingstestcache
add caching for binding tests
2020-02-14 20:49:54 +01:00
Brent Baude 08bb9317cb add caching for binding tests
add the ability to cache images instead of pull them.  makes tests faster and less network use when we flip on CI.

Also added list images with filter test

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-14 12:11:23 -06:00
Brent Baude b1034eabe3 apiv2 libpod container logs
wire up containers logs for libpod side of the house, same as compat.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-14 10:18:17 -06:00
Valentin Rothberg 85b7374491 add pkg/signal
Add pkg/signal to deal with parts of signal processing and translating
signals from string to numeric representations.  The code has been
copied from docker/docker (and attributed with the copyright) but been
reduced to only what libpod needs (on Linux).

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-14 15:04:14 +01:00
OpenShift Merge Robot 0c060dace1
Merge pull request #5190 from baude/apiv2cockpit3
filtering behavior correction
2020-02-14 00:32:33 +01:00
OpenShift Merge Robot cd9e6b4143
Merge pull request #5172 from giuseppe/api-fix-cpu-stats
api: fix the CPU stats reported
2020-02-13 15:42:53 +01:00
Brent Baude ce7c9c998c filtering behavior correction
when filtering containers, if a status= is provided as an input filter, then we should override the all to always be true.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-12 16:08:07 -06:00
OpenShift Merge Robot 2281cbdd6d
Merge pull request #5171 from baude/apiv2cockpit2
Fix container filters
2020-02-12 22:43:59 +01:00
Valentin Rothberg 9fbacd8305 api: pull: fix reference parsing
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-12 15:25:25 +01:00
OpenShift Merge Robot be37d144e7
Merge pull request #5175 from baude/apiv2events
apiv2 stream events
2020-02-12 13:28:55 +01:00
Giuseppe Scrivano 510fa4ebc8
stats: add SystemUsage
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-02-12 11:58:29 +01:00
Ed Santiago ba30bb8409 HTTP 304 (NotModified) is not an error!
Even after #5169, my test logs kept showing:

   ERRO[0004] unable to write json: "http: request method or response status code does not allow body"

Cause: overly-helpful code trying to treat condition as an
error and include a diagnostic message. This is forbidden
per rfc2616.

This PR fixes the faulty response, as well as three others
found via:

    $ ack 'Error.*NotMod'  (4 hits total)
    $ ack 'Error.*NoCont'  (no hits)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-11 15:15:20 -07:00
Giuseppe Scrivano 6215e1bb21
api: fix the CPU stats reported
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-02-11 22:24:14 +01:00
OpenShift Merge Robot 4bdfeed5bf
Merge pull request #5169 from edsantiago/apiv2_pod_status_codes
API v2: pods: fix two incorrect return codes
2020-02-11 22:22:55 +01:00
Brent Baude 5b830cca90 apiv2 stream events
the events endpoint should be stream-based.  it also needed to be registered to answer and not produce 404s.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-11 15:00:41 -06:00
OpenShift Merge Robot d34ce1320c
Merge pull request #5083 from vrothberg/v2-libpod-image-endpoints
v2 api: /libpod/images/{import,load,pull}
2020-02-11 21:25:35 +01:00
Brent Baude ad4a92c5e5 Fix container filters
container filters were being double encoded (maybe triple) which resulted in the wrong encoding representation of filters being sent by the go-bindings.  Also, on the server side, Filter needed to be changed to Filter to decode properly. Finally, due to the changed return type of List Containers, the go bindings return values needed to be changed.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-11 12:42:58 -06:00
Ed Santiago bdccdd2265 API v2: pods: fix two incorrect return codes
1) /pods/<X>/exists - is documented to return 204, and that's
    the correct value, but until now it has been returning 200.

 2) /pods/create - return 409 (conflict), not 500, when pod
    already exists

Also: in WriteResponse(), if code is 204 (No Content) or 304
(Not Modified), emit the status code only but no content-type
headers nor content.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-11 10:50:23 -07:00
Brent Baude ddffc865f3 Rewire ListContainers for APIv2 libpod
consumers of the api remarked how they would prefer a more strongly typed data structure from list containers oon the libpod side of things.  for example, events should be consumable and consistent timestamps.  also, for the sake of compatibility, it is helpful to have the json named atttributes for Id to not be ID.

listcontainers on the libpod side no longer strongly uses the the ps cli to obtain information but we do benefit from turning on the ability to list the last X containers, something CLI does not have yet. we also flipped the bit on defaulting to truncated output in the return.

thanks to the efforts of the cockpit team to help us here.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-11 08:14:28 -06:00
Valentin Rothberg 185c82bc80 v2 api: /libpod/images/import
Implement the /libpod/images/import endpoint

Tested manually with curl:
curl -X POST --data-binary "@image.tar" --header "Content-Type: application/x-tar"

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-10 13:18:50 +01:00
Valentin Rothberg 926c9f8fbb v2 api: /libpod/images/load
Implement the /libpod/images/load endpoint.

Tested manually with curl:
curl -X POST --data-binary "@image.tar" --header "Content-Type: application/x-tar"

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-10 13:18:48 +01:00
Valentin Rothberg 76e2a0c5d3 v2 api: /libpod/images/pull
Implement the /libpod/images/pull endpoint and correct the swagger docs.
The reference parameter is mandatory and must either be a
c/image/docker/reference or a reference to the "docker://" transport as
the pull endpoint is meant to only support pulling images from a
registry.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-10 12:36:45 +01:00
Valentin Rothberg 84381df810 swagger: v2: libpod/images/{import,load,pull}
Note: this commit is merely adding swagger documentation and the golang
stubs and types for the proposed endpoints.  The implementation will
follow in separate individual changes in the future.

The ultimate goal is to prevent the libpod API from exposing the rather
complex /images/create endpoint from Docker and split it into easier to
implement, use and comprehend endpoints with a more narrow focus.

 # Import

Add the v2 swagger documentation for the libpod/images/import endpoint.
Note that we have intend to have separate backend and not mix it up with
load since import allows for specifying a URL instead of a local
tarball.

 # Load

Complete the v2 swagger documentation for the libpod/images/load
endpoint.  Note that we are accounting for future plans to be able to
load multiple images from one oci/docker archive by returning an array
of image-load responses.

Also move the (incomplete) implementation of the generic endpoint to the
corresponding package and create a stub for the libpod handler, which
will be implemented once there's an agreement on the proposed API.

 # Pull

Add the v2 swagger documentation for the libpod/images/pull endpoint.
Similar to the load endpoint, we return an array since more than one
image can be pulled when the `all-tags` parameter is set.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-04 10:45:54 +01:00
OpenShift Merge Robot 54926d1b03
Merge pull request #5061 from baude/apiv2swaggerexec
[CI:DOCS]add apiv2 endpoints for exec
2020-02-04 01:39:45 -08:00
Jhon Honce 4d301c8c4f Update /_ping support
* Add swagger support and documentation
* Promote handler as there can only ever be one
* Update swagger tags

Between verbs and paths there are four endpoints for /_ping.  I've
attempted to document them well without four copies of the details.
Time will tell.

Clients will use the headers `Libpod-API-Version` and
`Libpod-Buildha-Version` to determine if they are connecting to a Podman
service or some other compatible engine.

Client calls GET(/_ping):
 * VARLINK engines will fail with error message
 * Compatible engines will return 200 without Libpod headers
 * Podman engines will return 200 and Libpod headers

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-02-03 11:57:54 -07:00
Brent Baude 81296cba82 [CI:DOCS]add apiv2 endpoints for exec
add the openapi/swagger documentation for exec.  The subcommands added are create, inspect, resize, and start.

at the time of this writing, no structure is declared for the inspect response.  once the libpod work for this is complete, we can inherit and swaggerize it.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-03 12:40:01 -06:00