110 Commits

Author SHA1 Message Date
c51c593ff6 Re-add resource limit warnings to Specgen
These were part of Podman v1.9, but were lost in the transition
to using Specgen to create containers. Most resource limits are
checked via the sysinfo package to ensure they are safe to use
(the cgroup is mounted, kernel support is present, etc) and
removed if not safe. Further, bounds checks are performed to
ensure that values are valid.

Ensure these warnings are printed client-side when they occur.
This part is a little bit gross, as it happens in pkg/infra and
not cmd/podman, which is largely down to how we implemented
`podman run` - all the work is done in pkg/infra and it returns
only once the container has exited, and we need warnings to print
*before* the container runs. The solution here, while inelegant,
avoid the need to extensively refactor our handling of run.

Should fix blkio-limit warnings that were identified by the FCOS
test suite.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-16 17:32:01 -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
63468464e8 Merge pull request #6546 from rhatdan/lint
Turn on golint
2020-06-10 08:42:16 -04:00
4bb43b898d Fixup issues found by golint
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-10 05:49:41 -04:00
817dbdfdf8 Ensure signal validation happens first in pod kill
This fixes an error in the system tests, which expect that when
you try and kill a nonexistent pod with an incorrect signal, you
receive an error about the signal, not the pod.

At the same time, fix a missing return statement in the bindings,
which could also have caused us grief.

Fixes #6540

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-09 14:10:10 -04:00
8c1883721c Fix leak of empty tarball
In cases of trying to export an image, if the image was not found, we leaked an empty tarball or directory depending on the format.

Fixes: #6409

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-06-01 10:07:58 -05:00
c479d63dd6 Merge pull request #6356 from baude/v2copyendpoints
v2 copy endpoints
2020-05-30 05:06:48 -04:00
dc80267b59 compat handlers: add X-Registry-Auth header support
* Support the `X-Registry-Auth` http-request header.

 * The content of the header is a base64 encoded JSON payload which can
   either be a single auth config or a map of auth configs (user+pw or
   token) with the corresponding registries being the keys.  Vanilla
   Docker, projectatomic Docker and the bindings are transparantly
   supported.

 * Add a hidden `--registries-conf` flag.  Buildah exposes the same
   flag, mostly for testing purposes.

 * Do all credential parsing in the client (i.e., `cmd/podman`) pass
   the username and password in the backend instead of unparsed
   credentials.

 * Add a `pkg/auth` which handles most of the heavy lifting.

 * Go through the authentication-handling code of most commands, bindings
   and endpoints.  Migrate them to the new code and fix issues as seen.
   A final evaluation and more tests is still required *after* this
   change.

 * The manifest-push endpoint is missing certain parameters and should
   use the ABI function instead.  Adding auth-support isn't really
   possible without these parts working.

 * The container commands and endpoints (i.e., create and run) have not
   been changed yet.  The APIs don't yet account for the authfile.

 * Add authentication tests to `pkg/bindings`.

Fixes: #6384
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-29 15:39:37 +02:00
5626c2163b V2 verify JSON output is consistent and doesn't drift
$ cd test/apiv2
$ python -m unittest -v test_rest_v1_0_0.TestApi

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-05-28 16:20:29 -07:00
5dfddf04ee v2 copy endpoints
add copy endpoint inputs and outputs.  these endpoints are not implemented yet, nor are any bindings.  this allows us to update this later without having to change our api version.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-26 12:04:20 -05:00
cf5d33807f Merge pull request #6345 from QiWang19/mani-push-test
remote manifest test
2020-05-22 15:47:33 +02:00
a61f9fd547 Removes remote system reset functionality. skip e2e test for remote.
As system reset too dangerous for remote use, deleting the functionality
and the test case.

Signed-off-by: Sujil02 <sushah@redhat.com>
2020-05-22 07:49:55 -04:00
f7dd915acc remote manifest test
Enable remove manifest tests. Skip --purge test because remote does not support it.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-05-21 16:17:39 -04:00
141b34f6be Fix remote integration for healthchecks
the one remaining test that is still skipped do to missing exec function

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-20 14:43:01 -05:00
fa5b33e70b Merge pull request #6211 from baude/v2remoteimagetree
enable remote image tree
2020-05-13 13:38:47 -07:00
3fea2f0a91 enable remote image tree
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-13 09:41:39 -05:00
cf502b99fe enable podman v2 networking for remote client
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-12 13:23:43 -05:00
03c29c357f add podman remote system df
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-05-12 08:35:48 -05:00
1c6ae73a89 Adds tunnel routes for system reset.
Adds tunnel routes for system reset.
Makes forces flag local as options are not propogated down the stack.
Adds relevant test cases and swagger docs.

Signed-off-by: Sujil02 <sushah@redhat.com>
2020-05-11 17:03:32 -04:00
f269be3a31 add {generate,play} kube
Add the `podman generate kube` and `podman play kube` command.  The code
has largely been copied from Podman v1 but restructured to not leak the
K8s core API into the (remote) client.

Both commands are added in the same commit to allow for enabling the
tests at the same time.

Move some exports from `cmd/podman/common` to the appropriate places in
the backend to avoid circular dependencies.

Move definitions of label annotations to `libpod/define` and set the
security-opt labels in the frontend to make kube tests pass.

Implement rest endpoints, bindings and the tunnel interface.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-06 17:08:22 +02:00
7f97896c59 image removal: refactor part 2
Continue the refactoring of image removal.  I didn't manage to break all
the following changes into smaller and easier to digest commits due to
time constraints:

 * Return an error slice instead of a single error. Use multierror only
   in the client/frontend.  Reflect that in the types.

 * Use the batch image removal in the client while preserving the more
   rest-idiomatic single-image removal endpoint.

 * Add a new handler for the single-image removal endpoint to make it
   share the same code as the batch endpoint.

 * Expose bindings for the single and batch endpoints, so we can
   properly test them.

 * Add several convenience functions for error handling to
   pkg/errorhandling.

 * Set the correct error type in libpod to set the exit code to 2 when
   one or more containers are using an image.

 * Massage the bindings tests a bit and tackle compilation errors.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-04 16:01:45 +02:00
4ed125f7b5 Merge pull request #5907 from sujil02/systemprune-v2
Adding system prune for podman v2
2020-04-28 18:11:39 +02:00
f6f7172494 Merge pull request #6000 from mheon/volume_backend_flags
Add support for volumes-from, image volumes, init
2020-04-27 21:53:37 +02:00
ccf009d22e Merge pull request #6001 from baude/v2intload
enable load integration tests
2020-04-27 20:34:39 +02:00
02671a103f Add support for volumes-from, image volumes, init
This should complete Podmanv2's support for volume-related flags.
Most code was sourced from the old pkg/spec implementation with
modifications to account for the split between frontend flags
(volume, mount, tmpfs) and the backend flags implemented here.

Also enables tests for podman run with volumes

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-04-27 13:13:21 -04:00
6db081fc5e enable load integration tests
fix bug where multiple images can be loaded and have to be able to handle the return of multiple names

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-27 10:20:53 -05:00
7ee0f7e14c implement pod stats
Implement pod stats for the local and remote client. Both code paths end
up in infra/abi to allow for code share.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-27 12:00:35 +02:00
5436e31441 Adding system prune for podman v2
Register system prune route, handler to support system prune,
Adds testcase to validate the system prune flow.

Signed-off-by: Sujil02 <sushah@redhat.com>
2020-04-24 15:44:07 -04:00
e66346c7b0 Stop wrapping pull messages
The length and size of our error messages on failure to pull
is huge.  This patch at least eliminates some of the wrapping.
But I think eventually we need to look at containers/image
and see if we can modify the error messages to something a little
more human friendly.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-23 05:31:36 -04:00
09dc701097 podman rmi: refactor logic
While this commit was initially meant to fix #5847, it has turned into a
bigger refactoring which I did not manage to break into smaller pieces:

 * Fix #5847 by refactoring the image-removal logic.

 * Make the api handler for image-removal use the ABI code. This way,
   both (i.e., ABI and Tunnel) end up using the same code.  Achieving
   this code share required to move some code around to prevent circular
   dependencies.

 * Everything in pkg/api (excluding pkg/api/types) must now only be
   accessed from code using `ABISupport`.

 * Avoid imports from entities on handlers to prevent circular
   dependencies.

 * Move `podman system service` logic into `cmd` to prevent circular
   dependencies - it depends on pkg/api.

 * Also remove the build header from infra/abi files.  It will otherwise
   confuse swagger and other tools; errors we cannot fix as go doesn't
   expose a build-tag env variable.

Fixes: #5847
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-21 08:12:25 +02:00
37f3b191d5 Add pod prune for api v2.
Add the ability to prune pods for api v2,
Includes the addition of force flag, for client side prompt.
Update test suite to support this use case.

Signed-off-by: Sujil02 <sushah@redhat.com>
2020-04-17 17:30:58 -04:00
44a8cf8676 Fixes for system tests
Various fixes to protect against regressions in system tests

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-17 13:22:06 -05:00
5def211400 Merge pull request #5842 from baude/v2bloat2
podman v2 remove bloat v2
2020-04-16 10:52:58 -07:00
ba430bfe5e podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-16 12:04:46 -05:00
e154249b46 allow filters to work when listing containers
enable filters when listing containers on the libpod endpoint.

Fixes: #5841

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-16 09:21:44 -05:00
30d2964ff8 v2 bloat pruning phase 2
this is second phase of removing unneeded bloat in the remote client. this is important to be able to reduce the client size as well as possible native compilation for windows/mac.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-15 16:09:27 -05:00
7147187942 v2specgen prune libpod
use libpod only in the specgen/generate package so that the remote clients do not inherit libpod bloat.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-14 20:02:20 -05:00
85c352d8bc Merge pull request #5709 from vrothberg/v2-search
podmanV2: implement search
2020-04-14 14:51:39 +02:00
d8d1aa49d2 v2podman add container init
add the ability to init a container both local and remote

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-13 19:51:20 -05:00
ff52b7524a podmanV2: implement search
Also implement a new libpod endpoint to add more parameters and to
prevent us from converting between slices and maps and make use of
the filter parsing in the image backend.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-09 13:05:19 +02:00
843fa25890 Merge pull request #5716 from baude/v2ps
podmanv2 ps
2020-04-06 22:04:16 +02:00
e20ecc733c refactor info
the current implementation of info, while typed, is very loosely done so.  we need stronger types for our apiv2 implmentation and bindings.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-06 12:45:42 -05:00
b22254dc8b podmanv2 ps
add the ability to list containers

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-06 12:12:59 -05:00
ba64186750 Merge pull request #5689 from sujil02/v2-pod-inspect
podmanv2 pod inspect
2020-04-06 15:23:19 +02:00
6514a5c80e v2podman container create
create a container in podmanv2 using specgen approach.  this is the core implementation and still has quite a bit of code commented out specifically around volumes, devices, and namespaces.  need contributions from smes on these parts.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-03 15:43:03 -05:00
35f5867833 Merge pull request #5672 from baude/v2save
podmanv2 save image
2020-04-03 22:41:18 +02:00
837aad724f podmanv2 save image
add ability to save an image for podman v2

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-03 13:07:35 -05:00
64cade0f71 Merge pull request #5638 from baude/v2containercheck
podmanv2 checkpoint and restore
2020-04-03 20:05:30 +02:00
8a16674722 podmanv2 checkpoint and restore
add the ability to checkpoint and restore containers on v2podman

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-03 09:32:06 -05:00
44a515015c podmanV2: implement push
* Implement `podman-push` and `podman-image-push` for the podmanV2
  client.

* Tests for `pkg/bindings` are not possible at the time of writing as we
  don't have a local registry running.

* Implement `/images/{name}/push` compat endpoint. Tests are not
  implemented for this v2 endpoint.  It has been tested manually.

General note: The auth config extraction from the http header is not
implement for push.  Since it's not yet supported for other endpoints
either, I deferred it to future work.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-02 17:01:32 +02:00