Commit graph

605 commits

Author SHA1 Message Date
Matthew Heon 42c95eed2c Major rework of --volumes-from flag
The flag should be substantially more durable, and no longer
relies on the create artifact.

This should allow it to properly handle our new named volume
implementation.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-04-04 12:27:20 -04:00
Matthew Heon 7309e38ddd Add handling for new named volumes code in pkg/spec
Now that named volumes must be explicitly enumerated rather than
passed in with all other volumes, we need to split normal and
named volumes up before passing them into libpod. This PR does
this.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-04-04 12:26:29 -04:00
OpenShift Merge Robot 1759eb09e1
Merge pull request #2706 from giuseppe/rootless-single-usernamespace
rootless: single user namespace
2019-04-04 09:21:09 -07:00
OpenShift Merge Robot 756a11c26f
Merge pull request #2819 from openSUSE/cri-o-annotations
Update cri-o annotations
2019-04-04 00:47:46 -07:00
Sascha Grunert 88b0e74e0b
Update registrar unit tests to match them of cri-o
- Add the test framework abstraction
- Update the unit tests to run with ginkgo

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-04-04 08:53:32 +02:00
baude 576a80b0d7 add remote-client diff
the remote client now can run the diff command to report changes,
modifications, and deletions in an image or container.

Signed-off-by: baude <bbaude@redhat.com>
2019-04-03 09:52:38 -05:00
Giuseppe Scrivano 72382a12a7
rootless: use a single user namespace
simplify the rootless implementation to use a single user namespace
for all the running containers.

This makes the rootless implementation behave more like root Podman,
where each container is created in the host environment.

There are multiple advantages to it: 1) much simpler implementation as
there is only one namespace to join.  2) we can join namespaces owned
by different containers.  3) commands like ps won't be limited to what
container they can access as previously we either had access to the
storage from a new namespace or access to /proc when running from the
host.  4) rootless varlink works.  5) there are only two ways to enter
in a namespace, either by creating a new one if no containers are
running or joining the existing one from any container.

Containers created by older Podman versions must be restarted.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-01 15:32:58 +02:00
Giuseppe Scrivano ed326206f2
rootless: remove SkipStorageSetup()
in the few places where we care about skipping the storage
initialization, we can simply use the process effective UID, instead
of relying on a global boolean flag.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-04-01 13:24:04 +02:00
Sascha Grunert 3600596b35
Update cri-o annotations
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-04-01 11:10:54 +02:00
OpenShift Merge Robot 284dea453d
Merge pull request #2797 from giuseppe/rootless-set-sticky
rootless: set sticky bit on rundir
2019-03-29 07:48:12 -07:00
OpenShift Merge Robot 6ab27c6355
Merge pull request #2796 from mheon/fix_cni_multinetwork
Ensure that we make a netns for CNI non-default nets
2019-03-29 04:26:30 -07:00
Giuseppe Scrivano ca38ca49b8
utils: call GetRootlessRuntimeDir once
use a sync.Once to potentially avoid multiple system calls everytime
the function is called.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-29 12:01:13 +01:00
OpenShift Merge Robot fdf979a791
Merge pull request #2786 from giuseppe/change-rootless-env-names
rootless: change env prefix
2019-03-28 17:00:31 -07:00
OpenShift Merge Robot df5b6e29a6
Merge pull request #2784 from QiWang19/digest
fix bug remote-podman images --digests
2019-03-28 16:51:31 -07:00
Matthew Heon e25924f31c Fix lint
Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-03-28 18:01:36 -04:00
Matthew Heon beb263554e Ensure that we make a netns for CNI non-default nets
We accidentally patched this out trying to enable ns:/path/to/ns

This should restore the ability to configure nondefault CNI
networks with Podman, by ensuring that they request creation of a
network namespace.

Completely remove the WithNetNS() call when we do use an explicit
namespace from a path. We use that call to indicate that a netns
is going to be created - there should not be any question about
whether it actually does.

Fixes #2795

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-03-28 17:39:56 -04:00
Giuseppe Scrivano ce0ca0d459
rootless: change env prefix
from _LIBPOD to _CONTAINERS.  The same change was done in buildah
unshare.

This is necessary for podman to detect we are running in a rootless
environment and work properly from a "buildah unshare" session.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-28 17:08:20 +01:00
Valentin Rothberg a5443a532b vendor buildah, image, storage, cni
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-03-28 15:12:26 +01:00
Qi Wang fd7a9c4a96 fix bug remote-podman images --digests
Add `digest` field to Image struct and update API.md
Show image digests when using --digests in podman-remote.

```
$ PODMAN_VARLINK_ADDRESS="tcp:127.0.0.1:1234" sudo bin/podman-remote images --digests
REPOSITORY                  TAG      DIGEST                                                                    IMAGE ID       CREATED       SIZE
docker.io/library/alpine    latest   sha256:d05ecd4520cab5d9e5d877595fb0532aadcd6c90f4bbc837bc11679f704c4c82   5cb3aa00f899   2 weeks ago   5.79 MB
docker.io/library/busybox   latest   sha256:4415a904b1aca178c2450fd54928ab362825e863c0ad5452fd020e92f7a6a47e   d8233ab899d4   5 weeks ago   1.42 MB
```

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-03-27 23:09:35 -04:00
Matthew Heon 5ed62991dc Remove ulele/deepcopier in favor of JSON deep copy
We have a very high performance JSON library that doesn't need to
perform code generation. Let's use it instead of our questionably
performant, reflection-dependent deep copy library.

Most changes because some functions can now return errors.

Also converts cmd/podman to use jsoniter, instead of pkg/json,
for increased performance.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-03-27 20:00:31 -04:00
Matthew Heon 0cd92eae65 Resolve review comments
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-03-27 10:12:18 -04:00
Matthew Heon 236300d028 Add --no-hosts flag to disable management of /etc/hosts
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-03-27 10:12:18 -04:00
Matthew Heon 16a7c7ff82 Add for --dns=none to disable creation of resolv.conf
Support in libpod was added in the previous commit. Wire it into
the frontend here.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-03-27 10:12:18 -04:00
baude 7f2221d48f size is optional for container inspection
on the remote client, if a user wants to know the rootfs size of a
container, a -s should be passed.  this corrects a behavior where size
was shown by default.

Fixes #2765

Signed-off-by: baude <bbaude@redhat.com>
2019-03-26 10:14:58 -05:00
baude e730fc6093 Add "died" event
We have a new event for container 'Exited' which has been renamed to
'died'.

also removed the stream bool from the varlink endpoint for events
because it can be determined by the varlink more value.

Signed-off-by: baude <bbaude@redhat.com>
2019-03-25 10:28:50 -05:00
Daniel J Walsh 71b1062c02
Need to pass the true paramater with --syslog in cobra
Currently cobra can not handle a boolean option without a vailue.

This change fixes an issue if you want syslog information to show up
based on the cleanup call.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-03-20 17:27:51 -04:00
Debarshi Ray 022bb95c8e Export ConmonPidFile in 'podman inspect' for containers
This can help scripts provide a more meaningful message when coming
across issues [1] which require the container to be re-created.

[1] eg., https://github.com/containers/libpod/issues/2673

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2019-03-18 21:03:22 +01:00
OpenShift Merge Robot ea54a1c2f5
Merge pull request #2670 from giuseppe/runtime-write-rootless-conf-before-reload
rootless: write the custom config file before reload
2019-03-18 06:35:39 -07:00
Giuseppe Scrivano 232b46a374
utils: split generation and writing of storage.conf
split the generation for the default storage.conf and when we write it
if not existing for a rootless user.

This is necessary because during the startup we might be overriding
the default configuration through --storage-driver and --storage-opt,
that would not be written down to the storage.conf file we generated.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-17 10:45:51 +01:00
Giuseppe Scrivano ea0b36bcbb
utils: avoid too long tmp directory
or we will easily pass the 108 chars limits for unix paths.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-16 15:17:33 +01:00
baude 5e86acd591 display logs for multiple containers at the same time
add the ability for users to specify more than one container at a time
while using podman logs.  If more than one container is being displayed,
podman will also prepend a shortened container id of the container on
the log line.

also, enabled the podman-remote logs command during the refactoring of
the above ability.

fixes issue #2219

Signed-off-by: baude <bbaude@redhat.com>
2019-03-15 13:41:01 -05:00
Giuseppe Scrivano e6a4bac09e
rootless: use Geteuid instead of Getuid
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-15 10:39:23 +01:00
Giuseppe Scrivano 592a2fd544
rootless: use /tmp/libpod-rundir-$EUID for fallback
when the fallback is in place, the first user creating /tmp/user/$EUID
prevents other users for creating other directories since /tmp/user is
created with mode 0700.

Since there is no way for an unprivileged user to initialize the
/tmp/user directory correctly (we would need it to be owned by root
with the sticky bit set), let's just use /tmp/libpod-rundir-$EUID.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-15 10:39:23 +01:00
OpenShift Merge Robot a65788c876
Merge pull request #2622 from baude/protectdarwin
Add gating tasks
2019-03-13 11:06:43 -07:00
baude c8ca027938 Add gating tasks
to protect against regressions, we need to add a few gating tasks:
 * build with varlink
 * build podman-remote
 * build podman-remote-darwin

we already have a gating task for building without varlink

Signed-off-by: baude <bbaude@redhat.com>
2019-03-13 12:10:35 -05:00
TomSweeneyRedHat 8f418f1568 Vendor docker/docker, fsouza and more #2
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Vendors in fsouza/docker-client, docker/docker and
a few more related. Of particular note, changes to the TweakCapabilities()
function from docker/docker along with the parse.IDMappingOptions() function
from Buildah. Please pay particular attention to the related changes in
the call from libpod to those functions during the review.

Passes baseline tests.
2019-03-13 11:40:39 -04:00
Daniel J Walsh adad93342c
Update vendor of Buildah and imagebuilder
Fixes the testing issues we are hitting.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-03-13 08:21:11 -04:00
OpenShift Merge Robot 883566fbc0
Merge pull request #2562 from baude/healtcheckphase2
healthcheck phase 2
2019-03-12 13:09:13 -07:00
baude 03716cf7f3 healtcheck phase 2
integration of healthcheck into create and run as well as inspect.
healthcheck enhancements are as follows:

* add the following options to create|run so that non-docker images can
define healthchecks at the container level.
  * --healthcheck-command
  * --healthcheck-retries
  * --healthcheck-interval
  * --healthcheck-start-period

* podman create|run --healthcheck-command=none disables healthcheck as
described by an image.
* the healthcheck itself and the healthcheck "history" can now be
observed in podman inspect
* added the wiring for healthcheck history which logs the health history
of the container, the current failed streak attempts, and log entries
for the last five attempts which themselves have start and stop times,
result, and a 500 character truncated (if needed) log of stderr/stdout.

The timings themselves are not implemented in this PR but will be in
future enablement (i.e. next).

Signed-off-by: baude <bbaude@redhat.com>
2019-03-12 14:29:18 -05:00
OpenShift Merge Robot 300b53cffe
Merge pull request #2527 from baude/events
Add event logging to libpod, even display to podman
2019-03-11 18:04:51 -07:00
baude ca1e76ff63 Add event logging to libpod, even display to podman
In lipod, we now log major events that occurr.  These events
can be displayed using the `podman events` command. Each
event contains:

* Type (container, image, volume, pod...)
* Status (create, rm, stop, kill, ....)
* Timestamp in RFC3339Nano format
* Name (if applicable)
* Image (if applicable)

The format of the event and the varlink endpoint are to not
be considered stable until cockpit has done its enablement.

Signed-off-by: baude <bbaude@redhat.com>
2019-03-11 15:08:59 -05:00
Daniel J Walsh de12f45688
Fix SELinux on host shared systems in userns
Currently if you turn on --net=host on a rootless container
and have selinux-policy installed in the image, tools running with
SELinux will see that the system is SELinux enabled in rootless mode.

This patch mounts a tmpfs over /sys/fs/selinux blocking this behaviour.

This patch also fixes the fact that if you shared --pid=host we were not
masking over certin /proc paths.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-03-11 15:17:22 -04:00
OpenShift Merge Robot 6421208e0f
Merge pull request #2583 from giuseppe/rootless-fix-pod-rm
rootless: fix stop and rm when the container is running with uid != 0
2019-03-11 10:01:25 -07:00
OpenShift Merge Robot f5afe88098
Merge pull request #2597 from jwhonce/issue/2016
Initialize field in InfoHost struct
2019-03-11 09:29:19 -07:00
Jhon Honce 55e24c65ce Initialize field in InfoHost struct
Fixes #2016

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-03-11 07:30:32 -07:00
Giuseppe Scrivano af3e73426a
rootless: allow single mappings
we were playing safe and not allowed any container to have less than
65536 mappings.  There are a couple of reasons to change it:

- it blocked libpod to work in an environment where
  newuidmap/newgidmap are not available, or not configured.

- not allowed to use different partitions of subuids, where each user
  has less than 65536 ids available.

Hopefully this change in containers/storage:

https://github.com/containers/storage/pull/303

will make error clearers if there are not enough IDs for the image
that is being used.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-11 14:38:42 +01:00
Giuseppe Scrivano 231129e4dc
rootless: fix pod stop|rm if uid in the container != 0
join the user namespace where the pod is running, so that we can both
manage the storage and correctly send the kill signal to a process
which is not running as root in the namespace.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-11 11:48:28 +01:00
Giuseppe Scrivano f31ba2929b
rootless: support a custom arg to the new process
let the process running as euid != 0 pass down an argument to the
process running in the user namespace.  This will be useful for
commands like rm -a that needs to join different namespaces, so that
we can re-exec separately for each of them.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-11 11:48:25 +01:00
Daniel J Walsh 2f3875d009
Move secrets package to buildah
Trying to remove circular dependencies between libpod and buildah.

First step to move pkg content from libpod to buildah.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-03-08 16:08:44 -05:00
Giuseppe Scrivano cc411dd98f
rootless: propagate errors from info
we use "podman info" to reconfigure the runtime after a reboot, but we
don't propagate the error message back if something goes wrong.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-08 19:42:20 +01:00
OpenShift Merge Robot 614409f644
Merge pull request #2534 from jwhonce/wip/remote_wait
Implement podman-remote wait command and container subcommand
2019-03-06 13:07:52 -08:00
OpenShift Merge Robot 02e2342d20
Merge pull request #2442 from baude/remotepodtop
podman-remote pod top|stats
2019-03-06 12:24:13 -08:00
OpenShift Merge Robot f50715ed25
Merge pull request #2412 from QiWang19/iss2380
Enable specifying directory as device on container with --device
2019-03-06 10:59:56 -08:00
Jhon Honce 8a6758d5fd Implement podman-remote wait command and container subcommand
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-03-06 10:32:01 -07:00
OpenShift Merge Robot c6c0b54c36
Merge pull request #2491 from baude/healtcheckphase1
podman healthcheck run (phase 1)
2019-03-06 09:24:22 -08:00
baude 788f818cc5 podman-remote pod top|stats
this is the final enablement for the pod subcommand.  it includes the
ability to run podman-remote pod top and stats.

Signed-off-by: baude <bbaude@redhat.com>
2019-03-06 11:01:25 -06:00
Qi Wang c90e0ea346 fix bug --device enable specifying directory as device
Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-03-06 10:14:52 -05:00
OpenShift Merge Robot 7418ff988b
Merge pull request #2543 from giuseppe/fix-rootless-s390x-cris
rootless: fix clone syscall on s390 and cris archs
2019-03-06 05:48:27 -08:00
baude 598bde52d0 podman healthcheck run (phase 1)
Add the ability to manually run a container's healthcheck command.
This is only the first phase of implementing the healthcheck.
Subsequent pull requests will deal with the exposing the results and
history of healthchecks as well as the scheduling.

Signed-off-by: baude <bbaude@redhat.com>
2019-03-05 14:03:55 -06:00
OpenShift Merge Robot 3d441b5d96
Merge pull request #2519 from jwhonce/wip/remote_kill
Support podman-remote kill container(s)
2019-03-05 08:52:09 -08:00
Giuseppe Scrivano ca5114faf9
rootless: fix clone syscall on s390 and cris archs
from the clone man page:

  On the cris and s390 architectures, the order of the first two
  arguments is reversed:

           long clone(void *child_stack, unsigned long flags,
                      int *ptid, int *ctid,
                      unsigned long newtls);

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1672714

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-05 17:27:43 +01:00
OpenShift Merge Robot 85b116707b
Merge pull request #2426 from giuseppe/exec-preserve-fds
exec: support --preserve-fds
2019-03-05 05:56:46 -08:00
Jhon Honce 8eb4940081 Support podman-remote kill container(s)
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-03-04 16:37:22 -07:00
OpenShift Merge Robot 4b80517b6a
Merge pull request #2522 from mheon/fix_timestamp_format_logs
Change timestamp format for podman logs
2019-03-04 13:52:21 -08:00
OpenShift Merge Robot 33be9e6845
Merge pull request #2523 from jwhonce/bug/2521
Fix #2521
2019-03-04 12:24:26 -08:00
Jhon Honce ae47a7c47e Fix #2521
* Bad merge against podman stop, restored overwritten code

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-03-04 12:20:37 -07:00
Matthew Heon 29ade7f6af Change timestamp format for podman logs
The Golang standard library implementation of RFC3339Nano will
trim trailing 0s from the nanoseconds portion of timestamps. This
is undesirable for lining everything up nicely during terminal
output. As the Golang developers have not seen fit to give us a
better way, use the one that was proposed on the issue tracker
but rejected.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-03-04 13:43:04 -05:00
OpenShift Merge Robot 34bf58c5db
Merge pull request #2513 from mheon/log_timestamps_newline
Ensure that each log line is newline-terminated
2019-03-04 08:38:18 -08:00
Matthew Heon ff609a5ade Add additional defense against 0-length log segfaults
Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-03-03 23:30:45 -05:00
Matthew Heon 429f2e63a0 When logging with timestamps, append only until newline
When we log time timestamps, don't print a new timestamp for each
input - instead, print one at the start of every line, and then
wait until we hit a newline to print a new timestamp.

This still doesn't exactly mirror the Docker behavior (they don't
print until they receive an entire line, while we print any time
the logs file is appended to - so you can see partial lines being
typed in our system). Also, timestamps are recorded as the start
of a line being typed, as opposed to when the enter key is
pressed (on Docker).

(Worth noting that, while characters are printed as they are
typed, logs does respect the backspace key - so you'll also see
them disappear as the person typing realizes they've made a
mistake and retypes their command).

This is the closest we can get to Docker without major surgery on
the Kubernetes log-printing library, so I'm content to call this
an adequate solution.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-03-03 23:06:32 -05:00
Matthew Heon e372837eb0 Ensure that each log line is newline-terminated
When writing logs with timestamps to the terminal, ensure that
each line is newline-terminated, so we don't end up with an
unreadable mess with timestamps interspersed with the actual
content being displayed.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-03-03 21:13:49 -05:00
Jhon Honce 4d13a80fa4 Support podman-remote stop container(s)
* Clean up adapter code
* Add GetContainersByContext to Varlink API
* Add missing comments
* Restore save command
* Restore error type mapping when using varlink

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-03-02 08:57:20 -07:00
Giuseppe Scrivano 0b34327ad4
exec: support --preserve-fds
Allow to pass additional FDs to the process being executed.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-02 11:45:42 +01:00
Giuseppe Scrivano 23615099e9
rootless, new[ug]idmap: on failure add output
if any of the mapping tools for setting up the user namespace fail,
then include their output in the error message.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-28 16:16:48 +01:00
Giuseppe Scrivano 80bad464f9
secrets: fix fips-mode with user namespaces
When using a user namespace, we create the mount point under
`mountPrefix` so that the uid != 0 can access that directory.

Change the addFIPSModeSecret code to honor that, and also ensure we
are creating the directories with the right ownership.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-27 22:40:38 +01:00
Matthew Heon ffefbda694 Fix build for non-Varlink-tagged Podman
Fixes #2459

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-02-27 10:27:08 -05:00
Matthew Heon f68a243f8e Centralize setting default volume path
No reason to do it in util/ anymore. It's always going to be a
subdirectory of c/storage graph root by default, so we can just
set it after the return.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-02-26 15:44:46 -05:00
Matthew Heon 5511cdc487 Ensure volume path is set appropriately by default
There are some cases where we might not be properly adjusting the
volume path after setting the storage graph root. Ensure that we
always set volume path to be a child of graph root.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-02-26 15:39:13 -05:00
Giuseppe Scrivano 21bc766ee3
volume: do not create a volume if there is a bind
if there is already a bind mount specified for the target, do not
create a new volume.

Regression introduced by 52df1fa7e0

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-26 18:42:04 +01:00
baude 0416b3afc4 podman-remote pod pause|unpause|restart
enable the ability for the remote client to pause, unpause, and
restart pods.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-25 16:14:06 -06:00
OpenShift Merge Robot cf521449e5
Merge pull request #2422 from baude/remotepodcreate
podman-remote create|ps
2019-02-25 21:57:42 +01:00
OpenShift Merge Robot e45c442080
Merge pull request #2358 from rhatdan/namespace
Fix up handling of user defined network namespaces
2019-02-25 21:31:50 +01:00
Giuseppe Scrivano 0f5ae3c5af
podman: fix ro bind mounts if no* opts are on the source
This is a workaround for the runc issue:

https://github.com/opencontainers/runc/issues/1247

If the source of a bind mount has any of nosuid, noexec or nodev, be
sure to propagate them to the bind mount so that when runc tries to
remount using MS_RDONLY, these options are also used.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-25 18:56:09 +01:00
baude 43a1686598 podman-remote create|ps
enable the podman-remote client to be able to create and list
pods on a remote system.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-25 09:10:09 -06:00
OpenShift Merge Robot cc4adddeb7
Merge pull request #2413 from baude/remotepodstop
Enable more podman-remote pod commands
2019-02-24 03:13:25 +01:00
OpenShift Merge Robot 3825db5aee
Merge pull request #2404 from baude/remoteerrors
make remote-client error messaging more robust
2019-02-23 22:10:03 +01:00
Daniel J Walsh b87bdced1f
Fix up handling of user defined network namespaces
If user specifies network namespace and the /etc/netns/XXX/resolv.conf
exists, we should use this rather then /etc/resolv.conf

Also fail cleaner if the user specifies an invalid Network Namespace.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-02-23 05:47:27 -05:00
baude 4bf973a9f6 Enable more podman-remote pod commands
enable pod start, stop, and kill subcommands for the remote-client.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-22 17:00:24 -06:00
Giuseppe Scrivano 8984ba7461
rootless: force same cwd when re-execing
when joining an existing namespace, we were not maintaining the
current working directory, causing commands like export -o to fail
when they weren't referring to absolute paths.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-22 23:55:21 +01:00
baude 6208d53464 make remote-client error messaging more robust
the remote-client is currently weak for carrying error messages
over the varlink interface and displaying something useful to users
and developers for the purposes of debug.  this is a starting point
to improve that user experience.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-22 14:12:36 -06:00
baude bc6b4aa39c podman-remote pod inspect|exists
enable the remote client to be able to inspect a pod.  also, bonus of
enabling the podman pod exists command which returns a 0 or 1 depending
on whether the given pod exists.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-22 11:08:04 -06:00
baude 71db80ddb1 podman-remote load image
enable the ability to load an image into remote storage
using the remote client.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-21 10:11:19 -06:00
OpenShift Merge Robot 28d6eeb57a
Merge pull request #2387 from baude/remotepodrm
enable podman-remote pod rm
2019-02-21 16:51:23 +01:00
baude e91ec38a70 enable podman-remote pod rm
add the ability to delete a pod from the remote client.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-21 08:40:42 -06:00
Harald Hoyer 3f60dc02e3
Adjust LISTEN_PID for reexec in varlink mode
Because the varlink server honors the socket activation protocol,
LISTEN_PID has to be adjusted with the new PID.

https://varlink.org/FAQ.html#how-does-socket-activation-work
Signed-off-by: Harald Hoyer <harald@redhat.com>
2019-02-21 10:25:57 +01:00
baude 711ac93051 podman-remote save [image]
Add the ability to save an image from the remote-host to the
remote-client.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-20 12:58:05 -06:00
Valentin Rothberg 6ae4401bd1 iopodman.SearchImages: add ImageSearchFilter to Varlink API
Also add some argument checks to the Varlink function to avoid
referencing nil pointers, and complement the API.md descriptions.

The varlink endpoint can be tested via varlink CLI:

$ varlink call -m unix:/run/podman/io.podman/io.podman.SearchImages \
      '{"query": "ruby", "limit": 0, "tlsVerify": false, "filter": {}}'

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-20 10:25:25 +01:00
Valentin Rothberg 8a49b59ed4 image.SearchImages: use SearchFilter type
Use an `image.SearchFilter` instead of a `[]string` in the SearchImages
API.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-20 10:25:25 +01:00
Valentin Rothberg 0d3eaca28a SearchImages: extend API with filter parameter
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-20 10:25:25 +01:00
Valentin Rothberg 87c9f4cc22 podman-search: refactor code to libpod/image/search.go
Refactor the image-search logic from cmd/podman/search.go to
libpod/image/search.go and update podman-search and the Varlink API to
use it.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-02-20 10:25:25 +01:00
baude 8f40c4e6b4 podman-remote pull
Add status for remote users and podman remote-client pull.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-19 10:13:07 -06:00
Sebastian Jug 7141f97270 OpenTracing support added to start, stop, run, create, pull, and ps
Drop context.Context field from cli.Context

Signed-off-by: Sebastian Jug <sejug@redhat.com>
2019-02-18 09:57:08 -05:00
OpenShift Merge Robot e738ef1622
Merge pull request #2354 from rhatdan/varlink
Add registry name to fields returned by varlink image search
2019-02-18 13:32:54 +01:00
Peter Hunt 81804fc464 pod infra container is started before a container in a pod is run, started, or attached.
Prior, a pod would have to be started immediately when created, leading to confusion about what a pod state should be immediately after creation. The problem was podman run --pod ... would error out if the infra container wasn't started (as it is a dependency). Fix this by allowing for recursive start, where each of the container's dependencies are started prior to the new container. This is only applied to the case where a new container is attached to a pod.

Also rework container_api Start, StartAndAttach, and Init functions, as there was some duplicated code, which made addressing the problem easier to fix.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-02-15 16:39:24 -05:00
Daniel J Walsh b75dcd4458
Add registry name to fields returned by varlink image search
Cockpit team wants to list the registry name where the image was
found.

Also fix up SearchImages code to check if the user specified a registry
in his call to use that rather then all the registries, This matches
podman search command.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-02-15 15:30:09 -05:00
OpenShift Merge Robot d512c4d255
Merge pull request #2305 from rhatdan/tlsverify
Add tlsVerify bool to SearchImage for varlink
2019-02-15 10:50:36 +01:00
OpenShift Merge Robot ae8cc41295
Merge pull request #2332 from baude/remotevolumeprune
volume prune
2019-02-14 22:52:03 +01:00
Daniel J Walsh 5f7d4ee73f
Add tlsVerify bool to SearchImage for varlink
Cockpit wants to be able to search images on systems without
tlsverify turned on.

tlsverify should be an optional parameter, if not set then we default
to the system defaults defined in /etc/containers/registries.conf.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-02-14 14:31:20 -05:00
Daniel J Walsh 52df1fa7e0
Fix volume handling in podman
iFix builtin volumes to work with podman volume

Currently builtin volumes are not recored in podman volumes when
they are created automatically. This patch fixes this.

Remove container volumes when requested

Currently the --volume option on podman remove does nothing.
This will implement the changes needed to remove the volumes
if the user requests it.

When removing a volume make sure that no container uses the volume.

Signed-off-by: Daniel J Walsh dwalsh@redhat.com
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-02-14 13:21:52 -05:00
baude 5be818e715 enable podman-remote volume prune
allow users to remotely prune volumes.

this is the last volume command for remote enablement.  as such,
the volume commands are being folded back into main because they
are supported for both local and remote clients.

also, enable all volume tests that do not use containers
as containers are not enabled for the remote client yet.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-14 10:55:05 -06:00
OpenShift Merge Robot 0cd2243596
Merge pull request #2321 from baude/remotebuild
podman-remote build
2019-02-14 15:40:52 +01:00
OpenShift Merge Robot dfc64e15d7
Merge pull request #2319 from mheon/unconditional_cleanup
Fix manual detach from containers to not wait for exit
2019-02-13 22:55:52 +01:00
baude ef85dd7950 podman-remote build
add the ability to build images using files local to the remote-client
but over a varlink interface to a "remote" server.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-13 15:36:36 -06:00
baude 4f60f79a27 podman-remote volume inspect|ls
add the ability to list and inspect volumes using the remote
client and varlink

Signed-off-by: baude <bbaude@redhat.com>
2019-02-13 12:43:51 -06:00
baude 7dcc21f213 podman-remote push
enable podman-remote push so that users can push images from a
remote client.

change in push API to deal with the need to see output over the
varlink connection.

Signed-off-by: baude <bbaude@redhat.com>
2019-02-13 08:44:12 -06:00
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
Lars Karlitski 2448129e4d varlink: Rename SearchImage to SearchImages
Also rename image result struct to `ImageSearchResult` and make `limit`
parameter optional.

Signed-off-by: Lars Karlitski <lars@karlitski.net>
2019-02-12 14:48:19 +01:00
Lars Karlitski 5a32518170 varlink: Rename ContainerInList to Container
Container more clearly describes what the type represents.

Signed-off-by: Lars Karlitski <lars@karlitski.net>
2019-02-12 14:48:19 +01:00
Lars Karlitski 8a51b11058 varlink: Rename ImageInList to Image
Image more clearly describes what the type represents.

Also, only include the image name in the `ImageNotFound` error returned
by `GetImage()`, not the full error message.

Signed-off-by: Lars Karlitski <lars@karlitski.net>
2019-02-12 14:48:19 +01:00
Lars Karlitski 27baf9970e varlink: Simplify GetVersion() call
Not having the `Version` wrapper type makes it easier for clients to
work with the returned data.

Signed-off-by: Lars Karlitski <lars@karlitski.net>
2019-02-12 14:47:49 +01:00
Lars Karlitski 29392b77e9 varlink: Return all times in RFC 3339 format
This is more consistent and eaiser to parse than the format that
golang's time.String() returns.

Fixes #2260

Signed-off-by: Lars Karlitski <lars@karlitski.net>
2019-02-12 14:47:49 +01:00
Lars Karlitski 608019b65b varlink: Remove the Ping() method
There are other ways for developers to "ensure their varlink setup is
working", for example by calling `GetVersion()` or any call on the
org.varlink.service interface.

Signed-off-by: Lars Karlitski <lars@karlitski.net>
2019-02-12 14:47:49 +01:00
Lars Karlitski a097772cf7 varlink: Remove NotImplemented type
Remove the `NotImplemented` type and comment out the methods that use
it. This way we can keep track of the methods that still need to be
implemented without committing them to stable API.

Signed-off-by: Lars Karlitski <lars@karlitski.net>
2019-02-12 14:47:49 +01: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
OpenShift Merge Robot b83b07cb47
Merge pull request #2082 from rhatdan/runc
Update vendor of runc
2019-01-06 17:27:50 -08:00
Daniel J Walsh 43686072d3
Update vendor of runc
Updating the vendor or runc to pull in some fixes that we need.
In order to get this vendor to work, we needed to update the vendor
of docker/docker, which causes all sorts of issues, just to fix
the docker/pkg/sysinfo.  Rather then doing this, I pulled in pkg/sysinfo
into libpod and fixed the code locally.

I then switched the use of docker/pkg/sysinfo to libpod/pkg/sysinfo.

I also switched out the docker/pkg/mount to containers/storage/pkg/mount

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-04 14:54:59 -05:00
Valentin Rothberg 75578aad61 add container-init support
Add support for executing an init binary as PID 1 in a container to
forward signals and reap processes.  When the `--init` flag is set for
podman-create or podman-run, the init binary is bind-mounted to
`/dev/init` in the container and "/dev/init --" is prepended to the
container's command.

The default base path of the container-init binary is `/usr/libexec/podman`
while the default binary is catatonit [1].  This default can be changed
permanently via the `init_path` field in the `libpod.conf` configuration
file (which is recommended for packaging) or temporarily via the
`--init-path` flag of podman-create and podman-run.

[1] https://github.com/openSUSE/catatonit

Fixes: #1670
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-01-04 11:42:03 +01:00
Daniel J Walsh b0fcd555db
If local storage file exists, then use it rather then defaults.
Currently we always force overlay if it exists even though a user might want
vfs.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-03 16:25:02 -05:00
Daniel J Walsh c141c5cfd2
Fix handling of symbolic links
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-28 13:10:15 -05:00
Daniel J Walsh df99522c67
Fixes to handle /dev/shm correctly.
We had two problems with /dev/shm, first, you mount the
container read/only then /dev/shm was mounted read/only.
This is a bug a tmpfs directory should be read/write within
a read-only container.

The second problem is we were ignoring users mounted /dev/shm
from the host.

If user specified

podman run -d -v /dev/shm:/dev/shm ...

We were dropping this mount and still using the internal mount.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-24 09:03:53 -05:00
Šimon Lukašík 4e85f468fc Refactor: use idtools.ParseIDMap instead of bundling own version
ParseIDMap function was extracted to idtools in

    https://github.com/containers/storage/pull/236

it is already used in containers/storage and buildah, it should be used in
libpod as well.

Signed-off-by: Šimon Lukašík <isimluk@fedoraproject.org>
2018-12-23 12:07:54 +01:00
Daniel J Walsh c657dc4fdb
Switch all referencs to image.ContainerConfig to image.Config
This will more closely match what Docker is doing.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-21 15:59:34 -05:00
Daniel J Walsh 1ad6f9af15
Allow users to specify a directory for additonal devices
Podman will search through the directory and will add any device
nodes that it finds.  If no devices are found we return an error.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-21 10:28:14 -05:00
Daniel J Walsh 4d13262405
Change all 'can not' to 'cannot' for proper usage
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-21 10:27:54 -05:00
Daniel J Walsh 664076c259
Invalid index for array
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-21 09:25:25 -05:00
Giuseppe Scrivano f2e96b0934
rootless: add function to join user and mount namespace
Add the possibility to join directly the user and mount namespace
without looking up the parent of the user namespace.

We need this in order to be able the conmon process, as the mount
namespace is kept alive only there.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-12-21 09:46:05 +01:00
Qi Wang 31edf47285 Support podman image trust command
Display the trust policy of the host system. The trust policy is stored in the /etc/containers/policy.json file and defines a scope of registries or repositories.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2018-12-19 13:36:11 -05:00
baude 06d763d964 Clean up some existing varlink endpoints
Going through and adding options (like tls-verify, signature option, etc)
to some varlink endpoints (like push/pull) many of which had not been
updated since their original authoring.

Signed-off-by: baude <bbaude@redhat.com>
2018-12-12 12:53:09 -06:00
baude 078fd071c1 add more example usage to varlink endpoints
Signed-off-by: baude <bbaude@redhat.com>
2018-12-09 11:16:33 -06:00
baude 5209894100 add timeout to pod stop
like podman stop of containers, we should allow the user to specify
a timeout override when stopping pods; otherwise they have to wait
the full timeout time specified during the pod/container creation.

Signed-off-by: baude <bbaude@redhat.com>
2018-12-07 10:27:41 -06:00
Miloslav Trmač 93e14b6198 Remove the forceSecure parameter on the pull call stack
DockerRegistryOptions.DockerInsecureSkipTLSVerify as an types.OptionalBool
can now represent that value, so forceSecure is redundant.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2018-12-06 23:34:59 +01:00
Miloslav Trmač 8150c942d5 Factor out the registries.conf location code in pkg/registries
The newly introduced SystemRegistriesConfPath somewhat decreases
duplication, but more importantly will allow future callers to
set just a types.SystemContext.SystemRegistriesConfPath and not call
GetRegistries / GetInsecureRegistries at all.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2018-12-06 23:34:59 +01:00
Miloslav Trmač 7407d6621c Remove the forceSecure parameter of Image.PushImageTo*
DockerRegistryOptions.DockerInsecureSkipTLSVerify as an types.OptionalBool
can now represent that value, so forceSecure is redundant.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2018-12-06 23:34:59 +01:00
Miloslav Trmač b134951d14 Minimally update for the DockerInsecureSkipTLSVerify type change
Following SystemContext.DockerInsecureSkipTLSVerify, make the
DockerRegistryOne also an OptionalBool, and update callers.

Explicitly document that --tls-verify=true and --tls-verify unset
have different behavior in those commands where the behavior changed
(or where it hasn't changed but the documentation needed updating).

Also make the --tls-verify man page sections a tiny bit more consistent
throughout.

This is a minimal fix, without changing the existing "--tls-verify=true"
paths nor existing manual insecure registry lookups.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2018-12-06 23:34:59 +01:00
umohnani8 4c70b8a94b Add "podman volume" command
Add support for podman volume and its subcommands.
The commands supported are:
	podman volume create
	podman volume inspect
	podman volume ls
	podman volume rm
	podman volume prune

This is a tool to manage volumes used by podman. For now it only handle
named volumes, but eventually it will handle all volumes used by podman.

Signed-off-by: umohnani8 <umohnani@redhat.com>
2018-12-06 10:17:16 +00:00
OpenShift Merge Robot 6bb56a1c97
Merge pull request #1924 from baude/mroevarlinkendpoints
Adding more varlink endpoints
2018-12-05 14:55:27 -08:00
OpenShift Merge Robot be74acee1c
Merge pull request #1940 from wking/numeric-gid
libpod/container_internal_linux: Allow gids that aren't in the group file
2018-12-05 08:09:58 -08:00
OpenShift Merge Robot 50e754cd57
Merge pull request #1918 from mheon/use_db_paths
Use paths written in DB instead if they differ from our defaults
2018-12-05 00:55:48 -08:00
W. Trevor King 39df2093e8 pkg/lookup: Return ID-only pointers on ErrNo*Entries
Callers that only care about the IDs should try to convert the
identifier to an integer before calling the Get* functions, so they
can save the cost of hitting the filesystem and maybe or maybe not
finding the other fields (User.Name, etc.).  But callers that *want*
the other fields but only actually need the ID can, with this commit,
just call the Get* function and ignore ErrNo*Entries responses:

  user, err := lookup.GetUser(mount, userIDorName)
  if err != nil && err != ErrNoPasswdEntries {
    return err
  }

Previously, they'd have to perform their own integer-conversion
attempt in Get* error handling, with logic like:

  user, err := lookup.GetUser(mount, userIDorName)
  if err == ErrNoPasswdEntries {
    uuid, err := strconv.ParseUint(userIDorName, 10, 32)
    if err == nil {
      user.Uid = int(uuid)
    }
  } else if err != nil {
    return err
  }

Signed-off-by: W. Trevor King <wking@tremily.us>
2018-12-04 14:46:43 -08:00
baude 9c359a31d5 create pod on the fly
when a user specifies --pod to podman create|run, we should create that pod
automatically.  the port bindings from the container are then inherited by
the infra container.  this signicantly improves the workflow of running
containers inside pods with podman.  the user is still encouraged to use
podman pod create to have more granular control of the pod create options.

Signed-off-by: baude <bbaude@redhat.com>
2018-12-03 15:49:17 -06:00
Matthew Heon 795fbba769 Revert changes to GetDefaultStoreOptions
We don't need this for anything more than rootless work in Libpod
now, but Buildah still uses it as it was originally written, so
leave it intact as part of our API.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-12-03 15:48:20 -05:00
baude 5c02dda869 Adding more varlink endpoints
* runlabel
* checkpoint
* restore
* container|image exists
* mount
* unmount

Signed-off-by: baude <bbaude@redhat.com>
2018-12-03 10:56:07 -06:00