Commit graph

1544 commits

Author SHA1 Message Date
baude 4f0e095b23 fix trivial type for event logger
Fixes: #4062

Signed-off-by: baude <bbaude@redhat.com>
2019-09-19 18:20:01 -05:00
Daniel J Walsh 34d22a4e5c
Fix exit code failure
Be less precise on the exit code and lot the exit code to the journal when it fails.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-09-17 12:01:02 -04:00
OpenShift Merge Robot 1a1ff98896
Merge pull request #4035 from mheon/unmount_unmounted_is_safe
Unmounting a container that is already unmounted is OK
2019-09-16 23:34:16 +02:00
OpenShift Merge Robot 42e080bcd3
Merge pull request #4043 from haircommander/preserve-fd-fix
exec: fix --preserve-fds
2019-09-16 23:23:59 +02:00
Peter Hunt 5f97721afc exec: fix --preserve-fds
There were two problems with preserve fds.
libpod didn't open the fds before passing _OCI*PIPE to conmon. This caused libpod to talk on the preserved fds, rather than the pipes, with conmon talking on the pipes. This caused a hang.
Libpod also didn't convert an int to string correctly, so it would further fail.

Fix these and add a unit test to make sure we don't regress in the future

Note: this test will not pass on crun until crun supports --preserve-fds

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-09-16 15:27:00 -04:00
Giuseppe Scrivano 7c3428de26
networking: use --enable-sandbox if available
if slirp4netns supports sandboxing, enable it.

It automatically creates a new mount namespace where slirp4netns will
run and have limited access to the host resources.

It needs slirp4netns 0.4.1.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-09-16 16:42:11 +02:00
Matthew Heon cabe1345f8 Unmounting a container that is already unmounted is OK
We should not be throwing errors because the operation we wanted
to perform is already done. Now, it is definitely strange that a
container is actually unmounted, but shows as mounted in the DB -
if this reoccurs in a way where we can investigate, it's worth
tearing into.

Fixes #4033

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-09-16 09:22:26 -04:00
OpenShift Merge Robot e8a44ebd46
Merge pull request #4006 from rhatdan/rootless
Report errors when trying to pause rootless containers
2019-09-13 18:44:45 +02:00
OpenShift Merge Robot 7875e00c66
Merge pull request #3934 from rhatdan/wait
Podman-remote run should wait for exit code
2019-09-13 18:12:25 +02:00
Daniel J Walsh 88ebc33840
Report errors when trying to pause rootless containers
If you are running a rootless container on cgroupV1
you can not pause the container.  We need to report the proper error
if this happens.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-09-13 08:29:46 -04:00
OpenShift Merge Robot b095d8a794
Merge pull request #4010 from haircommander/regsiter-later
exec: Register resize func a bit later
2019-09-13 00:55:10 +02:00
OpenShift Merge Robot 20772182e6
Merge pull request #4009 from baude/execrmsocket
clean up after healthcheck execs
2019-09-12 23:23:08 +02:00
OpenShift Merge Robot 42332a3ea2
Merge pull request #3989 from mheon/storage_containers_add_info
Add further fields to StorageContainer
2019-09-12 22:23:17 +02:00
Daniel J Walsh 82ac0d8925
Podman-remote run should wait for exit code
This change matches what is happening on the podman local side
and should eliminate a race condition.

Also exit commands on the server side should start to return to client.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-09-12 16:20:01 -04:00
Daniel J Walsh 535111b5d5
Use exit code constants
We have leaked the exit number codess all over the code, this patch
removes the numbers to constants.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-09-12 16:20:01 -04:00
Peter Hunt 1dcb771dbd exec: Register resize func a bit later
if we register the resize func too early, it attempts to read from the 'ctl' file before it exists. this causes the func to error, and the resize to not go through.

Fix this by registering resize func later for conmon. This, along with a conmon fix, will allow exec to know the terminal size at startup

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-09-12 16:14:30 -04:00
baude 7b68cd0b3d clean up after healthcheck execs
when executing a healthcheck, we were not cleaning up after exec's use
of a socket.  we now remove the socket file and ignore if for reason it
does not exist.

Fixes: #3962

Signed-off-by: baude <bbaude@redhat.com>
2019-09-12 14:30:46 -05:00
OpenShift Merge Robot 8c3349bc08
Merge pull request #3959 from giuseppe/rootless-use-systemd-scope
rootless: automatically create a systemd scope
2019-09-12 19:04:07 +02:00
Giuseppe Scrivano a249c98db8
linux: fix systemd with --cgroupns=private
When --cgroupns=private is used we need to mount a new cgroup file
system so that it points to the correct namespace.

Needs: https://github.com/containers/crun/pull/88

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-09-12 14:33:26 +02:00
Giuseppe Scrivano afd0818326
rootless: automatically create a systemd scope
when running in rootless mode and using systemd as cgroup manager
create automatically a systemd scope when the user doesn't own the
current cgroup.

This solves a couple of issues:

on cgroup v2 it is necessary that a process before it can moved to a
different cgroup tree must be in a directory owned by the unprivileged
user.  This is not always true, e.g. when creating a session with su
-l.

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

Also, for running systemd in a container it was before necessary to
specify "systemd-run --scope --user podman ...", now this is done
automatically as part of this PR.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-09-12 08:35:26 +02:00
Matthew Heon 3c277a67d5 Add further fields to StorageContainer
This will be used when we allow 'podman ps' to display info on
storage containers instead of Libpod containers.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-09-11 10:53:21 -04:00
Matthew Heon 5ddfe5d95d Volume lookup needs to include state to unmarshal into
Lookup was written before volume states merged, but merged after,
and CI didn't catch the obvious failure here. Without a valid
state, we try to unmarshall into a null pointer, and 'volume rm'
is completely broken because of it.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-11 10:17:28 -04:00
OpenShift Merge Robot 093013b099
Merge pull request #3984 from mheon/prune_no_in_use_error
Do not prune images being used by a container
2019-09-11 15:31:15 +02:00
OpenShift Merge Robot 9cf852c305
Merge pull request #3927 from openSUSE/manager-annotations
Add `ContainerManager` annotation to created containers
2019-09-11 09:34:14 +02:00
OpenShift Merge Robot 7ac6ed3b4b
Merge pull request #3581 from mheon/no_cgroups
Support running containers without CGroups
2019-09-11 00:58:46 +02:00
OpenShift Merge Robot 997c4b56ed
Merge pull request #3961 from mheon/copy_volume_contents
When first mounting any named volume, copy up
2019-09-10 22:24:43 +02:00
Matthew Heon 3e92bcbf71 Do not prune images being used by a container
Podman is not the only user of containers/storage, and as such we
cannot rely on our database as the sole source of truth when
pruning images. If images do not show as in use from Podman's
perspective, but subsequently fail to remove because they are
being used by a container, they're probably being used by Buildah
or another c/storage client.

Since the images in question are in use, we shouldn't error on
failure to prune them - we weren't supposed to prune them in the
first place.

Fixes: #3983

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-10 13:30:50 -04:00
Matthew Heon c2284962c7 Add support for launching containers without CGroups
This is mostly used with Systemd, which really wants to manage
CGroups itself when managing containers via unit file.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-10 10:52:37 -04:00
Sascha Grunert df036f9f8e
Add ContainerManager annotation to created containers
This change adds the following annotation to every container created by
podman:

```json
"Annotations": {
    "io.containers.manager": "libpod"
}
```

Target of this annotaions is to indicate which project in the containers
ecosystem is the major manager of a container when applications share
the same storage paths. This way projects can decide if they want to
manipulate the container or not. For example, since CRI-O and podman are
not using the same container library (libpod), CRI-O can skip podman
containers and provide the end user more useful information.

A corresponding end-to-end test has been adapted as well.

Relates to: https://github.com/cri-o/cri-o/pull/2761

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-09-10 09:37:14 +02:00
Matthew Heon b6106341fb When first mounting any named volume, copy up
Previously, we only did this for volumes created at the same time
as the container. However, this is not correct behavior - Docker
does so for all named volumes, even those made with
'podman volume create' and mounted into a container later.

Fixes #3945

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-09 17:17:39 -04:00
Matthew Heon 046178e55f Add function for looking up volumes by partial name
This isn't included in Docker, but seems handy enough.

Use the new API for 'volume rm' and 'volume inspect'.

Fixes #3891

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-09 12:06:10 -04:00
OpenShift Merge Robot 290def5b92
Merge pull request #3960 from mheon/ignore_umount_enoent
Ignore ENOENT on umount of SHM
2019-09-06 17:31:04 +02:00
OpenShift Merge Robot 575ffee2f0
Merge pull request #3918 from rhatdan/info
Return information about mount_program (fuse-overlayfs)
2019-09-06 16:45:25 +02:00
Matthew Heon 77f9234513 Ignore ENOENT on umount of SHM
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-06 10:25:53 -04:00
OpenShift Merge Robot 24171ae060
Merge pull request #3954 from mheon/hardcode_default_storepaths
Ensure good defaults on blank c/storage configuration
2019-09-06 14:01:59 +02:00
Daniel J Walsh b2b284111e
Return information about mount_program (fuse-overlayfs)
We want to get podman info to tell us about the version of
the mount program to help us diagnose issues users are having.

Also if in rootless mode and slirp4netns is installed reveal package
info on slirp4netns.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-09-06 07:32:42 -04:00
Matthew Heon 3a09956dff Ensure good defaults on blank c/storage configuration
If c/storage paths are explicitly set to "" (the empty string) it
will use compiled-in defaults. However, it won't tell us this via
`storage.GetDefaultStoreOptions()` - we just get the empty string
(which can put our defaults, some of which are relative to
c/storage, in a bad spot).

Hardcode a sane default for cases like this. Furthermore, add
some sanity checks to paths, to ensure we don't use relative
paths for core parts of libpod.

Fixes #3952

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-05 17:47:11 -04:00
Matthew Heon de9a394fcf Correctly report errors on unmounting SHM
When we fail to remove a container's SHM, that's an error, and we
need to report it as such. This may be part of our lingering
storage woes.

Also, remove MNT_DETACH. It may be another cause of the storage
removal failures.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-05 17:12:27 -04:00
Matthew Heon a760e325f3 Add ability for volumes with options to mount/umount
When volume options and the local volume driver are specified,
the volume is intended to be mounted using the 'mount' command.
Supported options will be used to volume the volume before the
first container using it starts, and unmount the volume after the
last container using it dies.

This should work for any local filesystem, though at present I've
only tested with tmpfs and btrfs.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-05 17:12:27 -04:00
Matthew Heon 5a8a71ed81 Add volume state
We need to be able to track the number of times a volume has been
mounted for tmpfs/nfs/etc volumes. As such, we need a mutable
state for volumes. Add one, with the expected update/save methods
in both states.

There is backwards compat here, in that older volumes without a
state will still be accepted.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-05 12:29:36 -04:00
Matthew Heon c8193633cd Change volume driver and options JSON tags
In upcoming commits, we're going to turn on the backends for
these fields. Volumes with these set will act fundamentally
differently from other volumes. There will probably be validation
required for each field.

Until now, though, we've freely allowed creation of volumes with
these set - they just did nothing. So we have no idea what could
be in the DB with old volumes.

Change the struct tags so we don't have to worry about old,
unvalidated data. We'll start fresh with new volumes.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-09-05 12:29:36 -04:00
OpenShift Merge Robot ab44484bec
Merge pull request #3876 from mheon/fix_mount_flags
Allow suid, exec, dev mount options to cancel nosuid/noexec/nodev
2019-09-04 22:43:41 +02:00
OpenShift Merge Robot 52f2454098
Merge pull request #3933 from giuseppe/skip-polling-on-run
libpod: avoid polling container status
2019-09-04 22:33:06 +02:00
Giuseppe Scrivano 8e337aff5a
libpod: avoid polling container status
use the inotify backend to be notified on the container exit instead
of polling continuosly the runtime.  Polling the runtime slowns
significantly down the podman execution time for short lived
processes:

$ time bin/podman run --rm -ti fedora true

real	0m0.324s
user	0m0.088s
sys	0m0.064s

from:

$ time podman run --rm -ti fedora true

real	0m4.199s
user	0m5.339s
sys	0m0.344s

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-09-04 19:55:54 +02:00
baude 8818e358bf handle dns response from cni
when cni returns a list of dns servers, we should add them under the
right conditions.  the defined conditions are as follows:

- if the user provides dns, it and only it are added.
- if not above and you get a cni name server, it is added and a
forwarding dns instance is created for what was in resolv.conf.
- if not either above, the entries from the host's resolv.conf are used.
Signed-off-by: baude <bbaude@redhat.com>

Signed-off-by: baude <bbaude@redhat.com>
2019-09-03 10:10:05 -05:00
Matthew Heon 5bdd97f77f Set base mount options for bind mounts from base system
If I mount, say, /usr/bin into my container - I expect to be able
to run the executables in that mount. Unconditionally applying
noexec would be a bad idea.

Before my patches to change mount options and allow exec/dev/suid
being set explicitly, we inferred the mount options from where on
the base system the mount originated, and the options it had
there. Implement the same functionality for the new option
handling.

There's a lot of performance left on the table here, but I don't
know that this is ever going to take enough time to make it worth
optimizing.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-08-28 14:28:18 -04:00
Matthew Heon 02264d597f Add support for 'exec', 'suid', 'dev' mount flags
Previously, we explicitly set noexec/nosuid/nodev on every mount,
with no ability to disable them. The 'mount' command on Linux
will accept their inverses without complaint, though - 'noexec'
is counteracted by 'exec', 'nosuid' by 'suid', etc. Add support
for passing these options at the command line to disable our
explicit forcing of security options.

This also cleans up mount option handling significantly. We are
still parsing options in more than one place, which isn't good,
but option parsing for bind and tmpfs mounts has been unified.

Fixes: #3819
Fixes: #3803

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-08-28 14:28:18 -04:00
OpenShift Merge Robot bdf9e56813
Merge pull request #3893 from mheon/readd_volume_locks
Re-add volume locks
2019-08-28 11:25:12 -07:00
OpenShift Merge Robot ced3ebb512
Merge pull request #3728 from mheon/systemd_container_test
Add an integration test for systemd in a container
2019-08-28 11:25:05 -07:00
Matthew Heon e563f41116 Re-add locks to volumes.
This will require a 'podman system renumber' after being applied
to get lock numbers for existing volumes.

Add the DB backend code for rewriting volume configs and use it
for updating lock numbers as part of 'system renumber'.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-08-28 11:35:00 -04:00