Commit graph

242 commits

Author SHA1 Message Date
Daniel J Walsh e42d920ebf
Add LogSize to container inspect
Other log options are available so we need to add ability to look
up LogSize.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-12-15 17:22:06 -05:00
Ed Santiago 4d7e05f9ba RHEL gating tests: more journald exceptions
Followup to #8284, due to my not having noticed #8096.

RHEL gating tests are failing again due to rhbz#1895105, the
one where we can't run journalctl rootless on RHEL. #8284 fixed
this for some RHEL builds of older podman, but I missed #8096
which added yet another logs test.

This brings us to three journalctl exceptions, which means
it gets complicated because I have to refactor it all.

**THIS IS NOT SUSTAINABLE**. We need some way to have a similar
setup in CI, with a permission-less rootless login, so we don't
add yet another logs test some day and discover, months later,
that it doesn't work on RHEL and then have to go into crisis
mode.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-14 06:40:46 -07:00
OpenShift Merge Robot 6db3e9bfeb
Merge pull request #8653 from rhatdan/buildah
Honor the --layers flag
2020-12-09 14:58:28 -05:00
Paul Holzinger 2870a0b0a6 Add system test for shell completion
There exists a unit test to ensure that shell completion functions are
defined. However there was no check about the quality of the provided
shell completions. Lets change that.

The idea is to create a general test that makes sure we are suggesting
containers,pods,images... for the correct commands. This works by
reading the command use line and checking for each arg if we provide
the correct suggestions for this arg.

It includes the following tests:
- flag suggestions if [options] is set
- container, pod, image, network, volume, registry completion
- path completion for the appropriate arg KEYWORDS (`PATH`,`CONTEXT`,etc.)
- no completion if there are no args
- completion for more than one arg if it ends with `...]`

The test does not cover completion values for flags and not every arg KEYWORD
is supported. This is still a huge improvement and covers most use cases.

This test spotted several inconsistencies between the completion and the
command use line. All of them have been adjusted to make the test pass.

The biggest advantage is that the completions always match the latest
command changes. So if someone changes the arguments for a command this
ensures that the completions must be adjusted.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-12-09 19:13:28 +01:00
Daniel J Walsh 0154f9e9b3
Honor the --layers flag
Currently the --layers flag set by the user is ignored, and only the BUILDAH_LAYERS
environment variable being set is observed.

Fixes: https://github.com/containers/podman/issues/8643

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-12-09 08:31:36 -05:00
OpenShift Merge Robot 9b3a81a002
Merge pull request #8571 from Luap99/podman-network-reload
Implement pod-network-reload
2020-12-08 06:15:40 -05:00
Matthew Heon b0286d6b43 Implement pod-network-reload
This adds a new command, 'podman network reload', to reload the
networks of existing containers, forcing recreation of firewall
rules after e.g. `firewall-cmd --reload` wipes them out.

Under the hood, this works by calling CNI to tear down the
existing network, then recreate it using identical settings. We
request that CNI preserve the old IP and MAC address in most
cases (where the container only had 1 IP/MAC), but there will be
some downtime inherent to the teardown/bring-up approach. The
architecture of CNI doesn't really make doing this without
downtime easy (or maybe even possible...).

At present, this only works for root Podman, and only locally.
I don't think there is much of a point to adding remote support
(this is very much a local debugging command), but I think adding
rootless support (to kill/recreate slirp4netns) could be
valuable.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-12-07 19:26:23 +01:00
Valentin Rothberg 9cd0efbb5c add comment to #8558 regression test
As suggested by @edsantiago, add a comment to the regression test
of #8558 to better document the context.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-12-07 14:37:27 +01:00
Valentin Rothberg f294d89b5c container create: do not clear image name
When creating a container, do not clear the input-image name before
looking up image names.  Also add a regression test.

Fixes: #8558
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-12-07 11:58:10 +01:00
OpenShift Merge Robot 0f496e4b81
Merge pull request #8570 from vrothberg/run-950
rewrite container copy
2020-12-04 13:33:36 -05:00
OpenShift Merge Robot f01630acf3
Merge pull request #8476 from rhatdan/containerenv
Add containerenv information to /run/.containerenv
2020-12-04 11:56:24 -05:00
Valentin Rothberg ccbca0b4ab rewrite podman-cp
* Add a new `pkg/copy` to centralize all container-copy related code.

* The new code is based on Buildah's `copier` package.

* The compat `/archive` endpoints use the new `copy` package.

* Update docs and an several new tests.

* Includes many fixes, most notably, the look-up of volumes and mounts.

Breaking changes:

 * Podman is now expecting that container-destination paths exist.
   Before, Podman created the paths if needed.  Docker does not do
   that and I believe Podman should not either as it's a recipe for
   masking errors.  These errors may be user induced (e.g., a path
   typo), or internal typos (e.g., when the destination may be a
   mistakenly unmounted volume).  Let's keep the magic low for such
   a security sensitive feature.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-12-04 14:39:55 +01:00
Chih-Hsuan Yen e58fb21ced
Support Unix timestamps for podman logs --since
To match what podman-logs(1) describes --since

Signed-off-by: Chih-Hsuan Yen <yan12125@gmail.com>
2020-12-04 15:14:31 +08:00
Daniel J Walsh d9154e97eb
Add containerenv information to /run/.containerenv
We have been asked to leak some information into the container
to indicate:
* The name and id of the container
* The version of podman used to launch the container
* The image name and ID the container is based on.
* Whether the container engine is running in rootless mode.

Fixes: https://github.com/containers/podman/issues/6192

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-12-03 13:32:15 -05:00
OpenShift Merge Robot 38a44acd20
Merge pull request #8564 from edsantiago/bats
BATS: add new load test
2020-12-03 01:25:54 +01:00
OpenShift Merge Robot 5cf7aa65fb
Merge pull request #8408 from umohnani8/sec-opt
Add mask and unmask option to --security-opt
2020-12-03 00:49:23 +01:00
Ed Santiago c8ab4c878f BATS: add new load test
Looks like #7337 was fixed (by #8112). Reenable a disabled
test for it; and make it actually work. Confirmed that
newly-added test fails on d45676549 (the commit before #8112).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-02 14:45:51 -07:00
Urvashi Mohnani 0334b61958 Add mask and unmask option to --security-opt
Add the mask and unmask option to the --security-opt flag
to allow users to specify paths to mask and unmask in the
container. If unmask=ALL, this will unmask all the paths we
mask by default.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2020-12-02 16:07:18 -05:00
Jhon Honce 2a02833e9f Fix podman images... missing headers in table templates
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-12-02 10:50:37 -07:00
Ed Santiago a17fb01d40 BATS: add ping test
- run test : tweaks to recently-added network-conflict test:
   * remove "-d" in run
   * confirm exact warning text, and also that container
     runs successfully
   * test multiple --net options (regression #8057)

 - images, run, build, exec tests: add multiple-flag
   testing for various flags, confirming as appropriate
   whether options are overridden or accumulated.

 - ps test : add --filter and --sort tests

 - pod test: run 'ping' inside container (confirms that
   container gets PING capability)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-01 08:14:54 -07:00
OpenShift Merge Robot f24812ac3b
Merge pull request #8230 from mheon/port_net_host_conflict
Ensure that --net=host/pod/container conflicts with -p
2020-11-30 19:41:26 +01:00
Ed Santiago a4c2471944 system tests: various
- images: confirm that 'podman images' emits headings
  even if there are no images present. Intended to
  replace e2e test which is difficult to get working
  under podman-remote.

- build: add test for #8092, podman-build gobbling stdin.
  Workaround needed for issues #8342 and #8343, in which
  podman-remote output differs from podman local.

- volumes: add test for #8307, double-lock on same volume.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-11-14 14:55:48 -07:00
Daniel J Walsh c69565d83c
test for buildah version in container images.
Check to see if we are recording the version of buildah
used to build the image as a label in the image.

Also we should make sure the filter "since" works.
We are only testing "after", which we don't document.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-13 03:54:08 -05:00
Ed Santiago c62c64856e system tests: skip journald tests on RHEL8
(actually, on any system exhibiting the symptom wherein
journalctl fails due to insufficient permissions, which
for all practical purposes means only RHEL8)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-11-09 13:44:44 -07:00
Daniel J Walsh 6ca705bf1a
Add support for mounting external containers
Continue progress on use of external containers.

This PR adds the ability to mount, umount and list the
storage containers whether they are in libpod or not.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-04 13:52:08 -05:00
Matthew Heon a4da384b55 Ensure that --net=host/pod/container/none warn with -p
Setting port mappings only works when CNI is configuring our
network (or slirp4netns, in the rootless case). This is not the
case with `--net=host`, `--net=container:`, and joining the
network namespace of the pod we are part of. Instead of allowing
users to do these things and then be confused why they do
nothing, let's match Docker and return a warning that your port
mappings will do nothing.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-11-04 13:42:58 -05:00
OpenShift Merge Robot 1fe79dd677
Merge pull request #8177 from rhatdan/wrap
Stop excessive wrapping of errors
2020-10-30 19:52:17 +01:00
Daniel J Walsh 831d7fb0d7
Stop excessive wrapping of errors
Most of the builtin golang functions like os.Stat and
os.Open report errors including the file system object
path. We should not wrap these errors and put the file path
in a second time, causing stuttering of errors when they
get presented to the user.

This patch tries to cleanup a bunch of these errors.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-30 05:34:04 -04:00
Daniel J Walsh 916825b675
Pod's that share the IPC Namespace need to share /dev/shm
Containers that share IPC Namespaces share each others
/dev/shm, which means a private /dev/shm needs to be setup
for the infra container.

Added a system test and an e2e test to make sure the
/dev/shm is shared.

Fixes: https://github.com/containers/podman/issues/8181

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-30 05:21:34 -04:00
OpenShift Merge Robot 228396a99d
Merge pull request #8174 from rhatdan/errors
Podman often reports OCI Runtime does not exist, even if it does
2020-10-29 22:21:17 +01:00
Valentin Rothberg 65a618886e new "image" mount type
Add a new "image" mount type to `--mount`.  The source of the mount is
the name or ID of an image.  The destination is the path inside the
container.  Image mounts further support an optional `rw,readwrite`
parameter which if set to "true" will yield the mount writable inside
the container.  Note that no changes are propagated to the image mount
on the host (which in any case is read only).

Mounts are overlay mounts.  To support read-only overlay mounts, vendor
a non-release version of Buildah.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-10-29 15:06:22 +01:00
Daniel J Walsh 0f191ad72c
Podman often reports OCI Runtime does not exist, even if it does
When the OCI Runtime tries to set certain settings in cgroups
it can get the error "no such file or directory",  the wrapper
ends up reporting a bogus error like:

```
 Request Failed(Internal Server Error): open io.max: No such file or directory: OCI runtime command not found error
{"cause":"OCI runtime command not found error","message":"open io.max: No such file or directory: OCI runtime command not found error","response":500}
```

On first reading of this, you would think the OCI Runtime (crun or runc) were not found.  But the error is actually reporting

message":"open io.max: No such file or directory

Which is what we want the user to concentrate on.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-29 06:19:21 -04:00
Ed Santiago c93d4be41e System tests: cleanup, make more robust
- run test: preserve --runtime test: use a random executable
  path. And, clean up better.

- run test: "look up correct image name" test: use random
  strings; test both without and with a :tag

- events test: use random label strings, add more filter tests

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-26 13:29:15 -06:00
OpenShift Merge Robot bce8331528
Merge pull request #8096 from ypu/log-driver-test
Tests: Check different log driver can work with podman logs
2020-10-25 10:46:44 -04:00
baude c593e49701 filter events by labels
adding the ability to filter evens by the container labels.  this requires that container labels be added to the events data being recorded and subsequently read.

Signed-off-by: baude <bbaude@redhat.com>
2020-10-23 12:07:34 -05:00
OpenShift Merge Robot 8e06f8efbc
Merge pull request #8053 from rhatdan/detachkeys
podman create doesn't support creating detached containers
2020-10-22 16:29:28 -04:00
OpenShift Merge Robot 2cb12bbc5a
Merge pull request #8098 from vrothberg/fix-8082
container create: record correct image name
2020-10-22 11:03:46 -04:00
Yiqiao Pu 8e66795530 Tests: Check different log driver can work with podman logs
Add a check step in podman run --log-driver test. Prefer to add
it here as it already has a loop to cover all different drivers
in this test.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
2020-10-22 14:38:28 +08:00
Daniel J Walsh 15345ce4c3
podman create doesn't support creating detached containers
Detached containers and detach keys are only created with the podman run, i
exec, and start commands.  We do not store the detach key sequence or the
detach flags in the database, nor does Docker. The current code was ignoreing
these fields but documenting that they can be used.

Fix podman create man page and --help output to no longer indicate that
--detach and --detach-keys works.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-21 21:00:50 -04:00
Valentin Rothberg 410fa53f89 container create: record correct image name
Record the correct image name when creating a container by using the
resolved image name if present.  Otherwise, default to using the first
available name or an empty string in which case the image must have been
referenced by ID.

Fixes: #8082
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-10-21 16:51:09 +02:00
Daniel J Walsh 980b1e87d4
Switch use of Flags to Options
Want to have man pages match commands, since we have lots of printed
man pages with using Options, we will change the command line to use
Options in --help.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-21 08:37:57 -04:00
Ed Santiago f5b3dc976c Tests: Fix common flakes, and improve apiv2 test log
- apiv2 - the 'ten /info requests' test is flaking often,
  taking ~8 seconds (our limit is 7, up from 5 a few weeks
  ago). Brent suggested that the first /info call might be
  expensive, because it needs to access storage. So, let's
  prime it by running one /info outside the timing loop.
  And, because even that continues to fail, bump it up
  to 10 seconds and file #8076 to track the slowdown.

- toolbox test - WaitForReady() has timed out, even on one
  occasion causing a run failure because it failed 3 times.
  Solution: bump up timeout from 2s to 5s. Not really great,
  but CI systems are underpowered, and it's not unreasonable
  that 2s might be too low.

- sdnotify test - add a 'podman wait' between stop & rm.
  This may prevent a "cannot rm container as it is running"
  race condition.

While working on this, Brent and I noticed a few ways that
test-apiv2 logging can be improved:

- test name: when request is POST, display the jsonified
  parameters, not the original input ones. This should
  make it much easier to reproduce failures.

- use curl's "--write-out" option to capture http code,
  content type, and request time. We were getting the
  first two via grep from logged headers; this is cleaner.
  And there was no other way to get timing. We now include
  the timing as X-Response-Time in the log file.

- abort on *any* curl error, not just 7 (cannot connect).
  Any error at all from curl is bad news.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-20 11:32:49 -06:00
Matthew Heon 1b4933376f Add a system test to verify --runtime is preserved
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-10-20 09:24:32 -04:00
Ed Santiago b23d430516 System tests: remove some misleading 'run's
The BATS 'run' directive is really quite obnoxious; for the
most part we really don't want to use it. Remove some uses
that snuck in last week, and remove one test (exists) that
can more naturally be piggybacked into an rm test.

While we're at it: in setup(), look for and delete stray
external (buildah) containers. This will be important if
any of the external-container tests fails; this way we
don't leave behind a state that causes subsequent tests
to fail.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-19 08:43:56 -06:00
Daniel J Walsh db23e12611
Add support for external container
External containers are containers created outside of Podman.
For example Buildah and CRI-O Containers.

$ buildah from alpine
alpine-working-container
$ buildah run alpine-working-container touch /test
$ podman container exists --external alpine-working-container

$ podman container diff alpine-working-container
C /etc
A /test

Added --external flag to refer to external containers, rather then --storage.

Added --external for podman container exists and modified podman ps to use
--external rather then --storage.  It was felt that --storage would confuse
the user into thinking about changing the storage driver or options.

--storage is still supported through the use of aliases.

Finally podman contianer diff, does not require the --external flag, since it
there is little change of users making the mistake, and would just be a pain
for the user to remember the flag.

podman container exists --external is required because it could fool scripts
that rely on the existance of a Podman container, and there is a potential
for a partial deletion of a container, which could mess up existing users.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-15 09:51:31 -04:00
Daniel J Walsh 22c8270135
fix podman container exists and diff for storage containers
Current these commands only check if a container exists in libpod. With
this fix, the commands will also check if they are in containers/storage.

This allows users to look at differences within a buildah or CRI-O container.

Currently buildah diff does not exists, so this helps out in that situation
as well as in CRI-O since the cri does not implement a diff command.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-15 09:51:15 -04:00
Ed Santiago 1646da834c System test additions
- run --userns=keep-id: confirm that $HOME gets set (#8013)

 - inspect: confirm that JSON output is a sane number of
   lines (10 or more), not an unreadable one-liner (#8011
   and #8021). Do so with image, pod, network, volume
   because the code paths might be different.

 - cgroups: confirm that 'run' preserves cgroup manager (#7970)

 - sdnotify: reenable tests, and hope CI doesn't hang. This
   test was disabled on August 18 because CI jobs were hanging
   and timing out. My suspicion was that it was #7316, which
   in turn seems to have hinged on conmon #182. The latter
   was merged on Sep 16, so let's cross our fingers and see
   what happens.

Also: remove inaccurate warning from a networking test.

And, wow, fix is_cgroupsv2(), it has never actually worked.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-14 15:32:02 -06:00
OpenShift Merge Robot 04674298bd
Merge pull request #7949 from edsantiago/bats
system tests: cleanup, and add more tests
2020-10-12 06:13:14 -04:00
OpenShift Merge Robot fa01b838a6
Merge pull request #7891 from rhatdan/rm
This PR allows users to remove external containers directly
2020-10-09 10:55:15 -04:00
Daniel J Walsh fea78d5530
This PR allows users to remove external containers directly
Currenly if a user specifies the name or ID of an external storage
container, we report an error to them.

buildah from scratch
working-container-2
podman rm working-container-2
Error: no container with name or ID working-container-2 found: no such container

Since the user specified the correct name and the container is in storage we
force them to specify --storage to remove it. This is a bad experience for the
user.

This change will just remove the container from storage.  If the container
is known by libpod, it will remove the container from libpod as well.

The podman rm --storage option has been deprecated, and removed from docs.

Also cleaned documented options that are not available to podman-remote.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-09 06:06:08 -04:00