Commit graph

260 commits

Author SHA1 Message Date
haircommander 63dd200e7e Changed GetContainerStats to return ErrCtrStateInvalid
This results in some functionality changes:

If a ErrCtrStateInvalid is returned to GetPodStats, the container is ommitted from the stats.
As such, if an empty slice of Container stats are returned to GetPodStats in varlink, an error will occur.
GetContainerStats will return the ErrCtrStateInvalid as well.
Finally, if ErrCtrStateInvalid is returned to the podman stats call, the container will be ommitted from the stats.

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1319
Approved by: baude
2018-08-23 15:58:08 +00:00
haircommander 3df6332a65 Add GetPodStats to varlink
Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1319
Approved by: baude
2018-08-23 15:58:08 +00:00
Giuseppe Scrivano 77bcc89d52 rootless: fix --net host --privileged
Closes: https://github.com/containers/libpod/issues/1313

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1323
Approved by: umohnani8
2018-08-22 20:32:27 +00:00
Matthew Heon b4420e22fc Fix a bug with hook ALWAYS matching with a process
When a non-nil process was used and a hook was set to match
always, this would not actually match. Fix this.

Fixes: #1308

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #1311
Approved by: rhatdan
2018-08-22 11:48:43 +00:00
Daniel J Walsh 462c503a47 Fix handling of devices
Devices are supposed to be able to be passed in via the form of

--device /dev/foo
--device /dev/foo:/dev/bar
--device /dev/foo:rwm
--device /dev/foo:/dev/bar:rwm

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1299
Approved by: umohnani8
2018-08-20 13:42:07 +00:00
Giuseppe Scrivano 50afe5b031 podman: fix --uts=host
Do not set any hostname value in the OCI configuration when --uts=host
is used and the user didn't specify any value.  This prevents an error
from the OCI runtime as it cannot set the hostname without a new UTS
namespace.

Differently, the HOSTNAME environment variable is always set.  When
--uts=host is used, HOSTNAME gets the value from the host.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1280
Approved by: baude
2018-08-17 08:17:43 +00:00
haircommander c4fadaba6b Added helper function for libpod pod api calls
Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1275
Approved by: mheon
2018-08-16 20:31:50 +00:00
haircommander 309a2a15ae CreatePod args now PodCreate structure
Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1275
Approved by: mheon
2018-08-16 20:31:50 +00:00
haircommander a51eb1e70f Added reason to PodContainerError
Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1275
Approved by: mheon
2018-08-16 20:31:50 +00:00
haircommander 8d5e0108d7 Change batchcontainer to shared
To better reflect it's usage: to share functions between podman and varlink.

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1275
Approved by: mheon
2018-08-16 20:31:50 +00:00
haircommander 0059989783 Add Pod API to varlink.
Including: GetPod, StartPod, StopPod, RestartPod, KillPod, PausePod, UnpausePod, CreatePod, RemovePod, and InspectPod

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1275
Approved by: mheon
2018-08-16 20:31:50 +00:00
Daniel J Walsh d20f3a5146 switch projectatomic to containers
Need to get some small changes into libpod to pull back into buildah
to complete buildah transition.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1270
Approved by: mheon
2018-08-16 17:12:36 +00:00
Giuseppe Scrivano c0abfaa7c3 Revert "spec: bind mount /sys only for rootless containers"
It breaks "podman  run --net=host --uidmap=0:1:70000 --gidmap=0:20000:70000 busybox echo hi"

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1285
Approved by: rhatdan
2018-08-16 16:02:32 +00:00
Qi Wang 1003df3444 Suport format param for varlink Commit
We need to pass the image format OCI or docker  in the varlink commit command.

Signed-off-by: Qi Wang <qiwan@redhat.com>

Closes: #1281
Approved by: mheon
2018-08-16 15:35:28 +00:00
Giuseppe Scrivano 0ddb42b4f7 spec: bind mount /sys only for rootless containers
root can always mount a new instance.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1279
Approved by: rhatdan
2018-08-15 15:30:15 +00:00
Daniel J Walsh cd7102a70e Fix handling of hostname in --net=host
Hostname should be set to the hosts hostname when network is none.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1274
Approved by: giuseppe
2018-08-15 11:38:18 +00:00
Valentin Rothberg 9563f31437 pkg/apparmor: use a pipe instead of a tmp file
Use a pipe instead of a temporary file to load the apparmor profile.
This change has a measurable speed improvement for apparmor users.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1262
Approved by: mheon
2018-08-14 14:25:14 +00:00
Valentin Rothberg 973c9e6ba6 pkg/apparmor: move data under Linux/apparmor buildtags
Move all Linux-related data under the corresponding buildtags to reduce
the memory footprint and speed up compilation for non-apparmor builds.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1262
Approved by: mheon
2018-08-14 14:25:14 +00:00
Valentin Rothberg 31e0dea5a0 pkg/apparmor: move all linux-code into apparmor_linux*
For easier maintenance and clearer structure of the code.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1262
Approved by: mheon
2018-08-14 14:25:14 +00:00
baude 5d7b31da73 when searching, survive errors for multiple registries
when searching multiple registries for images, if we get an error on one
of the searches, we should keep going and complete the search.  if there
is only one search registry however, we will return an error.

Resolves: #1255

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1257
Approved by: mheon
2018-08-14 01:59:53 +00:00
Giuseppe Scrivano 9e06478d83 rootless: fix user lookup if USER= is not set
Lookup the current username by UID if the USER env variable is not
set.

Reported in: https://github.com/projectatomic/libpod/issues/1092

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1217
Approved by: rhatdan
2018-08-08 09:27:27 +00:00
baude bd9d3a8fa5 Rename varlink socket and interface
io.projectatomic.podman -> io.podman

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1204
Approved by: mheon
2018-08-06 14:49:11 +00:00
baude a1e3e542ff Make one runtime for the varlink service
Rather than making a runtime each time a client hits a varlink endpoint, we now
make a single runtime when the varlink service starts up.  This fixes a problem
where we hit a max inotify limit from CNI.

Resolves: #1211

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1215
Approved by: rhatdan
2018-08-05 10:43:32 +00:00
Anders F Björklund 71af51e723 Check for missing arguments in /proc/self/cmdline
Closes: #1206
Approved by: giuseppe
2018-08-03 07:39:25 +00:00
Giuseppe Scrivano 13b1845214 rootless: do not set setgroups to deny when using newuidmap
It is required only when directly configuring the user namespace.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1200
Approved by: rhatdan
2018-08-02 18:49:55 +00:00
Daniel J Walsh 9f2da6f59f
Merge pull request #1201 from giuseppe/fix-segfault-rootless
rootless: do not segfault if the parent already died
2018-08-02 14:42:39 -04:00
Giuseppe Scrivano c7b6403ae5
rootless: do not segfault if the parent already died
Closes: https://github.com/projectatomic/libpod/issues/1189

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-08-02 14:29:50 +02:00
Miloslav Trmač 4dab4d97de RFC: Rename Image.PushImage to Image.PushImageToHeuristicDestination
The goal is to be very explicit about which functions try to heuristically
guess what is the expected format of the string.  Not quite "shaming"
the users, but making sure they stand out.

RFC:
- Is this at all acceptable? Desirable?
- varlink ExportImage says "destination must have transport type";
  should it be using alltransports.ParseImageReference
  + PushImageToReference, then?

(While touching the call in cmd/podman, also remove a commented-out
older version of the call.)

Should not change behavior (but does not add unit tests).

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1176
Approved by: rhatdan
2018-08-01 18:22:59 +00:00
Giuseppe Scrivano cfcd928476 network: add support for rootless network with slirp4netns
slirp4netns is required to setup the network namespace:

https://github.com/rootless-containers/slirp4netns

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1156
Approved by: rhatdan
2018-07-31 13:39:29 +00:00
baude 5b9c60cc10 varlink ImageRemove should always return image ID
When removing an image via varlink, we should always return the
ID of the image even in the case where the image has multiple
repository names and one was only untagged.

Reported by jhonce during integration testing.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1191
Approved by: jwhonce
2018-07-31 11:38:48 +00:00
Matthew Heon 3dd577e93c Fix godoc comment in pkg/netns
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #1165
Approved by: baude
2018-07-27 02:48:16 +00:00
Matthew Heon 8c52aa15f0 Fix handling of Linux network namespaces
The CNI plugins upstream removed their network namespace creation
code, making it a test package only. Copy it into our repository
and slightly modify it for our use (most notably, use MNT_DETACH
when unmounting namespaces).

This new CNI code splits closing and unmounting network
namespaces, which allows us to greatly reduce the number of
occasions on which we call teardownNetwork() and make more errors
in that function fatal instead of warnings. Instead, we can call
Close() and just close the open file descriptor in cases where
the namespace has already been cleaned up.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #1165
Approved by: baude
2018-07-27 02:48:15 +00:00
umohnani8 e56717833e Clear variables used to store options after parsing for every volume
If more than one volume was mounted using the --volume flag in
podman run, the second and onwards volumes were picking up options
of the previous volume mounts defined. Found out that the options were
not be cleared out after every volume was parsed.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #1142
Approved by: mheon
2018-07-25 14:44:57 +00:00
Daniel J Walsh c90b7400a8
Merge pull request #1116 from mheon/namespaces
Add Pod and Container namespaces
2018-07-25 08:47:35 -04:00
Matthew Heon 561007d1f8
Merge pull request #1153 from jwhonce/bug/psgo
Fix varlink API usage of psgo
2018-07-24 18:23:41 -04:00
Giuseppe Scrivano e43270fc5e podman: allow to specify the IPC namespace to join
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1145
Approved by: rhatdan
2018-07-24 21:50:49 +00:00
Giuseppe Scrivano 977c8a9cd6 podman: allow to specify the UTS namespace to join
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1145
Approved by: rhatdan
2018-07-24 21:50:49 +00:00
Giuseppe Scrivano 8223fbaac6 podman: allow to specify the PID namespace to join
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1145
Approved by: rhatdan
2018-07-24 21:50:49 +00:00
Giuseppe Scrivano 819c807125 podman: allow to specify the userns to join
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1145
Approved by: rhatdan
2018-07-24 21:50:49 +00:00
Giuseppe Scrivano 41c7e43b4d network: support ns: prefix to join existing namespace
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1145
Approved by: rhatdan
2018-07-24 21:50:49 +00:00
Giuseppe Scrivano 6f65490e27 spec: allow container:NAME network mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1145
Approved by: rhatdan
2018-07-24 21:50:49 +00:00
Matthew Heon 486c5c87bc Add missing runtime.go lines to set namespace
Also add namespace to inspect output to verify its presence

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-07-24 16:12:31 -04:00
Jhon Honce 8e145d9c9a Fix varlink API usage of psgo
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2018-07-24 12:06:16 -07:00
Valentin Rothberg 8569ed0305 AppArmor: runtime check if it's enabled on the host
Check at runtime if AppArmor is enabled on the host.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1128
Approved by: mheon
2018-07-23 18:11:09 +00:00
Giuseppe Scrivano d4f14be3a7
rootless: support a per-user mounts.conf
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-20 11:00:53 +02:00
Giuseppe Scrivano 45a92f8357
secrets: parse only one mounts configuration file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-20 11:00:53 +02:00
Giuseppe Scrivano c737d01937
rootless: allow a per-user registries.conf file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-20 11:00:52 +02:00
Giuseppe Scrivano 6372c977ea rootless: require subids to be present
Most images won't work without multiple ids/gids.  Error out
immediately if there are no multiple ids available.

The error code when the user is not present in /etc/sub{g,u}id looks
like:

$ bin/podman run --rm -ti alpine echo hello
ERRO[0000] No subuid ranges found for user "gscrivano"

Closes: https://github.com/projectatomic/libpod/issues/1087

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1097
Approved by: rhatdan
2018-07-16 13:40:40 +00:00
Matthew Heon 5b43a6a7ee Only print container size JSON if --size was requested
To do this, move it into a separate struct, and embed that in
the JSON we return.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-07-13 14:28:41 -04:00
Daniel J Walsh 14a6d51a84
Merge pull request #1091 from giuseppe/rootless-unshare-mount-ns
rootless: unshare mount namespace
2018-07-13 14:16:24 -04:00
Daniel J Walsh 673465a747
Merge pull request #1075 from giuseppe/rootless-no-symlinks-into-storage-path
rootless: fix usage on Fedora Silverblue/CoreOS
2018-07-13 14:15:54 -04:00
Giuseppe Scrivano 62e48e5b71
rootless: correctly propagate the exit status from the container
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-13 16:41:11 +02:00
Giuseppe Scrivano 6ffcb98a70
rootless: unshare mount namespace
unshare the mount namespace as well when creating an user namespace so
that we are the owner of the mount namespace and we can mount FUSE
file systems on Linux 4.18.  Tested on Fedora Rawhide:

podman --storage-opt overlay.fuse_program=/usr/bin/fuse-overlayfs run alpine echo hello
hello

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-13 16:37:37 +02:00
haircommander a04a8d1dd4 Added full podman pod ps, with tests and man page
Signed-off-by: haircommander <pehunt@redhat.com>
2018-07-13 09:17:33 -04:00
haircommander 1aad3fd96b Podman pod create/rm commands with man page and tests.
Includes a very stripped down version of podman pod ps, just for testing

Signed-off-by: haircommander <pehunt@redhat.com>
2018-07-13 09:05:03 -04:00
baude 4f699db8da Support multiple networks
This is a refresh of Dan William's PR #974 with a rebase and proper
vendoring of ocicni and containernetworking/cni.  It adds the ability
to define multiple networks as so:

podman run --network=net1,net2,foobar ...

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1082
Approved by: baude
2018-07-12 21:45:47 +00:00
baude 7f3f491396 create conmon sockets when getting their paths
when using the getattachsockets endpoint, which returns the sockets needed
to create and use a terminal, we should check if the container is just in the
configured state.  if so, we need to perform a container init to have conmon
create the required sockets so we can attach to them prior to starting the container.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1067
Approved by: jwhonce
2018-07-11 19:55:16 +00:00
Valentin Rothberg 06ab343bd7 podman/libpod: add default AppArmor profile
Make users of libpod more secure by adding the libpod/apparmor package
to load a pre-defined AppArmor profile.  Large chunks of libpod/apparmor
come from github.com/moby/moby.

Also check if a specified AppArmor profile is actually loaded and throw
an error if necessary.

The default profile is loaded only on Linux builds with the `apparmor`
buildtag enabled.

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1063
Approved by: rhatdan
2018-07-11 16:36:24 +00:00
Giuseppe Scrivano 84cfdb2061 rootless: fix when argv[0] is not an absolute path
use execvp instead of exec so that we keep the PATH environment
variable and the lookup for the "podman" executable works.

Closes: https://github.com/projectatomic/libpod/issues/1070

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1072
Approved by: mheon
2018-07-10 16:13:43 +00:00
umohnani8 4855998f1c Add --volumes-from flag to podman run and create
podman now supports --volumes-from flag, which allows users
to add all the volumes an existing container has to a new one.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #931
Approved by: mheon
2018-07-09 19:30:03 +00:00
Daniel J Walsh 5a8e5a2b17 Mask /proc/keys to protect information leak about keys on host
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1060
Approved by: mheon
2018-07-08 13:38:20 +00:00
W. Trevor King 0660108e3e ctime: Drop 32-/64-bit distinction on Linux
We added the explicit int64 casts for 32-bit builds in 35e1ad78 (Make
libpod build on 32-bit systems, 2018-02-12, #324), but the explicit
casts work fine on 64-bit systems too.

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

Closes: #1058
Approved by: mheon
2018-07-07 20:35:00 +00:00
W. Trevor King b2344b83ed pkg/ctime: Factor libpod/finished* into a separate package
This removes some boilerplate from the libpod package, so we can focus
on container stuff there.  And it gives us a tidy sub-package for
focusing on ctime extraction, so we can focus on unit testing and
portability of the extraction utility there.

For the unsupported implementation, I'm falling back to Go's ModTime
[1].  That's obviously not the creation time, but it's likely to be
closer than the uninitialized Time structure from cc6f0e85 (more
changes to compile darwin, 2018-07-04, #1047).  Especially for our use
case in libpod/oci, where we're looking at write-once exit files.

The test is more complicated than I initially expected, because on
Linux filesystem timestamps come from a truncated clock without
interpolation [2] (and network filesystems can be completely decoupled
[3]).  So even for local disks, creation times can be up to a jiffie
earlier than 'before'.  This test ensures at least monotonicity by
creating two files and ensuring the reported creation time for the
second is greater than or equal to the reported creation time for the
first.  It also checks that both creation times are within the window
from one second earlier than 'before' through 'after'.  That should be
enough of a window for local disks, even if the kernel for those
systems has an abnormally large jiffie.  It might be ok on network
filesystems, although it will not be very resilient to network clock
lagging behind the local system clock.

[1]: https://golang.org/pkg/os/#FileInfo
[2]: https://groups.google.com/d/msg/linux.kernel/mdeXx2TBYZA/_4eJEuJoAQAJ
     Subject: Re: Apparent backward time travel in timestamps on file creation
     Date: Thu, 30 Mar 2017 20:20:02 +0200
     Message-ID: <tqMPU-1Sb-21@gated-at.bofh.it>
[3]: https://groups.google.com/d/msg/linux.kernel/mdeXx2TBYZA/cTKj4OBuAQAJ
     Subject: Re: Apparent backward time travel in timestamps on file creation
     Date: Thu, 30 Mar 2017 22:10:01 +0200
     Message-ID: <tqOyl-36A-1@gated-at.bofh.it>

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

Closes: #1050
Approved by: mheon
2018-07-06 17:54:32 +00:00
Daniel J Walsh aaab26fd0c Block use of /proc/acpi from inside containers
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1053
Approved by: mheon
2018-07-06 17:29:35 +00:00
W. Trevor King 4f0c0597a1 spec: Make addPrivilegedDevices and createBlockIO per-platform
b96be3af (changes to allow for darwin compilation, 2018-06-20, #1015)
made AddPrivilegedDevices per-platform and cc6f0e85 (more changes to
compile darwin, 2018-07-04, #1047) made CreateBlockIO per-platform.
But both left but left out docs for the unsupported version [1]:

  pkg/spec/config_unsupported.go:18:1⚠️ exported method
    CreateConfig.AddPrivilegedDevices should have comment or be
    unexported (golint)
  pkg/spec/config_unsupported.go:22:1⚠️ exported method
    CreateConfig.CreateBlockIO should have comment or be unexported
    (golint)

To keep the docs DRY, I've restored the public methods and their docs,
and I've added new, internal methods for the per-platform
implementations.

[1]: https://travis-ci.org/projectatomic/libpod/jobs/400555937#L160

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

Closes: #1034
Approved by: baude
2018-07-06 00:48:40 +00:00
W. Trevor King 83968de28c rootless: Merge rootless.go back into rootless_linux.go
The files were split apart by b96be3af (changes to allow for darwin
compilation, 2018-06-20, #1015), but the C import and two functions
left in rootless.go are all Linux-specific as well.  This commit moves
all of the pre-b96be3af rootless.go into rootless_linux.go, just
adding the '// +build linux' header (b96be3af also scrambled the + in
that header) and keeping the new GetRootlessUID from a1545fe6
(rootless: add function to retrieve the original UID, 2018-07-05, #1048).

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

Closes: #1034
Approved by: baude
2018-07-06 00:48:39 +00:00
baude cc6f0e85f9 more changes to compile darwin
this should represent the last major changes to get darwin to **compile**.  again,
the purpose here is to get darwin to compile so that we can eventually implement a
ci task that would protect against regressions for darwin compilation.

i have left the manual darwin compilation largely static still and in fact now only
interject (manually) two build tags to assist with the build.  trevor king has great
ideas on how to make this better and i will defer final implementation of those
to him.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1047
Approved by: rhatdan
2018-07-05 16:05:12 +00:00
Giuseppe Scrivano a1545fe6e4 rootless: add function to retrieve the original UID
After we re-exec in the userNS os.Getuid() returns the new UID (= 0)
which is not what we want to use.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1048
Approved by: mheon
2018-07-05 13:30:15 +00:00
baude d357703e06 add image user to inspect data
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1036
Approved by: rhatdan
2018-07-02 15:10:46 +00:00
baude b96be3af1b changes to allow for darwin compilation
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1015
Approved by: baude
2018-06-29 20:44:09 +00:00
Daniel J Walsh 7fc1a329bd Add podman container cleanup to CLI
When we run containers in detach mode, nothing cleans up the network stack or
the mount points.  This patch will tell conmon to execute the cleanup code when
the container exits.

It can also be called to attempt to cleanup previously running containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #942
Approved by: mheon
2018-06-29 15:25:21 +00:00
Daniel J Walsh 810f2b6061 Start using github.com/seccomp/containers-golang
User newer seccomp bindings from the seccomp upstream

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1021
Approved by: giuseppe
2018-06-29 13:18:41 +00:00
Daniel J Walsh c9eddd22eb conmon no longer writes to syslog
If the caller sets up the app to be in logrus.DebugLevel,
then we will add the --syslog flag to conmon to get all of the
messages.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1014
Approved by: TomSweeneyRedHat
2018-06-29 08:22:27 +00:00
W. Trevor King fd12c8918b *: Replace Generator.Spec() with Generator.Config
Catching up with opencontainers/runtime-tools@84a62c6a (generate: Move
Generator.spec to Generator.Config, 2016-11-06, #266, v0.6.0), now
that we've bumped runtime-tools in f6c0fc1a (Vendor in latest
runtime-tools, 2018-06-26, #1007).

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

Closes: #1008
Approved by: mheon
2018-06-27 21:27:19 +00:00
baude c32c491869 generator.New() requires an OS string input variable
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1007
Approved by: baude
2018-06-27 15:16:02 +00:00
Giuseppe Scrivano 20862c9746 rootless: do not configure additional groups
Additional groups are not allowed in an userNS.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
2018-06-27 14:07:17 +00:00
Giuseppe Scrivano 5ff90677c8 rootless: add management for the userNS
When running podman as non root user always create an userNS and let
the OCI runtime use it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
2018-06-27 14:07:17 +00:00
umohnani8 088d5af879 Podman history now prints out intermediate image IDs
If the intermediate image exists in the store, podman history
will show the IDs of the intermediate image of each layer.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #982
Approved by: mheon
2018-06-22 15:19:34 +00:00
Daniel J Walsh 82a948c04e Option handling has become large and should be a shared function
Everytime we add a new option for create, we end up having to also
add it to run, this makes it error prone.  Moving these to the same
function makes it easier to develop and prevents user mistakes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #975
Approved by: mheon
2018-06-22 14:30:18 +00:00
Wim 9e134576e8 Add more network info ipv4/ipv6 and be more compatible with docker
Signed-off-by: Wim <wim@42.be>

Closes: #953
Approved by: mheon
2018-06-17 21:21:27 +00:00
Giuseppe Scrivano 16ea659757 spec: remove dead code
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:19 +00:00
Giuseppe Scrivano c976d49805 network: do not attempt to create a network in rootless mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano 3861098fb3 oci: do not set resources in rootless mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano ed0261176b spec: change mount options for /dev/pts in rootless mode
The default /dev/pts has the option gid=5 that might not be mapped in
the rootless case.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano be66361e08 podman: provide a default UID mapping when non root
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano 7bdfb4f9b3 podman: accept option --rootfs to use exploded images
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Matthew Heon 4b4de5dc21 When setting a memory limit, also set a swap limit
Closes #940

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #946
Approved by: rhatdan
2018-06-15 09:25:21 +00:00
baude 06a29f0bde varlink build fixes
the varlink build was not working as designed and required some touch-ups:

* return a struct that includes logs and the new image ID
* pass namespaceoption so that networking in buildah works

Signed-off-by: baude <bbaude@redhat.com>

Closes: #903
Approved by: rhatdan
2018-06-05 19:31:13 +00:00
W. Trevor King c9f763456c libpod: Execute poststop hooks locally
Instead of delegating to the runtime, since some runtimes do not seem
to handle these reliably [1].

[1]: https://github.com/projectatomic/libpod/issues/730#issuecomment-392959938

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

Closes: #864
Approved by: rhatdan
2018-06-04 18:36:40 +00:00
Matthew Heon 6d52ebdd13 Add flag to add annotations to a container
Also add annotations from the image the container was created
from.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #886
Approved by: rhatdan
2018-06-04 17:52:28 +00:00
Daniel J Walsh 3416e9f194 Want to change the log level on buildah by default to warnf
Change the level of missing /etc/containers/mount.conf to a debug, since
this is expected on most machines.

Also raised the level of some warnings to errors, so they will be better seen,
even if we are skipping.

Fixed the wording of one error, since stating is not the correct word.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #882
Approved by: mheon
2018-06-04 15:12:12 +00:00
W. Trevor King 41a3f48f6d hooks: Add debug logging for initial hook loading
We've had logrus logging in the monitor code since it landed in
68eb128f (pkg/hooks: Version the hook structure and add 1.0.0 hooks,
2018-04-27, #686).  This commit adds similar logging to the initial
hook.New() and Manager.Hooks() calls to make it easier to see if those
are working as expected.

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

Closes: #887
Approved by: rhatdan
2018-06-04 13:01:56 +00:00
W. Trevor King d5bedf42cf hooks/docs: Fix 1.0.0 Nvidia example (adding version, etc.)
Reported by Gary Edwards [1].  Both typos are originally from 68eb128f
(pkg/hooks: Version the hook structure and add 1.0.0 hooks,
2018-04-27, #686).

[1]: https://github.com/projectatomic/libpod/issues/884#issuecomment-394174571

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

Closes: #887
Approved by: rhatdan
2018-06-04 13:01:56 +00:00
W. Trevor King fd126d8453 hooks/1.0.0/when_test: Fix "both, and" -> "both, or" name typo
The typo is a copy/paste error from 68eb128f (pkg/hooks: Version the
hook structure and add 1.0.0 hooks, 2018-04-27, #686).

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

Closes: #887
Approved by: rhatdan
2018-06-04 13:01:56 +00:00
W. Trevor King 8f198e67ca hooks/1.0.0: Fix 'annotation' -> 'annotations' in JSON
This typo from 68eb128f (pkg/hooks: Version the hook structure and add
1.0.0 hooks, 2018-04-27, #686) was causing any 'annotations' entries
in hook JSON to be silently ignored.

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

Closes: #887
Approved by: rhatdan
2018-06-04 13:01:56 +00:00
W. Trevor King 947e410fe6 hooks: Fail ReadDir if a configured hook executable is missing
The continue here is from 5676597f (hooks/read: Ignore IsNotExist for
JSON files in ReadDir, 2018-04-27, #686), where it was intended to
silently ignore missing JSON files.  However, the old logic was also
silently ignoring not-exist errors from the os.Stat(hook.Hook.Path)
from 68eb128f (pkg/hooks: Version the hook structure and add 1.0.0
hooks, 2018-04-27, #686).  This commit adjusts the check so JSON
not-exist errors continue to be silently ignored while hook executable
not-exist errors become fatal.

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

Closes: #887
Approved by: rhatdan
2018-06-04 13:01:56 +00:00
baude 62ea88fa19 varlink build
Add the endpoint and methods for build so users can build an image
with varlink.  build can also use the more method for streaming
output back more regularily; however, it looks like a bug in buildah
does not output all build output to the writer provided.

Tidy up some create fixes and add endpoint for GetImage requested by
jhonce.

Signed-off-by: baude <bbaude@redhat.com>
2018-06-01 09:13:31 -05:00
baude 8f14f966be return all inspect info for varlink containerinspect
when obtaining the inspect information for a container through varlink, we need
to extract more container related information by parsing the data through the
method 'GetCtrInspectInfo' which was previously only in podman's main.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #866
Approved by: rhatdan
2018-06-01 08:37:55 +00:00
W. Trevor King 34886a79d6 hooks/exec: Allow successful reaps for 0s post-kill timeouts
I'd been getting the failed-to-reap errors locally, but on an
unrelated pull-request the FAH27 suite successfully reaped that hook
[1]:

  --- FAIL: TestRunKillTimeout (0.50s)
  	assertions.go:226:

  	Error Trace:	exec_test.go:210

  	Error:      	Expect "signal: killed" to match "^failed to reap process within 0s of the kill signal$"
  FAIL

The successful-reap cases limit our coverage, but I don't think that's
a big enough problem to be worth repeated polling or similar until we
do get the failed-to-reap error.

[1]: 96c1535fdc.0.1527811547665239762/output.log

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

Closes: #868
Approved by: rhatdan
2018-06-01 08:28:06 +00:00
Daniel J Walsh a9e9fd4f5b If user specifies UIDMapSlice without GIDMapSlice, set them equal
We need to map slices set for both UID and GID maps to be equivalent if
not specified by user.  Currently if you do not specify both the containers
are not running.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #865
Approved by: baude
2018-05-31 22:30:16 +00:00
W. Trevor King 81d6f082f3 pkg/hooks/exec: Add a new package for local hook execution
This wraps os/exec to:

* Clear the environment when the hook doesn't set 'env'.  The runtime
  spec has [1]:

  > * env (array of strings, OPTIONAL) with the same semantics as IEEE
  >   Std 1003.1-2008's environ.

  And running execle or similar with NULL env results in an empty
  environment:

    $ cat test.c
    #include <unistd.h>

    int main()
    {
      return execle("/usr/bin/env", "env", NULL, NULL);
    }
    $ cc -o test test.c
    $ ./test
    ...no output...

  Go's Cmd.Env, on the other hand, has [2]:

  > If Env is nil, the new process uses the current process's environment.

  This commit works around that by setting []string{} in those cases
  to avoid leaking the runtime environment into the hooks.

* Roll the 'timeout' value (if set) into the passed context.  There's
  no need for two separate ways to cancel hook execution.

* Add a configurable timeout on abandoning a post-kill wait.  The
  waiting goroutine will continue and eventually reap the process, but
  this avoids blocking the Run() call when that takes inordinately
  long (for example, if a GPU cleanup hook is stuck in I/O sleep [3]).

The 'env' output format is specified in POSIX [4].

[1]: https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#posix-platform-hooks
[2]: https://golang.org/pkg/os/exec/#Cmd
[3]: https://github.com/projectatomic/libpod/pull/857#discussion_r192191002
[4]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/env.html

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

Closes: #857
Approved by: mheon
2018-05-31 21:45:27 +00:00
W. Trevor King 4dfe0d60f3 hooks: Rename Hooks() output to extensionStageHooks
To more clearly distinguish between the extensionStages input to New()
(a slice of strings) and the map output from Hooks().

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

Closes: #855
Approved by: rhatdan
2018-05-31 14:11:52 +00:00
W. Trevor King 7c1434c2f7 hooks: Allow local control of OCI stages via extensionStages
This allows callers to avoid delegating to OCI runtimes for cases
where they feel that the runtime hook handling is unreliable [1].

[1]: https://github.com/projectatomic/libpod/issues/730#issuecomment-392959938

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

Closes: #855
Approved by: rhatdan
2018-05-31 14:11:52 +00:00
Daniel J Walsh bae80a0b66 Clear all caps, except the bounding set, when --user is specified.
Currently we are giving all caps to users when running with podman run --user,
They should get none by default.  If the command line includes --cap-add, then
we need to run with those capabilties.  Similarly we need to drop caps from
bounding set, if user specifies --cap-drop

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #851
Approved by: mheon
2018-05-31 13:46:08 +00:00
Jhon Honce 8fcf1aaa29 Rename addFIPSsModeSecret to addFIPSModeSecret
Signed-off-by: Jhon Honce <jhonce@redhat.com>

Closes: #833
Approved by: mheon
2018-05-25 16:37:34 +00:00
umohnani8 c8b72e57a7 save and load should support multi-tag for docker-archive
The docker-archive tar files can have multiple tags for the same
image stored in it. Load pulls all the tags found in the archive
when loading a tar file. Save can oush multiple tags of the same
image to a tar archive.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #819
Approved by: rhatdan
2018-05-25 15:15:47 +00:00
Jhon Honce 0a4ade1c17 Implement python podman create and start
- Added alias 'container()' to image model for CreateContainer()
- Fixed return in containers_create.go to wrap error in varlink
  exception
- Added a wait time to container.kill(), number of seconds to wait
  for the container to change state
- Refactored cached_property() to use system libraries
- Refactored tests to speed up performance

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Closes: #821
Approved by: rhatdan
2018-05-25 09:31:21 +00:00
Jhon Honce 684b544e9c Spell check strings and comments
Signed-off-by: Jhon Honce <jhonce@redhat.com>

Closes: #831
Approved by: rhatdan
2018-05-25 08:45:15 +00:00
W. Trevor King a7180cd545 hooks/1.0.0: Error on empty process.args instead of panicking
The process property is optional [1], which this package already
handled appropriately, although I've added a new test here to guard
against regressions.

The process.args entry is required when process is set [2], and it's
also required to contain at least one entry [3].  The previous
implementation here assumed that would always be satisfied, and
panicked on empty process.args.  With this commit, we avoid the panic
and instead return an error message explaining why the input was
invalid.

[1]: https://github.com/opencontainers/runtime-spec/blame/v1.0.1/config.md#L145
[2]: https://github.com/opencontainers/runtime-spec/blame/v1.0.1/config.md#L157
[3]: https://github.com/opencontainers/runtime-spec/blame/v1.0.1/config.md#L158

Reported-by: Brent Baude <bbaude@redhat.com>
Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #829
Approved by: mheon
2018-05-24 21:27:05 +00:00
baude 82feafecdd podman create, start, getattachsocket
First pass at implement API endpoints for create and start.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #805
Approved by: baude
2018-05-21 19:26:56 +00:00
W. Trevor King 31e3a50ddd hooks/README: Fix some Markdown typos (e.g. missing runc target)
I'd accidentally introduced these typos in ea415610 (hooks/docs: Add
oci-hooks.5 and per-package man page building, 2018-05-15, #772).

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

Closes: #810
Approved by: mheon
2018-05-21 14:09:25 +00:00
W. Trevor King fb628380a2 oci-hooks.5: Discuss directory precedence and monitoring
We've had this functionality since 68eb128f (pkg/hooks: Version the
hook structure and add 1.0.0 hooks, 2018-04-27, #686), but didn't have
any user-facing docs for it.

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

Closes: #811
Approved by: mheon
2018-05-21 13:36:17 +00:00
W. Trevor King c45d4c6d5c hooks: Fix monitoring of multiple directories
This isn't an issue with podman, which will only ever use one
directory.  But CRI-O generally uses two directories, and we want to
make sure that changes to the fallback directory are not clobbering
hooks configured in the override directory.  More background in [1].

I've split the handling into a single-directory block and a
multiple-directory block so we don't waste time polling the filesystem
for single-directory removals.

I'm using the single-directory block for the the zero-directory case
as well.  Managers with zero directories should not be receiving
fsnotify events, so I don't think it really matters which block
handles them.  If we want to handle this case robustly (because we're
concerned about something in the hook package adjusted the private
.directories property on the fly?), then we'll probably want to add an
explicit zero-directory block in future work.

[1]: https://github.com/kubernetes-incubator/cri-o/pull/1470

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

Closes: #757
Approved by: rhatdan
2018-05-17 22:39:13 +00:00
W. Trevor King ea4156108d hooks/docs: Add oci-hooks.5 and per-package man page building
This allows us to reference the hooks docs from podman(1) in a way
that will survive system installation.  The downside is that the
GitHub rendered pages become less usable, now that we can no longer
embed links as freely as we could before.

I've followed the "Sections within a manual page" suggestions from
[1].

locale(7) is [2], which is Linux-specific.  Even section numbering is
platform-dependent [3], so it's unlikely that these external man
references are particularly portable.  Platform packagers can adjust
our local references to match their target system, but that leaves the
GitHub rendering in an awkward place.  For now, I think a
Linux-centric GitHub rendering without clickable links may be the best
we can do without moving away from go-md2man.

As far as I can tell, there's not a nice way to get go-md2man to wrap
the links in SEE ALSO without sometimes hyphenating a URL (which makes
it harder for man-page readers to copy/paste those links into their
browser).

I've also fixed some "extention" -> "extension" typos.

[1]: http://man7.org/linux/man-pages/man7/man-pages.7.html
[2]: http://man7.org/linux/man-pages/man7/locale.7.html
[3]: https://en.wikipedia.org/wiki/Man_page#Manual_sections

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

Closes: #772
Approved by: mheon
2018-05-17 18:22:10 +00:00
Nalin Dahyabhai e686269da3 chrootuser: default to GID 0 when given a numeric --user
When we're given a numeric --user value, default to GID 0 if the numeric
ID doesn't correspond to a user entry in /etc/passwd that can provide us
with the user's primary group ID.

Make sure that GetAdditionalGroupsForUser() returns wrapped errors.

Also test various user:group forms.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #728
Approved by: mheon
2018-05-17 17:05:44 +00:00
baude d870c25c01 implement varlink commit
Signed-off-by: baude <bbaude@redhat.com>

Closes: #762
Approved by: baude
2018-05-15 17:08:10 +00:00
W. Trevor King 45838b9561 hooks: Add package support for extension stages
We aren't consuming this yet, but these pkg/hooks changes lay the
groundwork for future libpod changes to support post-exit hooks [1,2].

[1]: https://github.com/projectatomic/libpod/issues/730
[2]: https://github.com/opencontainers/runc/issues/1797

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

Closes: #758
Approved by: rhatdan
2018-05-14 21:36:48 +00:00
W. Trevor King 89430ffe65 hooks: Order injection by collated JSON filename
We also considered ordering with sort.Strings, but Matthew rejected
that because it uses a byte-by-byte UTF-8 comparison [1] which would
fail many language-specific conventions [2].

There's some more discussion of the localeToLanguage mapping in [3].
Currently language.Parse does not handle either 'C' or 'POSIX',
returning:

  und, language: tag is not well-formed

for both.

[1]: https://github.com/projectatomic/libpod/pull/686#issuecomment-387914358
[2]: https://en.wikipedia.org/wiki/Alphabetical_order#Language-specific_conventions
[3]: https://github.com/golang/go/issues/25340

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

Closes: #686
Approved by: mheon
2018-05-11 16:26:35 +00:00
W. Trevor King 5676597f40 hooks/read: Ignore IsNotExist for JSON files in ReadDir
If a .json file existed when we called ioutil.ReadDir but that file
has been removed by the time we get around to calling Read on it,
silently ignore the file.  Iterating through all the files in the
directory shouldn't take particularly long, so this is an unlikely
corner case.  And when it happens, silently ignoring the file gives
the same outcome as you'd have gotten if the parallel remove had
happened slightly earlier before the ioutil.ReadDir call.

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

Closes: #686
Approved by: mheon
2018-05-11 16:26:35 +00:00
W. Trevor King 68eb128fb0 pkg/hooks: Version the hook structure and add 1.0.0 hooks
This shifts the matching logic out of libpod/container_internal and
into the hook package, where we can reuse it after vendoring into
CRI-O.  It also adds unit tests with almost-complete coverage.  Now
libpod is even more isolated from the hook internals, which makes it
fairly straightforward to bump the hook config file to 1.0.0.  I've
dubbed the old format 0.1.0, although it doesn't specify an explicit
version.  Motivation for some of my changes with 1.0.0:

* Add an explicit version field.  This will make any future JSON
  structure migrations more straightforward by avoiding the need for
  version-guessing heuristics.

* Collect the matching properties in a new When sub-structure.  This
  makes the root Hook structure easier to understand, because you
  don't have to read over all the matching properties when wrapping
  your head around Hook.

* Replace the old 'hook' and 'arguments' with a direct embedding of
  the runtime-spec's hook structure.  This provides access to
  additional upstream properties (args[0], env, and timeout) and
  avoids the complication of a CRI-O-specific analog structure.

* Add a 'when.always' property.  You can usually accomplish this
  effect in another way (e.g. when.commands = [".*"]), but having a
  boolean explicitly for this use-case makes for easier reading and
  writing.

* Replace the previous annotations array with an annotations map.  The
  0.1.0 approach matched only the values regardless of key, and that
  seems unreliable.

* Replace 'cmds' with 'when.commands', because while there are a few
  ways to abbreviate "commands", there's only one way to write it out
  in full ;).  This gives folks one less thing to remember when
  writing hook JSON.

* Replace the old "inject if any specified condition matches" with
  "inject if all specified conditions match".  This allows for more
  precise targeting.  Users that need more generous targeting can
  recover the previous behavior by creating a separate 1.0.0 hook file
  for each specified 0.1.0 condition.

I've added doc-compat support for the various pluralizations of the
0.1.0 properties.  Previously, the docs and code were not in
agreement.  More on this particular facet in [1].

I've updated the docs to point out that the annotations being matched
are the OCI config annotations.  This differs from CRI-O, where the
annotations used are the Kubernetes-supplied annotations [2,3].  For
example, io.kubernetes.cri-o.Volumes [4] is part of CRI-O's runtime
config annotations [5], but not part of the Kubernetes-supplied
annotations CRI-O uses for matching hooks.

The Monitor method supports the CRI-O use-case [6].  podman doesn't
need it directly, but CRI-O will need it when we vendor this package
there.

I've used nvidia-container-runtime-hook for the annotation examples
because Dan mentioned the Nvidia folks as the motivation behind
annotation matching.  The environment variables are documented in [7].
The 0.1.0 hook config, which does not allow for environment variables,
only works because runc currently leaks the host environment into the
hooks [8].  I haven't been able to find documentation for their usual
annotation trigger or hook-install path, so I'm just guessing there.

[1]: https://github.com/kubernetes-incubator/cri-o/pull/1235
[2]: https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/server/container_create.go#L760
[3]: https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/server/container_create.go#L772
[4]: https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/pkg/annotations/annotations.go#L97-L98
[5]: https://github.com/kubernetes-incubator/cri-o/blob/v1.10.0/server/container_create.go#L830-L834
[6]: https://github.com/kubernetes-incubator/cri-o/pull/1345/
[7]: https://github.com/NVIDIA/nvidia-container-runtime/tree/v1.3.0-1#environment-variables-oci-spec
[8]: https://github.com/opencontainers/runc/pull/1738

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

Closes: #686
Approved by: mheon
2018-05-11 16:26:35 +00:00
baude 9657cd6c15 Fix varlink remove image force
Fixes a bug where the force bool was being ignored when deleting images
via the varlink interface.

Also, minor fix to the docs to add a line break between methods and types in
the doc index.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #753
Approved by: rhatdan
2018-05-11 16:05:10 +00:00
baude 834f1f641e varlink info
The varlinfo info returns the same information as podman info but always includes
the so-called debug information.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #745
Approved by: baude
2018-05-11 14:00:25 +00:00
baude cc1bad85fe Dont eat the pull error message for varlink
When using varlink to pull an image, we should expose the actual error to the caller.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #744
Approved by: rhatdan
2018-05-10 16:11:27 +00:00
baude 0e58ec7474 podman push should honor registries.conf
Like podman pull, when you push an image, podman should check
if the registry is listed as insecure and if so, it should
--tls-verify=false unless the user overrides this.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #738
Approved by: mheon
2018-05-10 14:56:56 +00:00
baude 25263558f1 Generate varlink API documentation automatically
Using varlink's idl parser, we generate API documentation for the podman
API relying on the .varlink file as the source.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #734
Approved by: baude
2018-05-08 21:01:28 +00:00
baude 21ebdb558c Allow streaming on some varlink container methods
The following methods should support streaming requests from the client:

* GetContainerLogs

A reference for a python stream implementation can be found here:

https://github.com/varlink/python/blob/master/varlink/tests/test_orgexamplemore.py#L29-L42

Signed-off-by: baude <bbaude@redhat.com>

Closes: #724
Approved by: mheon
2018-05-08 15:44:38 +00:00
Giuseppe Scrivano 522a7197a8 podman, userNS: configure an intermediate mount namespace
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #690
Approved by: mheon
2018-05-04 17:15:55 +00:00
Daniel J Walsh b51d737998 Begin wiring in USERNS Support into podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #690
Approved by: mheon
2018-05-04 17:15:55 +00:00
baude 8dfebd4607 varlink containers
first pass at adding in the container related endpoints/methods for the libpod
backend. Couple of important notes:

* endpoints that can use a console are not going to be done until we have "remote" console
* several of the container methods should probably be able to stream as opposed to a one-off return

Signed-off-by: baude <bbaude@redhat.com>

Closes: #708
Approved by: baude
2018-05-03 17:31:33 +00:00
baude 86e0c87a29 fix typos in the inspect json structs
Resolves: #633

Signed-off-by: baude <bbaude@redhat.com>

Closes: #710
Approved by: rhatdan
2018-05-02 18:02:22 +00:00
baude 7a0a8552cb Fix misc stuff found by jhonce
During the python client implementation, jhonce found some return types
that needed correction as well as a panic related to history which is now
corrected.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #704
Approved by: rhatdan
2018-04-30 22:22:08 +00:00
baude a824186ac9 Use buildah commit and bud in podman
Vendor in buildah and use as much of commit and bug as possible for podman
build and commit.

Resolves #586
Signed-off-by: baude <bbaude@redhat.com>

Closes: #681
Approved by: mheon
2018-04-27 20:51:07 +00:00
umohnani8 51a5cdc636 Modify secrets pkg
Made a mistake in my earlier patch. I though that if you add an empty string
to an array, the length of the array would still be 0...
Realised this when vendoring the secrets pkg into cri-o.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #685
Approved by: mheon
2018-04-27 14:07:54 +00:00
baude 39a7a773a6 varlink images
implement varlink image functions for working with libpod with the exception of a
couple due to incompletions on the libpod side of things (build).

also, created a first pass at a libpodpy package which will stand as a client to
working with libpod's varlink methods using python.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #669
Approved by: baude
2018-04-26 19:14:44 +00:00
Matthew Heon 0ccfd7dc20 Retrieve IP addresses for container from DB
Instead of execing out to the host's IP, use the IP address we
got back from CNI to populate Inspect's IP address information.

Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #680
Approved by: umohnani8
2018-04-26 17:26:13 +00:00
umohnani8 6ac8a24db4 Add --default-mounts-file hidden flag
The hidden flag is used to override the path of the default mounts file
for testing purposes.
Also modified the secrets pkg to allow for this override to happen.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #678
Approved by: mheon
2018-04-26 16:33:25 +00:00
umohnani8 cf41dc70b3 Modify --user flag for podman create and run
If an integer is passed into the --user flag, i.e --user=1234
don't look up the user in /etc/passwd, just assign the integer as the uid.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #652
Approved by: mheon
2018-04-24 14:28:33 +00:00
umohnani8 57afb7514d Add FIPS mode secret
If the host is in FIPS mode and /etc/system-fips exists
/run/secrets/system-fips is created in the container so that
the container can run in FIPS mode as well.

Signed-off-by: umohnani8 <umohnani@redhat.com>
2018-04-23 13:17:12 -04:00
baude 8493dba23c Initial varlink implementation
Signed-off-by: baude <bbaude@redhat.com>

Closes: #627
Approved by: mheon
2018-04-23 14:29:45 +00:00
baude 313e5e83e9 regression: tls verify should be set on registries.conf if insecure
In the case where podman needs to pull an image, if that registry that the image
resides on is known to be insesure (as defined in /etc/containers/registries.conf),
tls-verify should be altered on the fly.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #626
Approved by: mheon
2018-04-18 14:07:59 +00:00
umohnani8 9aafc25a3d Fix secrets patch
The secrets code was just tarring and copying the contents of the secrets directory on host as is.
This meant it was not accounting for any symlinks inside the directory, leading up to the contents
not being copied over.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #611
Approved by: mheon
2018-04-13 21:25:15 +00:00
umohnani8 998fd2ece0 Functionality changes to the following flags
--group-add
	--blkio-weight-device
	--device-read-bps
	--device-write-bps
	--device-read-iops
	--device-write-iops

--group-add now supports group names as well as the gid associated with them.
All the --device flags work now with moderate changes to the code to support both
bps and iops.
Added tests for all the flags.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #590
Approved by: mheon
2018-04-06 00:09:46 +00:00
Daniel J Walsh fdcf633a33 Add hooks support to podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #155
Approved by: mheon
2018-04-05 14:13:49 +00:00
Matthew Heon 0fb38659b7 Add container dependencies to Inspect output
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #577
Approved by: rhatdan
2018-04-03 14:57:16 +00:00
Nalin Dahyabhai 94301bab8f Correct a godoc comment
Correct the names of the files in the godoc for
pkg/chrootuser/GetUser().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #579
Approved by: rhatdan
2018-04-02 20:03:17 +00:00
umohnani8 8a96b4acbc Add secrets patch to podman
Adds support for mounting secrets especially on RHEL where the container
can use the host subsription to run yum

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #544
Approved by: rhatdan
2018-03-29 14:15:27 +00:00
baude 9aba605dde Remove dependency on kubernetes
podman parse and attach were using a very small portion of the kubernetes code
but using it caused a signficant increase in binary size.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #559
Approved by: rhatdan
2018-03-27 21:55:33 +00:00
baude b85b217f55 Stage3 Image Library
This represents the stage3 implementation for the image library.  At this point, we
are moving the image-centric functions to pkg/image including migration of args and
object-oriented references.  This is a not a one-for-one migration of funcs and some
funcs will need to continue to reside in runtime_img as they are overly specific to
libpod and probably not useful to others.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #484
Approved by: baude
2018-03-14 20:21:31 +00:00
baude bc358eb396 Include tmpfs in inspect
Other container runtimes include the tmpfs mount points in their inspect
output.  Podman should as well.  It is under hostconfig.

Resolves: #483

Signed-off-by: baude <bbaude@redhat.com>

Closes: #488
Approved by: rhatdan
2018-03-14 17:14:07 +00:00
baude 4929e37507 Performance enhancement for podman images
Previous code was using slow routines to collect some of the information
needed to output images.  Specifically size was being calculated instead
of using the cached, already known size already available.  Also, straight-
lined several of the code paths.  Overall assessment is that these
improvements cut the time for images in half.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #365
Approved by: mheon
2018-02-20 21:54:32 +00:00