Commit graph

1624 commits

Author SHA1 Message Date
OpenShift Merge Robot 3e2d9f8662
Merge pull request #4352 from vrothberg/config-package
refactor libpod config into libpod/config
2019-10-31 19:21:46 +01:00
Valentin Rothberg 11c282ab02 add libpod/config
Refactor the `RuntimeConfig` along with related code from libpod into
libpod/config.  Note that this is a first step of consolidating code
into more coherent packages to make the code more maintainable and less
prone to regressions on the long runs.

Some libpod definitions were moved to `libpod/define` to resolve
circular dependencies.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-10-31 17:42:37 +01:00
OpenShift Merge Robot 381fa4df87
Merge pull request #4380 from giuseppe/rootless-create-cgroup-for-conmon
libpod, rootless: create cgroup for conmon
2019-10-30 21:42:47 +01:00
OpenShift Merge Robot 32266d155f
Merge pull request #4305 from mheon/fix_volume_mount
Wait for `mount` command to finish when mounting volume
2019-10-30 21:18:49 +01:00
Matthew Heon 3e891c1b60 Wait for mount command to finish when mounting volume
command.Start() just starts the command. That catches some
errors, but the nasty ones - bad options and similar - happen
when the command runs. Use CombinedOutput() instead - it waits
for the command to exit, and thus catches non-0 exit of the
`mount` command (invalid options, for example).

STDERR from the `mount` command is directly used, which isn't
necessarily the best, but we can't really get much more info on
what went wrong.

Fixes #4303

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-30 14:41:16 -04:00
Giuseppe Scrivano 78e2a31943
libpod, rootless: create cgroup for conmon
always create a new cgroup for conmon also when running as rootless.
We were previously creating one only when necessary, but that behaves
differently than root containers.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-30 17:04:05 +01:00
OpenShift Merge Robot 2e8eb8403d
Merge pull request #4372 from rhatdan/exec
Processes execed into container should match container label
2019-10-30 14:29:54 +01:00
Daniel J Walsh 0b9e07f7f2
Processes execed into container should match container label
Processes execed into a container were not being run with the correct label.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-10-29 16:05:42 -04:00
Daniel J Walsh 66c126d6de Set default seccomp.json file for podman play kube
Currently podman play kube is not using the system default seccomp.json file.
This PR will use the default or override location for podman play.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-10-29 13:43:45 -04:00
Nalin Dahyabhai 248bb61b14 images: distinguish between tags and digests
Generate an image's RepoDigests list using all applicable digests, and
refrain from outputting a digest in the tag column of the "images"
output.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
Nalin Dahyabhai 07195ff09f API: report multiple digests for images
Be prepared to report multiple image digests for images which contain
multiple manifests but, because they continue to have the same set of
layers and the same configuration, are considered to be the same image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
Nalin Dahyabhai b9313d355e pull/create: add --override-arch/--override-os flags
Add --override-arch and --override-os as hidden flags, in line with the
global flag names that skopeo uses, so that we can test behavior around
manifest lists without having to conditionalize more of it by arch.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
Nalin Dahyabhai 803357334c image: don't get confused by lists
When an image can be opened as an ImageSource but not an Image, handle
the case where it's an image list all by itself, the case where it's an
image for a different architecture/OS combination, or the case where
it's both.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
Nalin Dahyabhai a4a70b4506 bump containers/image to v5.0.0, buildah to v1.11.4
Move to containers/image v5 and containers/buildah to v1.11.4.

Replace an equality check with a type assertion when checking for a
docker.ErrUnauthorizedForCredentials in `podman login`.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:18 -04:00
OpenShift Merge Robot 59582c55b7
Merge pull request #3792 from haircommander/minimum-conmon
require conmon v2.0.1
2019-10-29 17:44:52 +01:00
OpenShift Merge Robot 8e264ca572
Merge pull request #4350 from giuseppe/slirp4netnslog
libpod: if slirp4netns fails, return its stderr
2019-10-29 09:01:48 +01:00
Giuseppe Scrivano 795460f7b0
libpod: if slirp4netns fails, return its output
read the slirp4netns stderr and propagate it in the error when the
process fails.

Replace: https://github.com/containers/libpod/pull/4338

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-29 07:13:50 +01:00
Peter Hunt 306f7cb9f5 require conmon v2.0.1
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-10-28 16:13:58 -04:00
Peter Hunt 57fa6cf756 require conmon v2.0.0
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-10-28 16:13:58 -04:00
OpenShift Merge Robot 1b5c2d1440
Merge pull request #4355 from mheon/ensure_state
Add ensureState helper for checking container state
2019-10-28 19:59:35 +01:00
OpenShift Merge Robot 49bd51e12f
Merge pull request #4331 from mheon/sane_rename_error
Return a better error for volume name conflicts
2019-10-28 19:13:12 +01:00
Matthew Heon 5f8bf3d07d Add ensureState helper for checking container state
We have a lot of checks for container state scattered throughout
libpod. Many of these need to ensure the container is in one of a
given set of states so an operation may safely proceed.
Previously there was no set way of doing this, so we'd use unique
boolean logic for each one. Introduce a helper to standardize
state checks.

Note that this is only intended to replace checks for multiple
states. A simple check for one state (ContainerStateRunning, for
example) should remain a straight equality, and not use this new
helper.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-10-28 13:09:01 -04:00
Giuseppe Scrivano 0d5d6dab57
systemd: mask /sys/fs/cgroup/systemd/release_agent
when running in systemd mode on cgroups v1, make sure the
/sys/fs/cgroup/systemd/release_agent is masked otherwise the container
is able to modify it and execute scripts on the host.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-25 21:50:29 +02:00
OpenShift Merge Robot 77c7a28a72
Merge pull request #4333 from giuseppe/error-rootless-cni
rootless: raise an error with --network=
2019-10-24 21:29:53 +02:00
Giuseppe Scrivano 8f75b3e8c9
rootless: raise an error with --network=
Closes: https://github.com/containers/libpod/issues/4332

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-24 20:14:24 +02:00
OpenShift Merge Robot 674dc2bc75
Merge pull request #4228 from giuseppe/detect-no-systemd-session
rootless: detect no system session with --cgroup-manager=systemd
2019-10-24 01:20:25 +02:00
Matthew Heon 84eea2b2c0 Return a better error for volume name conflicts
When you try and create a new volume with the name of a volume
that already exists, you presently get a thoroughly unhelpful
error from `mkdir` as the volume attempts to create the
directory it will be mounted at. An EEXIST out of mkdir is not
particularly helpful to Podman users - it doesn't explain that
the name is already taken by another volume.

The solution here is potentially racy as the runtime is not
locked, so someone else could take the name while we're still
getting things set up, but that's a narrow timing window, and we
will still return an error - just an error that's not as good as
this one.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-23 16:34:32 -04:00
Giuseppe Scrivano 13fe146840
rootless: detect no system session with --cgroup-manager=systemd
if the cgroup manager is set to systemd, detect if dbus is available,
otherwise fallback to --cgroup-manager=cgroupfs.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-23 09:26:54 +02:00
Matthew Heon f60a814e4d Add parsing for UID, GID in volume "o" option
Everything else is a flag to mount, but "uid" and "gid" are not.
We need to parse them out of "o" and handle them separately.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-22 14:32:54 -04:00
OpenShift Merge Robot d358840ebe
Merge pull request #4287 from mheon/anonymous_volumes
Add support for anonymous volumes to `podman run -v`
2019-10-22 14:50:28 +02:00
OpenShift Merge Robot 5431aceb0a
Merge pull request #4313 from haircommander/unused-var
exec: remove unused var
2019-10-22 02:08:01 +02:00
Peter Hunt 06850ea2c0 exec: remove unused var
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-10-21 17:04:27 -04:00
OpenShift Merge Robot efc54c3987
Merge pull request #4284 from mheon/fix_vol_inspect
Show volume options in 'volume inspect'
2019-10-21 22:20:40 +02:00
OpenShift Merge Robot d2591a5433
Merge pull request #4309 from giuseppe/write-storage-overrides
rootless: write storage overrides to the conf file
2019-10-21 22:02:57 +02:00
Giuseppe Scrivano fa9982b87e
rootless: write storage overrides to the conf file
make sure the user overrides are stored in the configuration file when
first created.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-21 12:07:21 +02:00
Matthew Heon 6456f6da17 Show volume options in 'volume inspect'
We initialized the map to show them, but didn't actually copy
them in, so they weren't being displayed.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-10-18 13:42:31 -04:00
Matthew Heon 0d623914d0 Add support for anonymous volumes to podman run -v
Previously, when `podman run` encountered a volume mount without
separate source and destination (e.g. `-v /run`) we would assume
that both were the same - a bind mount of `/run` on the host to
`/run` in the container. However, this does not match Docker's
behavior - in Docker, this makes an anonymous named volume that
will be mounted at `/run`.

We already have (more limited) support for these anonymous
volumes in the form of image volumes. Extend this support to
allow it to be used with user-created volumes coming in from the
`-v` flag.

This change also affects how named volumes created by the
container but given names are treated by `podman run --rm` and
`podman rm -v`. Previously, they would be removed with the
container in these cases, but this did not match Docker's
behaviour. Docker only removed anonymous volumes. With this patch
we move to that model as well; `podman run -v testvol:/test` will
not have `testvol` survive the container being removed by `podman
rm -v`.

The sum total of these changes let us turn on volume removal in
`--rm` by default.

Fixes: #4276

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-17 13:18:17 -04:00
Giuseppe Scrivano 64f53b4f02
rootless: do not enable lingering mode
do not automatically enable lingering mode.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-17 19:12:10 +02:00
OpenShift Merge Robot 8172460f2a
Merge pull request #4273 from mheon/no_runtime
Add a MissingRuntime implementation
2019-10-16 11:05:45 +02:00
OpenShift Merge Robot 7b54aeb6e3
Merge pull request #4272 from baude/rootlesstatsnet
rootless v2 cannot collect network stats
2019-10-16 10:48:22 +02:00
OpenShift Merge Robot 1137c1084b
Merge pull request #4256 from mheon/fix_volumes
Ensure volumes can be removed when they fail to unmount
2019-10-16 10:20:27 +02:00
Matthew Heon cab7bfbb21 Add a MissingRuntime implementation
When a container is created with a given OCI runtime, but then it
is uninstalled or removed from the configuration file, Libpod
presently reacts very poorly. The EvictContainer code can
potentially remove these containers, but we still can't see them
in `podman ps` (aside from the massive logrus.Errorf messages
they create).

Providing a minimal OCI runtime implementation for missing
runtimes allows us to behave better. We'll be able to retrieve
containers from the database, though we still pop up an error for
each missing runtime. For containers which are stopped, we can
remove them as normal.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-15 15:59:20 -04:00
baude f10f9bc58f rootless v2 cannot collect network stats
network statistics cannot be collected for rootless network devices with
the current implementation.  for now, we return nil so that stats will
at least for users.

Fixes:#4268

Signed-off-by: baude <bbaude@redhat.com>
2019-10-15 14:09:41 -05:00
Valentin Rothberg 019f19cf4f inspect: rename ImageID go field to Image
The json field is called `Image` while the go field is called `ImageID`,
tricking users into filtering for `Image` which ultimately results in an
error.  Hence, rename the field to `Image` to align json and go.

To prevent podman users from regressing, rename `Image` to `ImageID` in
the specified filters.  Add tests to prevent us from regressing.  Note
that consumers of the go API that are using `ImageID` are regressing;
ultimately we consider it to be a bug fix.

Fixes: #4193
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-10-15 12:16:47 +02:00
Daniel J Walsh 25572cefa8
Merge pull request #4262 from nalind/error-cause
Unwrap errors before comparing them
2019-10-15 06:06:45 -04:00
Nalin Dahyabhai 17a7596af4 Unwrap errors before comparing them
Unwrap errors before directly comparing them with errors defined by the
storage and image libraries.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-14 13:49:06 -04:00
Matthew Heon 0f6b0e8c9c Ensure volumes can be removed when they fail to unmount
Also, ensure that we don't try to mount them without root - it
appears that it can somehow not error and report that mount was
successful when it clearly did not succeed, which can induce this
case.

We reuse the `--force` flag to indicate that a volume should be
removed even after unmount errors. It seems fairly natural to
expect that --force will remove a volume that is otherwise
presenting problems.

Finally, ignore EINVAL on unmount - if the mount point no longer
exists our job is done.

Fixes: #4247
Fixes: #4248

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-14 10:32:15 -04:00
Valentin Rothberg 2d2646883f change error wording when conmon fails without logs
In some cases, conmon can fail without writing logs.  Change the wording
of the error message from

	"error reading container (probably exited) json message"
to
	"container create failed (no logs from conmon)"

to have a more helpful error message that is more consistent with other
errors at that stage of execution.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-10-14 13:46:10 +02:00
OpenShift Merge Robot 79d05b99cf
Merge pull request #4220 from mheon/null_runtime
Move OCI runtime implementation behind an interface
2019-10-11 20:55:37 +02:00
OpenShift Merge Robot cee6478f9e
Merge pull request #4221 from mheon/reset_runtime
Migrate can move containers to a user-defined runtime
2019-10-11 19:56:13 +02:00