Commit graph

910 commits

Author SHA1 Message Date
Daniel J Walsh a6108f1c19
Add support for RunAsUser and RunAsGroup
Currently podman generate kube does not generate the correct RunAsUser and RunAsGroup
options in the yaml file.  This patch fixes this.

This patch also make `podman play kube` use the RunAdUser and RunAsGroup options if
they are specified in the yaml file.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-11-06 10:35:37 -05:00
OpenShift Merge Robot b4b727256c
Merge pull request #4370 from rhatdan/seccomp
Set SELinux labels based on the security context in the kube.yaml
2019-11-05 21:52:22 +01:00
Giuseppe Scrivano b8514ca6f3
namespaces: by default create cgroupns on cgroups v2
change the default on cgroups v2 and create a new cgroup namespace.

When a cgroup namespace is used, processes inside the namespace are
only able to see cgroup paths relative to the cgroup namespace root
and not have full visibility on all the cgroups present on the
system.

The previous behaviour is maintained on a cgroups v1 host, where a
cgroup namespace is not created by default.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-05 17:29:01 +01:00
Daniel J Walsh 65ed819932
Set SELinux labels based on the security context in the kube.yaml
If the kube.yaml specifieds the SELinux type or Level, we need the container
to be launched with the correct label.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-11-05 04:09:01 -05:00
Giuseppe Scrivano 11750df510
logs: support --tail 0
change the default to -1, so that we can change the semantic of
"--tail 0" to not print any existing log line.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-31 19:55:36 +01:00
OpenShift Merge Robot 1e750f7ca8
Merge pull request #4394 from vrothberg/fix-start
container start: fix regression when using name
2019-10-31 19:03:08 +01:00
Valentin Rothberg dc3e3af256 container start: fix regression when using name
When starting a container by using its name as a reference, we should
print the name instead of the ID.  We regressed on this behaviour
with commit b4124485ae which made it into Podman v1.6.2.

Kudos to openSUSE testing for catching it.  To prevent future
regressions, extend the e2e tests to check the printed container
name/ID.

Reported-by: @sysrich
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-10-31 14:24:41 +01:00
Daniel J Walsh 0eea8fbc46
Fix selinux test for exec
We want to make sure that the process label of pid 1 is the same as the process label of a process execed into the container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-10-31 08:38:56 -04: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
OpenShift Merge Robot a35d002b72
Merge pull request #4376 from giuseppe/drop-ostree
build: drop support for ostree
2019-10-30 15:49:26 +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
OpenShift Merge Robot 7318b0e8c7
Merge pull request #4369 from baude/golandautocodecorrections
goland autocorrections
2019-10-30 14:29:46 +01:00
Giuseppe Scrivano 2046be6ae0
build: drop support for ostree
it is going to be removed from containers/image as well, so no longer
depend on it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-30 11:28:10 +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
Nalin Dahyabhai 05c65e88e3 Add e2e tests for manifest list support
Test that when we pull using tag or digest references from locations
that are manifest lists, that we can inspect using the references that
we used for pulling, that the tags show up in the RepoTag list when we
inspect an image that was pulled using a tag, and that the list and
instance digests always both show up in the RepoDigest list.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-10-29 13:35:19 -04:00
baude 91baaee9a8 goland autocorrections
just ran the autocorrect code corrections from goland and it found a few
nits.

Signed-off-by: baude <bbaude@redhat.com>
2019-10-29 12:18:50 -05:00
OpenShift Merge Robot a56131fef4
Merge pull request #4110 from mheon/fix_sigproxy_tests
Fix sig-proxy=false test and use image cache
2019-10-29 15:13:29 +01:00
OpenShift Merge Robot 299a430759
Merge pull request #4329 from mheon/no_noexec_image_volume
Image volumes should not be mounted noexec
2019-10-24 01:07:51 +02:00
OpenShift Merge Robot 4b8832a9af
Merge pull request #4298 from mheon/uid_gid_options
Add parsing for UID, GID in volume "o" option
2019-10-24 01:07:43 +02:00
Matthew Heon 57eaea9539 Image volumes should not be mounted noexec
This matches Docker more closely, but retains the more important
protections of nosuid/nodev.

Fixes #4318

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-23 12:09:22 -04:00
Valentin Rothberg 77a2bbb1c0 stats: list all running containers unless specified otherwise
Unless specified otherwise by --all, --latest or via arguments, list all
running containers.  This matches the behaviour of Docker and is also
illustrated in the man pages where containers and options are marked to
be optional.

Fixes: #4274
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-10-23 13:48:54 +02:00
Matthew Heon 224d805db7 Fix sig-proxy=false test and use image cache
Pulling fedora-minimal was potentially causing timeouts, which is
bad. Using the cache avoids that.

Sig-proxy=false test was entirely nonfunctional - I think we
didn't update it when we fixed sig-proxy=true to be less racy.
It was still passing, which is concerning.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-10-22 16:17:29 -04: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 efc54c3987
Merge pull request #4284 from mheon/fix_vol_inspect
Show volume options in 'volume inspect'
2019-10-21 22:20:40 +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
OpenShift Merge Robot 123e034892
Merge pull request #4241 from haircommander/kube-test-refactor
play kube: refactor test suite
2019-10-18 15:52:56 +02:00
Alex Jia 774a36d177 System tests: make sure exec pid hash w/o leaking
podman exec leaks an exec_pid_<hash> file for every exec in tmpfs,
it's known rhbz#1731117, this case makes sure leakage issue has
been fixed.

rhbz: https://bugzilla.redhat.com/show_bug.cgi?id=1731117

Signed-off-by: Alex Jia <chuanchang.jia@gmail.com>
2019-10-18 15:04:09 +08: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
Jhon Honce 60d0be17fc Refactor tests when checking for error exit codes
Rather than checking for non-zero, we need to check for >0 to
distinguish between timeouts and error exit codes.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-10-16 08:10:07 -07: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
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
Giuseppe Scrivano 71410ff073
images: empty list is valid json with --format=json
similar change to f7d55d64e7

with images --format=json, be sure the output is valid json also when
it is an empty list.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-11 21:56:40 +02:00
OpenShift Merge Robot b0b3506621
Merge pull request #4238 from giuseppe/rootless-enable-ps-size-tests
tests: enable ps --size tests for rootless
2019-10-11 21:30:25 +02:00
Peter Hunt e0fda971da play kube: Container->Ctr
for berevity

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-10-11 14:28:14 -04:00
Peter Hunt 6ad4fb0c49 play kube: refactor test suite
The play kube test suite has many different cases to cover, and should only grow in coverage over time
The old design was difficult to extend, and there was lots of duplicated code.
The largest pain point was the Container struct needed to be changed often, and doing so caused changes every test case

Instead, adopt the `withOption` idiom. Now, adding a new option for customizing just involves adding a new withOption function, and changing the struct definition and initialization in one place.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-10-11 13:12:01 -04:00
OpenShift Merge Robot eb6ca054fc
Merge pull request #4237 from giuseppe/ps-not-null
container: initialize results list
2019-10-11 18:53:26 +02:00
Giuseppe Scrivano c731131c86
tests: enable ps --size tests for rootless
rootless podman is using a single user namespace for all the containers
so it can safely access the storage for all of them.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-11 17:19:52 +02:00
Giuseppe Scrivano f7d55d64e7
container: initialize results list
it solves:

$ podman ps --format=json
null

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-11 16:52:18 +02:00
OpenShift Merge Robot fd389d28ce
Merge pull request #4206 from giuseppe/systemd-mode-look-full-path
systemd: expect full path /usr/sbin/init
2019-10-10 14:58:41 -07:00
OpenShift Merge Robot cec8edd6f5
Merge pull request #4181 from cevich/start_test_slower_poll
Raise start_test polling interval
2019-10-10 14:58:34 -07:00
Giuseppe Scrivano 3ba3e1c751
systemd: expect full path /usr/sbin/init
"init" is a quite common name for the command executed in a container
image and Podman ends up using the systemd mode also when not
required.

Be stricter on enabling the systemd mode and not enable it
automatically when the basename is "init" but expect the full path
"/usr/sbin/init".

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-10-09 23:38:45 +02:00
Mrigank Krishan c5e26f8e40 podman network create: validate user input
Disallow invalid/confusing names such as '../bar' or 'foo '
Closes #4184

Signed-off-by: Mrigank Krishan <mrigankkrishan@gmail.com>
2019-10-04 02:34:01 +05:30
OpenShift Merge Robot 86c8650c23
Merge pull request #4174 from cevich/use_bash_not_sh
System-tests: Use bash explicitly
2019-10-03 11:28:58 -07:00
Chris Evich 584c70a9f8
Raise start_test polling interval
According to the documentation
https://onsi.github.io/gomega/#eventually

> the default value for the polling interval is 10 milliseconds

That is excessively fast given the observed failures in
issue #4021 are always using podman-remote.  Lower the interval to
3-seconds, which should be plenty long enough for container removal.

Signed-off-by: Chris Evich <cevich@redhat.com>
2019-10-03 12:08:36 -04:00
Ed Santiago 0ed9763b72 system tests: info: deal with hyphen in username
...e.g. cloud-user. 9822f54ac was intended to fix this,
but it doesn't. Simple and standard solution is to
move the dash to the end of the character class.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-10-03 07:55:41 -06:00
Chris Evich c091374d77
System-tests: Use bash explicitly
On Ubuntu, /bin/sh != /bin/bash.  Update system-tests to only use
bash for testing consistency across platforms.

Signed-off-by: Chris Evich <cevich@redhat.com>
2019-10-02 14:32:31 -04:00
Ed Santiago 6c0b5a2fab system tests: reenable skipped tests
Issue #3829 (cp symlinks) has been fixed: enable tests for it

And, it looks like podman-remote is now handling exit status
of a force-rm'ed container. Enable that test too.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-10-02 06:22:36 -06:00
OpenShift Merge Robot 2c23729c84
Merge pull request #4001 from kunalkushwaha/podman-import-fix
podman import syntax fix
2019-09-30 07:20:09 -07:00