Commit graph

333 commits

Author SHA1 Message Date
Matthew Heon b6775d5d22 Fix manual detach from containers to not wait for exit
At present, when manually detaching from an attached container
(using the detach hotkeys, default C-p C-q), Podman will still
wait for the container to exit to obtain its exit code (so we can
set Podman's exit code to match). This is correct in the case
where attach finished because the container exited, but very
wrong for the manual detach case.

As a result of this, we can no longer guarantee that the cleanup
and --rm functions will fire at the end of 'podman run' - we may
be exiting before we get that far. Cleanup is easy enough - we
swap to unconditionally using the cleanup processes we've used
for detached and rootless containers all along. To duplicate --rm
we need to also teach 'podman cleanup' to optionally remove
containers instead of cleaning them up.

(There is an argument for just using 'podman rm' instead of
'podman cleanup --rm', but cleanup does have different semantics
given that we only ever expect it to run when the container has
just exited. I think it might be useful to keep the two separate
for things like 'podman events'...)

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-02-12 10:14:57 -05:00
baude 3101364a3c podman-remote volume rm
add the ability to remove/delete volumes with the podman remote
client.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-11 20:14:50 -06:00
baude 358da6c8c0 podman-remote volume create
create a volume using the remote client over varlink

Signed-off-by: baude <bbaude@redhat.com>
2019-02-11 14:48:07 -06:00
baude 25a3923b61 Migrate to cobra CLI
We intend to migrate to the cobra cli from urfave/cli because the
project is more well maintained.  There are also some technical reasons
as well which extend into our remote client work.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-08 10:26:43 -06:00
Giuseppe Scrivano 1a8391b914
cleanup: use the correct runtime
make sure "containers cleanup" uses the correct runtime if it was
overriden.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-07 14:59:59 +01:00
OpenShift Merge Robot dab590d13e
Merge pull request #2278 from rhatdan/varlink
Fix handling of memory limits via varlink
2019-02-07 00:34:59 +01:00
OpenShift Merge Robot 74e71c41d2
Merge pull request #2268 from mheon/force_storage_refresh
Unconditionally refresh storage options from config
2019-02-06 23:15:24 +01:00
OpenShift Merge Robot 9644802cd7
Merge pull request #2279 from giuseppe/pts-no-override-if-not-needed
rootless: do not override /dev/pts if not needed
2019-02-06 20:28:15 +01:00
Matthew Heon 33845f8a0f Unconditionally refresh storage options from config
Due to our unconditionally setting some storage options, we
are not always reading storage options from storage.conf. This
can lead to some fields in the storage config (most notably extra
storage options) being ignored, despite being set in
storage.conf.

Resolve this by unconditionally refreshing our storage config
from storage.conf (this was previously only done for rootless
Podman)

Fixes #2217

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-02-06 10:01:43 -05:00
Giuseppe Scrivano e2970ea62d
rootless: do not override /dev/pts if not needed
when running in rootless mode we were unconditionally overriding
/dev/pts to take ride of gid=5.  This is not needed when multiple gids
are present in the namespace, which is always the case except when
running the tests suite with only one mapping.  So change it to check
how many gids are present before overriding the default mount.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-06 15:31:20 +01:00
Daniel J Walsh 3416bb20f2
Fix handling of memory limits via varlink
Currently handlin memory via varlink is hard coded to 0
Changing to
			Memory:            create.Resources.Memory,
			MemoryReservation: create.Resources.Memory_reservation,
			MemorySwap:        create.Resources.Memory_swap,
			MemorySwappiness:  int(create.Resources.Memory_swappiness),
			KernelMemory:      create.Resources.Kernel_memory,
Allows callers to modify these memory settings.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-02-06 06:22:13 -08:00
baude 64c8fb7c24 podman-remote import|export
addition of import and export for the podman-remote client.  This includes
the ability to send and receive files between the remote-client and the
"podman" host using an upgraded varlink connection.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-05 10:05:41 -06:00
Daniel J Walsh 3554bfce98
Merge pull request #2196 from baude/toolbox
Changes to container runlabel for toolbox project
2019-02-05 10:34:40 -05:00
OpenShift Merge Robot 8e79420489
Merge pull request #2143 from QiWang19/continue2108
Fix up `image sign` in PR 2108
2019-02-01 17:12:50 +01:00
OpenShift Merge Robot f0d64a9e3e
Merge pull request #2236 from baude/listcontainermountsmap
Alter varlink API for ListContainerMounts to return a map
2019-02-01 03:23:34 +01:00
baude 735f0de633 Changes to container runlabel for toolbox project
The toolbox project would benefit from a few changes to more closely
resembe the original atomic cli project.  Changes made are:

* only pull image for container runlabel if the label exists in the image
* if a container image does not have the desired label, exit with non-zero

Signed-off-by: baude <bbaude@redhat.com>
2019-01-30 08:44:58 -06:00
OpenShift Merge Robot b01ec95bda
Merge pull request #2225 from cevich/enable_apparmor
Cirrus: Enable AppArmor build and test
2019-01-30 11:23:05 +01:00
baude 656033ca96 podman image prune -- implement all flag
we now, by default, only prune dangling images.  if --all is passed, we
prune dangling images AND images that do not have an associated containers.

also went ahead and enabled the podman-remote image prune side of things.

Fixes: #2192

Signed-off-by: baude <bbaude@redhat.com>
2019-01-29 16:51:48 -06:00
baude 9e22fbf679 Alter varlink API for ListContainerMounts to return a map
We want to return a map of containermounts where the key is container
id and it points to the mountpath.

Issue #2215

Signed-off-by: baude <bbaude@redhat.com>
2019-01-29 16:47:27 -06:00
Valentin Rothberg 18b7009754
apparmor: don't load default profile in rootless mode
AppArmor requires root privileges, so skip loading the default profile
in rootless mode.  Also add a log to ease debugging.

Fixes: #2223
Reported-by: @dmacvicar
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-01-29 10:38:52 -05:00
baude 5c8e7ed0de enable podman-remote version
initial enablement of podman-remote version.  includes add a APIVersion const
that will allow us to check compatibility between host/client when connections
are made.

also added client related information to podman info.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-21 15:23:30 -06:00
OpenShift Merge Robot 74b85098cf
Merge pull request #2142 from giuseppe/expose-ports
rootless: support port redirection from the host
2019-01-20 13:25:37 +01:00
Giuseppe Scrivano f182946bef
rootless: support port redirection from the host
add support for ports redirection from the host.

It needs slirp4netns v0.3.0-alpha.1.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-01-19 20:45:07 +01:00
baude eadaa5fb42 podman-remote inspect
base enablement of the inspect command.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-18 15:43:11 -06:00
Giuseppe Scrivano 8156f8c694
rootless: fix --pid=host without --privileged
When using --pid=host don't try to cover /proc paths, as they are
coming from the /proc bind mounted from the host.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-01-18 17:12:28 +01:00
Daniel J Walsh 0abb757425
Cleanup coverity scan issues
If realloc fails, then buffer will be leaked, this change frees up the buffer.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-15 17:09:15 -05:00
Qi Wang e24167eef9 Fix up image sign in PR 2108
Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-01-15 12:25:10 -05:00
OpenShift Merge Robot 140ae25c4d
Merge pull request #2141 from baude/remotetag
Add darwin support for remote-client
2019-01-13 09:34:33 -08:00
baude e10baba326 podman play kube: add containers to pod
when defining containers, we missed the conditional logic to allow
the container to be defined with "WithPod" and so forth.  I had to
slightly modify the createcontainer process to pass a libpod.Pod
that could override things; use nil as no pod.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-11 14:01:57 -06:00
baude 43c6da22b9 Add darwin support for remote-client
Add the ability to cross-compile podman remote for OSX.

Also, add image exists and tag to remote-client.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-11 11:30:28 -06:00
OpenShift Merge Robot 28c35cab87
Merge pull request #2135 from baude/varlinkprune
Add varlink support for prune
2019-01-11 06:18:29 -08:00
OpenShift Merge Robot 9368c24be6
Merge pull request #2113 from baude/remoteimages
remote-client support for images
2019-01-11 05:54:16 -08:00
baude 7459c48863 Add varlink support for prune
Add the ability to prune unused images using the varlink
API.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-10 15:21:42 -06:00
OpenShift Merge Robot 36d96c19f9
Merge pull request #2131 from mheon/restore_storage_defaults
Use defaults if paths are not specified in storage.conf
2019-01-10 11:58:13 -08:00
OpenShift Merge Robot 4fb6045087
Merge pull request #2108 from QiWang19/from1899
Fix 'image trust' from PR1899
2019-01-10 11:57:59 -08:00
baude c8e3dd8a9c remote-client support for images
Signed-off-by: baude <bbaude@redhat.com>
2019-01-10 13:18:08 -06:00
Matthew Heon 2fe6ada854 Use defaults if paths are not specified in storage.conf
For rootless Podman, if storage.conf exists but does not specify
one or both of RunRoot and GraphRoot, set them to rootless
defaults so we don't end up with an unusable configuration.

Fixes #2125

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-01-10 13:19:51 -05:00
Giuseppe Scrivano 7ba38b375f
createconfig: always cleanup a rootless container
the rootless container storage is always mounted in a different mount
namespace, owned by the unprivileged user.  Even if it is mounted, a
process running in another namespace cannot reuse the already mounted
storage.

Make sure the storage is always cleaned up once the container
terminates.

This has worked with vfs since there is no real mounted storage.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-01-10 13:02:58 +01:00
OpenShift Merge Robot 64627d910b
Merge pull request #2114 from vrothberg/issue-2107
apparmor: apply default profile at container initialization
2019-01-10 03:34:54 -08:00
Qi Wang b01b2a78f4 Fix 'image trust' from PR1899
Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-01-09 17:48:47 -05:00
W. Trevor King 0f6535cf6b libpod/image: Use ParseNormalizedNamed in RepoDigests
Avoid generating
quay.io/openshift-release-dev/ocp-release@sha256@sha256:239... and
similar when the image name is already digest-based [1].  It's not
clear exactly how we get into this state, but as shown by the unit
tests, the new code handles this case correctly (while the previous
code does not).

[1]: https://github.com/containers/libpod/issues/2086

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #2106
Approved by: rhatdan
2019-01-09 22:29:18 +00:00
Valentin Rothberg edb285d176 apparmor: apply default profile at container initialization
Apply the default AppArmor profile at container initialization to cover
all possible code paths (i.e., podman-{start,run}) before executing the
runtime.  This allows moving most of the logic into pkg/apparmor.

Also make the loading and application of the default AppArmor profile
versio-indepenent by checking for the `libpod-default-` prefix and
over-writing the profile in the run-time spec if needed.

The intitial run-time spec of the container differs a bit from the
applied one when having started the container, which results in
displaying a potentially outdated AppArmor profile when inspecting
a container.  To fix that, load the container config from the file
system if present and use it to display the data.

Fixes: #2107
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-01-09 22:18:11 +01:00
W. Trevor King 99e642d940 pkg/hooks/exec: Include failed command in hook errors
For example:

  $ cat /etc/containers/oci/hooks.d/test.json
  {
    "version": "1.0.0",
    "hook": {
      "path": "/bin/sh",
      "args": ["sh", "-c", "echo 'oh, noes!' >&2; exit 1"]
    },
    "when": {
      "always": true
    },
    "stages": ["precreate"]
  }
  $ podman run --rm docker.io/library/alpine echo 'successful container'
  error setting up OCI Hooks: executing [sh -c echo 'oh, noes!' >&2; exit 1]: exit status 1

The rendered command isn't in in the right syntax for copy/pasting
into a shell, but it should be enough for the user to be able to
locate the failing hook.  They'll need to know their hook directories,
but with the previous commits requiring explicit hook directories it's
more likely that the caller is aware of them.  And if they run at a
debug level, they can see the lookups in the logs:

  $ podman --log-level=debug --hooks-dir=/etc/containers/oci/hooks.d run --rm docker.io/library/alpine echo 'successful container' 2>&1 | grep -i hook
  time="2018-12-02T22:15:16-08:00" level=debug msg="reading hooks from /etc/containers/oci/hooks.d"
  time="2018-12-02T22:15:16-08:00" level=debug msg="added hook /etc/containers/oci/hooks.d/test.json"
  time="2018-12-02T22:15:16-08:00" level=debug msg="hook test.json matched; adding to stages [precreate]"
  time="2018-12-02T22:15:16-08:00" level=warning msg="container 3695c6ba0cc961918bd3e4a769c52bd08b82afea5cd79e9749e9c7a63b5e7100: precreate hook: executing [sh -c echo 'oh, noes!' >&2; exit 1]: exit status 1"
  time="2018-12-02T22:15:16-08:00" level=error msg="error setting up OCI Hooks: executing [sh -c echo 'oh, noes!' >&2; exit 1]: exit status 1"

Signed-off-by: W. Trevor King <wking@tremily.us>
2019-01-08 21:06:17 -08:00
W. Trevor King c441d51e05 hooks/exec/runtimeconfigfilter: Log config changes
To make it easier to notice and track down errors (or other surprising
behavior) due to precreate hooks.  With this commit, the logged
messages look like:

  time="2018-11-19T13:35:18-08:00" level=debug msg="precreate hook 0 made configuration changes:
  --- Old
  +++ New
  @@ -18,3 +18,3 @@
     Namespaces: ([]specs.LinuxNamespace) <nil>,
  -  Devices: ([]specs.LinuxDevice) (len=1) {
  +  Devices: ([]specs.LinuxDevice) (len=2) {
      (specs.LinuxDevice) {
  @@ -24,2 +24,11 @@
       Minor: (int64) 229,
  +    FileMode: (*os.FileMode)(-rw-------),
  +    UID: (*uint32)(0),
  +    GID: (*uint32)(0)
  +   },
  +   (specs.LinuxDevice) {
  +    Path: (string) (len=8) "/dev/sda",
  +    Type: (string) (len=1) "b",
  +    Major: (int64) 8,
  +    Minor: (int64) 0,
       FileMode: (*os.FileMode)(-rw-------),
  "
  time="2018-11-19T13:35:18-08:00" level=debug msg="precreate hook 1 made configuration changes:
  --- Old
  +++ New
  @@ -29,3 +29,3 @@
      (specs.LinuxDevice) {
  -    Path: (string) (len=8) "/dev/sda",
  +    Path: (string) (len=8) "/dev/sdb",
       Type: (string) (len=1) "b",
  "

Ideally those logs would include the container ID, but we don't have
access to that down at this level.  I'm not sure if it's worth
teaching RuntimeConfigFilter to accept a *logrus.Entry (so the caller
could use WithFields [1]) or to use a generic logging interface (like
go-log [2]).  For now, I've left the container ID unlogged here.

The spew/difflib implementation is based on stretchr/testify/assert,
but I think the ~10 lines I'm borrowing are probably small enough to
stay under the "all copies or substantial portions" condition in its
MIT license.

[1]: https://godoc.org/github.com/sirupsen/logrus#WithFields
[2]: https://github.com/go-log/log

Signed-off-by: W. Trevor King <wking@tremily.us>
2019-01-08 21:06:17 -08:00
W. Trevor King f6a2b6bf2b hooks: Add pre-create hooks for runtime-config manipulation
There's been a lot of discussion over in [1] about how to support the
NVIDIA folks and others who want to be able to create devices
(possibly after having loaded kernel modules) and bind userspace
libraries into the container.  Currently that's happening in the
middle of runc's create-time mount handling before the container
pivots to its new root directory with runc's incorrectly-timed
prestart hook trigger [2].  With this commit, we extend hooks with a
'precreate' stage to allow trusted parties to manipulate the config
JSON before calling the runtime's 'create'.

I'm recycling the existing Hook schema from pkg/hooks for this,
because we'll want Timeout for reliability and When to avoid the
expense of fork/exec when a given hook does not need to make config
changes [3].

[1]: https://github.com/opencontainers/runc/pull/1811
[2]: https://github.com/opencontainers/runc/issues/1710
[3]: https://github.com/containers/libpod/issues/1828#issuecomment-439888059

Signed-off-by: W. Trevor King <wking@tremily.us>
2019-01-08 21:06:17 -08:00
OpenShift Merge Robot 4f19f1afca
Merge pull request #2076 from rhatdan/storage.conf
If local storage file exists, then use it rather then defau…
2019-01-08 05:55:40 -08:00
OpenShift Merge Robot faa24627bb
Merge pull request #2078 from rhatdan/config.file
Add the configuration file used to setup storage to podman info
2019-01-07 14:27:19 -08:00
OpenShift Merge Robot 8c8d895d66
Merge pull request #2098 from baude/remote
Add ability to build golang remote client
2019-01-07 11:54:55 -08:00
baude 41fb81d074 Add ability to build golang remote client
Add the ability to build a remote client in golang that uses all
the same front-end cli code and output code. The initial limitations
here are that it can only be a local client while the bridge and
resolver code is being written for the golang varlink client.

Tests and docs will be added in subsequent PRs.

Signed-off-by: baude <bbaude@redhat.com>
2019-01-07 12:43:57 -06:00
Daniel J Walsh b367855d5f
Add the configuration file used to setup storage to podman info
Users have no idea what storage configuration file is used to setup
storage, so adding this to podman info, should make it easier to
discover.

This requires a revendor of containers/storage

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-07 10:02:26 -05:00