Commit graph

339 commits

Author SHA1 Message Date
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
Jhon Honce b490905f26 Port commands to V2 --format 'table...'
* 'containers mount'
 * 'image history'
 * 'images mount'
 * 'images search'
 * Correct spelling errors

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-10-07 10:40:30 -07:00
Ed Santiago 0ab9e39064 system tests: cleanup, and add more tests
- images test: add test for 'table' and '\t' formatting

 - image mount test: check output from 'umount', test
   repeat umount (NOP), and test invalid-umount

 - kill test: remove kludgy workaround for crun signal bug
   ref: #5004 -- code is no longer needed (fingers crossed),
   and the workaround involved pulling an expensive image.

 - selinux test: add new tests for shared context in:
   * pods , w/ and w/o infra container (ref: #7902)
   * containers with namespace sharing: --ipc, --pid, --net

 - selinux test: new test for --pid=host (disabled pending
   propagation of container-selinux-2.146, ref: #7939)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-07 10:43:02 -06:00
Daniel J Walsh ccc5bc167f
Attempt to turn on some more remote tests
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-07 10:19:08 -04:00
OpenShift Merge Robot 01c7ae6407
Merge pull request #7856 from rhatdan/root
podman-remote does not support most of the global flags
2020-10-02 16:37:43 -04:00
OpenShift Merge Robot 1132bcfeb5
Merge pull request #7893 from ashley-cui/journald
Fix Podman logs reading journald
2020-10-02 14:24:53 -04:00
OpenShift Merge Robot 1784f4f338
Merge pull request #7873 from edsantiago/logformatter_env
logformatter: add Synopsis at top of each page
2020-10-02 11:24:31 -04:00
Ashley Cui c0d1954663 Fix Podman logs reading journald
A podman could not read logs written to journald properly, due to a tail config bug.
Added a system test to check this - since e2e tests don't like journald

Signed-off-by: Ashley Cui <acui@redhat.com>
2020-10-02 10:05:19 -04:00
Daniel J Walsh b3f17936aa
podman-remote does not support most of the global flags
podman-remote --help is showing a bunch of global flags that it
does not support

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-02 06:32:17 -04:00
Ed Santiago d380ba0394 logformatter: add Synopsis at top of each page
At the top of each generated page, add a Synopsis table with:

  PR number/name, and link to github
  Author name(s)
  Test name (fedora/ubuntu, rootless, etc)
  Cirrus build ID (usually uninteresting)
  Cirrus task ID (usu. important), with link to Cirrus
  The value of $SPECIALMODE

This is all we can get from the Cirrus environment in
which logformatter runs; we can't get things like
cgroup manager or username that the test runs under.

Note that the table is at the top, which is usually
unseen because we autoscroll to the bottom on
page load. I tentatively think that top is a more
natural place for this info than bottom, but am
willing to listen to arguments against.

Also, one minor tweak: highlight podman commands in
the BATS output. The idea is to make it easier for the eye
to spot those, then copy/paste them to find a reproducer.

And, sigh, disable the new 'podman network create'
system test. It is flaking much too much.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-10-01 20:33:20 -06:00
Valentin Rothberg 7951a7f13a system test: untag all test
Extend the system tests to test `podman untag $image` without further
arguments to force removing all tags from the image.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-10-01 18:34:08 +02:00
OpenShift Merge Robot f86e01ab10
Merge pull request #7820 from giuseppe/fix-capabilities-not-root
capabilities: always set ambient and inheritable
2020-09-30 17:22:54 +00:00
Giuseppe Scrivano 703381b4a2
capabilities: always set ambient and inheritable
change capabilities handling to reflect what docker does.

Bounding: set to caplist
Inheritable: set to caplist
Effective: if uid != 0 then clear; else set to caplist
Permitted: if uid != 0 then clear; else set to caplist
Ambient: clear

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-09-30 15:14:07 +02:00
OpenShift Merge Robot 08d036cbd4
Merge pull request #7825 from rhatdan/exitcode
Fix handling of remove of bogus volumes, networks and Pods
2020-09-30 11:33:19 +00:00
OpenShift Merge Robot b68b6f334d
Merge pull request #7832 from edsantiago/bats_run_tz
System tests: add podman run --tz
2020-09-30 00:24:55 +00:00
Daniel J Walsh 22474095ab
Fix handling of remove of bogus volumes, networks and Pods
In podman containers rm and podman images rm, the commands
exit with error code 1 if the object does not exists.

This PR implements similar functionality to volumes, networks, and Pods.

Similarly if volumes or Networks are in use by other containers, and return
exit code 2.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-29 15:52:43 -04:00
Ed Santiago 258ccfc3c9 System tests: add podman run --tz
New tests for podman run --tz=EXPLICIT and =local. Requires
updating our testimage by adding a fixed reference timestamp
to a known file path.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-29 12:23:58 -06:00
Ed Santiago 81d9ba59db System tests: corner case for run --pull
Obscure corner case in which 'podman run --pull=never alpine'
will actually pass *with no alpine image* if there's an
image named "myalpine". (i.e. a substring match, not full
string match). Fixed in #7770 but the tests that were added
there do not actually test that.

This adds a double-duty test for that as well as making
sure that 'run --pull=never SHORTNAME' (implicit :latest)
does not match our existing :YYYYMMDD image; then one
more quick test to make sure that if we tag as :latest,
the same --pull=never succeeds.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-29 10:56:40 -06:00
Ed Santiago f732e2edcb Gating-test fix: deal with new crun error msg
crun changed an error message:

   https://github.com/containers/crun/pull/439

It's a good change, absolutely the right thing to do, but
it broke gating tests. Fix tests so they handle both old
and new format.

Fixes: #7814

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-29 06:20:21 -06:00
OpenShift Merge Robot 4a7fb62adc
Merge pull request #7803 from edsantiago/bats
System tests: reenable some skipped tests
2020-09-29 01:45:20 +00:00
Ed Santiago 1f78d33f76 System tests: reenable some skipped tests
- pause test: enable when rootless + cgroups v2
   (was previously disabled for all rootless)

 - run --pull: now works with podman-remote
   (in #7647, thank you @jwhonce)

 - various other run/volumes tests: try reenabling
   It looks like #7195 was fixed (by #7451? I'm not
   sure if I'm reading the conversation correctly).
   Anyway, remove all the skip()s on 7195. Only time
   will tell if it's really fixed)

Also:

 - new test for podman image tree --whatrequires
   (because TIL). Doesn't work with podman-remote.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-28 13:59:42 -06:00
Paul Holzinger 1db49d95b7 Journald log driver test
Test that the journald log driver writes to journald and
that we can read it with journalctl.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-28 20:48:12 +02:00
OpenShift Merge Robot b9d77796c0
Merge pull request #7687 from edsantiago/bats
system tests: new tests
2020-09-25 16:06:07 +00:00
OpenShift Merge Robot 0839300a71
Merge pull request #7758 from edsantiago/test_log_driver
system tests: new test for run --log-driver
2020-09-24 16:57:05 +00:00
Ed Santiago e628487525 system tests: helpers: safer parse_table
The parse_table() helper has until now dumbly split lines
on every single '|' character. This prevents us from running
simple tests such as 'cgroupManager: (systemd|cgroupfs)'.

We now use an ugly but robust sed expression to split
on '|' but *only* when surrounded by spaces and/or beginning
or end of line. This is safe because, for readability, all
tables already keep the '|' symbols well separated from
table content.

Add tests. And, the whole reason behind this, add
an actual real test for cgroupManager and cgroupVersion.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-23 16:38:05 -06:00
Ed Santiago b60bb3b622 system tests: new test for run --log-driver
Tests all (current) values for --log-driver=X, and one test
for invalid value. For those drivers that write a local
file (json-file, k8s-file), test that the file exists and
contains results of the expected form (timestamp, stdout,
'F' for 'F'ull line, and the expected string output.

For json-file, confirm that podman issues a "Choosing k8s-file"
warning (only on local. On podman-remote, the warning goes only
to the server's stderr).

Written in response to #7754 in which driver=json-file was
falling through to 'none' instead of 'k8s-file'.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-23 15:16:54 -06:00
OpenShift Merge Robot 2270be1871
Merge pull request #7729 from mheon/info_cgroup_manager
Include cgroup manager in `podman info` output
2020-09-22 21:00:57 +00:00
Matthew Heon 99386c7ae7 Include cgroup manager in podman info output
This is very useful for debugging cgroups v2, especially on
rootless - we need to ensure people are correctly using systemd
cgroups in these cases.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-09-22 13:15:01 -04:00
Valentin Rothberg 78afe67e00 podman save: fix redirect of multi-images
Fix a bug when saving multi-image archives where the progress bars from
copying images was accidentally written to the archive and hence
corrupted it.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-22 17:04:38 +02:00
Ed Santiago bd3c66fc81 system tests: new tests
- podman network create: new test

- podman pull by-sha + podman images -a (#7651)

- podman image mount: new test

- podman pod: --infra-image and --infra-command (#7167)

For convenience and robustness, build a new testimage
containing a custom file /home/podman/testimage-id
with contents YYYYMMDD (same as image tag). The
image-mount test checks that this file exists and
has the desired content. New testimage also includes
a dummy 'pause' executable, for testing pod infra.

Updates from testimage:20200902 to :20200917

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-19 15:55:00 -06:00
OpenShift Merge Robot b9c47fa40b
Merge pull request #7636 from vrothberg/fix-7407
run/create: record raw image
2020-09-16 09:00:47 +02:00
OpenShift Merge Robot e7af517914
Merge pull request #7633 from edsantiago/minus_l_with_other_args
Usability: prevent "-l" with arguments
2020-09-15 19:58:19 +02:00
Valentin Rothberg ce6efadd5c run/create: record raw image
Record the user-specified "raw" image name in the SpecGenerator, so we
can pass it along to the config when creating a container.  We need a
separate field as the image name in the generator may be set to the
ID of the previously pulled image - ultimately the cause of #7404.

Reverting the image name from the ID to the user input would not work
since "alpine" for pulling iterates over the search registries in the
registries.conf but looking up "alpine" normalizes to
"localhost/alpine".

Recording the raw-image name directly in the generator was the best of
the options I considered as no hidden magic from search registries or
normalizations (that may or may not change in the future) can interfere.
The auto-update backend enforces that the raw-image name is a
fully-qualified reference, so we need to worry about that in the front
end.

Fixes: #7407
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-15 13:33:22 +02:00
Ed Santiago 2583948f72 Usability: prevent "-l" with arguments
Add new system check confirming that "podman foo -l arg"
throws an error; and fix lots of instances where code
was not doing this check.

I'll probably need to add something similar for --all but
that can wait.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-14 15:49:28 -06:00
Jhon Honce 146c68f3ac Refactor API build endpoint to be more compliant
* Refactor/Rename channel.WriteCloser() to encapsulate the channel
* Refactor build endpoint to "live" stream buildah output channels
  over API rather then buffering output
* Refactor bindings/tunnel build because endpoint changes
  * building tar file now in bindings rather then depending on
    caller
* Cleanup initiating extra image engine
* Remove setting fields to zero values (less noise in code)
* Update tests to support remote builds

Fixes #7136
Fixes #7137

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-09-14 13:46:59 -07:00
OpenShift Merge Robot d7db1da789
Merge pull request #7600 from rhatdan/codespell
Fix up errors found by codespell
2020-09-11 11:30:05 -04:00
OpenShift Merge Robot 881f2dfe92
Merge pull request #7403 from QiWang19/runtime-flag
Add global options --runtime-flags
2020-09-11 11:00:11 -04:00
Daniel J Walsh 526f01cdf5
Fix up errors found by codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-11 06:14:25 -04:00
Ed Santiago 1cb7bdc8a0 system tests: cleanup
- run tests: better "skip" message for docker-archive test;
  remove FIXME, document that podman-remote doesn't support it

- run tests: instrument the --conmon-pidfile test in hopes
  of tracking down flake #7580: cross-check pidfile against
  output of 'podman inspect', and add some debug messages
  that will only be seen on test failure.

- load tests: the pipe test: save and load a temporary tag,
  not $IMAGE. Primary reason is because of #7371, in which
  'podman load' assigns a new image ID (instead of preserving
  the saved one). This messes with our image management, and
  it turns out to be nonfixable.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-10 14:29:08 -06:00
OpenShift Merge Robot 8d78605929
Merge pull request #7574 from vrothberg/fix-7117
remote run: consult events for exit code
2020-09-10 13:10:48 -04:00
Valentin Rothberg 5c44ebf96e remote run: consult events for exit code
After attaching to a container, we wait for the container to finish and
return its exit code.  Waiting for the container may not always succeed,
for instance, when the container has been force removed by another
process.  In such case, we have to look at the *last* container-exit
event.

Also refactor the `ContainerRun` method a bit to return early on errors
and de-spaghetti the code.

Enable the remote-disabled system test.

Fixes: #7117
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-10 10:06:48 +02:00
Valentin Rothberg fce2eaa6ca remote kill: don't wait for the container to stop
Invert the branch logic to match the comment.  Docker seems to wait for
the container while Podman does not.

Enable the remote-disabled system test as well.

Fixes: #7135
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-09-09 14:38:28 +02:00
OpenShift Merge Robot 814784c5e6
Merge pull request #7564 from Luap99/remote-subcmds-usage
Don't setup the Image/ContainerEngine when calling a cmd with subcmds
2020-09-08 17:21:55 -04:00
Paul Holzinger ea71f613e6 Don't setup the Image/ContainerEngine when calling a cmd with subcmds
There is no need to setup the image and container engine when calling
a command with subcommands since we only print a usage message.
e.g `podman`,`podman container`

This also allows the remote client to show the usage message on
these commands without a running endpoint. I added a test for this.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-09-08 21:05:11 +02:00
Ed Santiago a9dbd2b3de Migrate away from docker.io
CI and system tests currently pull some images from docker.io.
Eliminate that, by:

  - building a custom image containing much of what we need
    for testing; and
  - copying other needed images to quay.io

(Reason: effective 2020-11-01 docker.io will limit the
number of image pulls).

The principal change is to create a new quay.io/libpod/testimage,
using the new test/system/build-testimage script, instead of
relying on quay.io/libpod/alpine_labels. We also switch to
using a hardcoded :YYYYMMDD tag, instead of :latest, in an
attempt to futureproof our CI. This image includes 'httpd'
from busybox-extras, which we use in our networking test
(previously we had to pull and run busybox from docker.io).

The testimage can and should be extended as needed for future
tests, e.g. adding test file content or other useful tools.

For the '--pull' tests which require actually pulling from
the registry, I've created an image with the same name but
tagged :00000000 so it will never be pulled by default.
Since this image is only used minimally, it's just busybox.

Unfortunately there remain two cases we cannot solve in
this tiny alpine-based image:

  1) docker registry
  2) systemd

For those, I've (manually) run:

    podman pull [ docker.io/library/registry:2.7 | registry.fedoraproject.org/fedora:31 ]
    podman tag !$ quay.io/...
    podman push !$

...and amended the calling tests accordingly.

I've tried to make the the smallest reasonable diff, not the
smallest possible one. I hope it's a reasonable tradeoff.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-09-08 06:06:06 -06:00
OpenShift Merge Robot ba8d0bb5e3
Merge pull request #7437 from openSUSE/rm
Just use `rm` for helper command to remove storage
2020-09-06 06:46:07 -04:00
Qi Wang 6b0864434a Add global options --runtime-flags
Add global options --runtime-flags for setting options to container runtime.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-09-04 15:04:36 -04:00
Sascha Grunert 773bbffd7f
Just use rm for helper command to remove storage
This allows to use any kind of `rm` in `$PATH` for the system tests.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-28 12:17:46 +02:00
Ed Santiago 4060b77157 BATS: fix corner case in --userns=keep-id test
The test that does 'adduser' in a keep-id container had a
really dumb bug: if the user running the test has UID 1000,
then podman itself (via keep-id) will add the "1000" passwd
entry, and the in-container "adduser" will allocate 1001,
making our test fail. This triggered in f31/f32 podman gating
tests, but (?!?) never in rawhide gating tests.

Solution: explicitly feed a UID to adduser. Make sure that
it's not the same as the UID of the current user.

Also (unrelated): fix a ridiculous "run mkdir || die". At
the time I wrote that I probably had no idea how BATS works.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-27 12:58:13 -06:00
Sascha Grunert 3c4f945425
Remove test comment for now succeeding tests
The related issue seems fixed so the test execution should work as
intended.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-25 15:26:34 +02:00
Ed Santiago d254fa4c35 system tests: enable more remote tests; cleanup
info, images, run, networking tests: remove some skip_if_remote()s
that were added in the varlink days. All of these tests now seem
to work with APIv2.

help test: check that first output line from 'podman --help'
is the program description (regression check for #7273).

load test: clean up stray images, rewrite test to make it conform
to existing convention. In the process, discover and file #7337

exec test (and networking): file #7360, and add FIXME comment
to skip()s suggesting evaluating those tests once that is fixed.

pod test: now that #6328 is fixed, use 'podman pod inspect --format'
instead of relying on jq

Various other tests: add an explanation of why test is disabled
so we can more easily distinguish "this will never be meaningful
under remote" vs "hey, doesn't work for now, but maybe someday".

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-19 08:12:14 -06:00
Paul Holzinger d9f0c48176 fix podman version output to include git commit and builttime
Add the go module version v2 to the libpod path.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-18 20:37:18 +02:00
Ed Santiago 18f36d8cf6 Re-disable sdnotify tests to try to fix CI
Some CI tests are hanging, timing out in 60 or 120 minutes.
I wonder if it's #7316, the bug where all podman commands
hang forever if NOTIFY_SOCKET is set?

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-18 07:21:47 -06:00
OpenShift Merge Robot 47108e2e09
Merge pull request #7333 from openSUSE/bashify
Use `bash` binary from env instead of /bin/bash for scripts
2020-08-17 12:24:58 +02:00
Sascha Grunert ba9f18e2b8
Use bash binary from env instead of /bin/bash for scripts
It's not possible to run any of the scripts on distributions which do
have `bash` not in `/bin`. This is being fixed by using `/usr/bin/env
bash` instead.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-17 10:42:23 +02:00
Ed Santiago 60ab5f3ae6 system tests: enable sdnotify tests
Oops. PR #6693 (sdnotify) added tests, but they were disabled
due to broken crun on f31. I tried for three weeks to get a
magic CI:IMG PR to update crun on the CI VMs ... but in that
time I forgot to actually enable those new tests.

This PR removes a 'skip', replacing it with a check that systemd
is running plus one more to make sure our runtime is crun. It
looks like sdnotify just doesn't work on Ubuntu (it hangs), and
my guess is that it's a crun/runc issue.

I also changed the test image from fedora:latest to :31, because,
sigh, fedora:latest removed the systemd-notify tool.

WARNING WARNING WARNING: the symptom of a missing systemd-notify
is that podman will hang forever, not even stopped by the timeout
command in podman_run! (Filed: #7316). This means that if the
sdnotify-in-container test ever fails, the symptom will be that
Cirrus itself will time out (2 hours?). This is horrible. I
don't know what to do about it other than push for a fix for 7316.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-13 19:16:25 -06:00
Qi Wang 49dea06037 podman save use named pipe
podman save uses named pipe as output path, not directly using /dev/stdout.
fix #7017

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-08-12 10:03:41 -04:00
Brent Baude be41c58f25 Replace deepcopy on history results
the deepcopy in the remote history code path was throwing an uncaught error on a type mismatch.  we now manually do the conversion and fix the type mismatch on the fly.

Fixes: #7122

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-11 12:19:17 -05:00
Jhon Honce c60b695e64 Default .Repository and .Tag values to <none>
Refactor the processing of Repository and Tag fields to default to <none>
when printing via --format flag. Previously, the default format would
print <none> but --format {{.Tag}} would not in some cases.

Fixes #7123

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-10 08:03:58 -07:00
Ed Santiago 3c880a9b83 system tests: podman-remote, image tree
- new sanity checks for podman-remote:
  - first, confirm that when PODMAN is "-remote",
    we actually talk to a server (validated by
    presence of "Server:" string in "podman version").
  - second, add test for #7212, in which we run
    "podman --remote" (podman with --remote flag,
    not podman-remote command) and make sure --remote
    is allowed both as the first option and also
    with other flag options preceding.

- new test for "podman image tree" (piggybacking on
  top of a "podman build" test, because that gives
  us lots of layers).

- skip "podman exec - basic test" when remote. It is consistently
  causing CI failures, breaking all of CI, due to #7241.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-10 06:27:44 -06:00
OpenShift Merge Robot 0d4a269c6d
Merge pull request #7220 from baude/issue7124
podman-remote send name and tag
2020-08-05 23:35:41 +02:00
OpenShift Merge Robot bae6d5ddaf
Merge pull request #7236 from mheon/write_error_to_inspect
Ensure that exec errors write exit codes to the DB
2020-08-05 21:57:48 +02:00
Matthew Heon 7a64ce35db Ensure that exec errors write exit codes to the DB
In local Podman, the frontend interprets the error and exit code
given by the Exec API to determine the appropriate exit code to
set for Podman itself; special cases like a missing executable
receive special exit codes.

Exec for the remote API, however, has to do this inside Libpod
itself, as Libpod will be directly queried (via the Inspect API
for exec sessions) to get the exit code. This was done correctly
when the exec session started properly, but we did not properly
handle cases where the OCI runtime fails before the exec session
can properly start. Making two error returns that would otherwise
not set exit code actually do so should resolve the issue.

Fixes #6893

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-05 14:30:48 -04:00
Brent Baude 77f7bf9a9c podman-remote send name and tag
when loading an image with podman-remote load, we need to send a name and a tag to the endpoint

Fixes: #7124

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-05 12:34:44 -05:00
OpenShift Merge Robot 47971909ae
Merge pull request #7125 from QiWang19/fd-validate
validate fds --preserve-fds
2020-08-05 09:37:59 +02:00
Daniel J Walsh a0fb081003
Handle podman-remote run --rm
We need to remove the container after it has exited for
podman-remote run --rm commands.  If we don't remove this
container at this step, we open ourselves up to race conditions.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-04 20:26:34 -04:00
Brent Baude 7590a415d0 correct go-binding key for volumes
the go binding for remove container was using 'vols' for a key to remove volumes associated to the container.  the correct key should be "v" and is documented as such.

Fixes: #7128

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-04 15:31:51 -05:00
Qi Wang 34e82f81bd validate fds --preserve-fds
validate file descriptors passed from podman run and podman exec --preserve-fds.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-08-04 15:09:17 -04:00
Ed Santiago a4fcf09b7a Reenable remote system tests
podman-remote is in better shape now. Let's see what needs
to be done to reenable remote system tests.

 - logs test: skip multilog, it doesn't work remote

 - diff test: use -l only when local, not with remote

 - many other tests: skip_if_remote, with 'FIXME: pending #xxxx'
   where xxxx is a filed issue.

Unrelated: added new helper to skip_if_remote and _if_rootless,
where we check if the source message includes "remote"/"rootless"
and insert it if missing. This is a minor usability enhancement
to make it easier to understand at-a-glance why a skip triggers.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-03 09:36:36 -06:00
Giuseppe Scrivano 10627228be
volumes: do not recurse when chowning
keep the file ownership when chowning and honor the user namespace
mappings.

Closes: https://github.com/containers/podman/issues/7130

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-07-31 10:57:03 +02:00
zhangguanzhang b4fa2c2517 fix podman system df format error
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-07-31 01:40:42 +08:00
Ed Santiago 84f4b87c2e System tests: new system-df and passwd tests
- New test for #6991 - passwd file is writable even when
   run with --userns=keep-id

 - Enable another keep-id test, commented out due to #6593

 - New test for podman system df

Also, independently, removed this line:

   apt-get -y upgrade conmon

...because it's causing CI failures, probably because of the
boothole CVE, probably because the Ubuntu grub update was
rushed out. I believe it is safe to remove this, because
both Ubuntu 19 and 20 report:

   conmon is already the newest version (2.0.18~1).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-30 06:16:51 -06:00
OpenShift Merge Robot 83166a98c3
Merge pull request #7121 from rhatdan/build
Fix building from http or '-' options
2020-07-29 05:03:05 -04:00
Daniel J Walsh a35045cbc4
Fix building from http or '-' options
When copying from a URL, podman will download and create a context
directory in a temporary file.  The problem was that this directory
was being removed as soon as the function that created it was returned.

Later the build code would look for content in the temporary directory
and fail to find it, blowing up the build.

By pulling the extraction code back into the build function, we keep the
temporary directory around until the build completes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 14:51:21 -04:00
Ed Santiago 409d07a181 System tests: add environment, volume tests
Tests for #7094, in which symlinks in a volume would
cause chown errors and nonrunnable containers.

Tests for environment variable precedence, now
include --env-host and proxy settings

Fix a bug caught by covscan in helpers.t ('source'
path would fail if path included spaces).

Fix podman-run man page: it was incorrect in stating
precedence between in-image environment and --env-host.

Fixes: #7099

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-28 09:22:22 -06:00
Daniel J Walsh a5e37ad280
Switch all references to github.com/containers/libpod -> podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 08:23:45 -04:00
Ed Santiago 2b323f2238 BATS help-message test: improve diagnostics
The error messages from the 'podman xxx --help' cross-check
test are unhelpful, and cause much wasted time when they trigger.

Solution: instead of using the built-in exit-status check
in run_podman, do an explicit check outside of run_podman.
This lets us die() with a custom, hopefully useful, message.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-21 08:31:56 -06:00
Ed Santiago 1405c3a205 BATS tests: more resilient remove_same_dev_warning
Some CI tests are flaking in the SELinux test, possibly because
there's a new variation of the "multiple devices" warning I hadn't
seen before:

   WARNING: Creating device "/dev/null" with same type, major and minor as existing "/dev/foodevdir/null".

Solution: in remove_same_dev_warning(), remove "multiple" from
the match string.

Also: fix a Go test that wasn't cleaning up after itself. And
add an actual test to it, not just check-exit-status.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-20 12:32:17 -06:00
OpenShift Merge Robot 6dcff5c32b
Merge pull request #6975 from baude/rootlessIPMAC
Error on rootless mac and ip addresses
2020-07-15 16:38:36 -04:00
OpenShift Merge Robot 9051546c4d
Merge pull request #6979 from edsantiago/bats_masked_dirs
system tests: check for masked-device leaks
2020-07-15 14:08:16 -04:00
Brent Baude c58127602e Error on rootless mac and ip addresses
When creating a pod or container where a static MAC or IP address is provided, we should return a proper error and exit as 125.

Fixes: #6972

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-07-15 07:06:58 -05:00
Ed Santiago 65644d8aa4 system tests: check for masked-device leaks
PR #6957 added a new path (/sys/devs) to an existing list
of masked mount points which an unprivileged container
should not be able to access. Here we add a test for
those: run 'stat' on those devices in the container,
and make sure that they are dummies.

This is kind of kludgy, and relies on heuristics that
may not be 100% accurate. It also adds duplication,
a list that must be kept in sync with the original
list in pkg/specgen/generate/config_linux.go.
I'd love to hear suggestions on how to do it better.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-14 16:02:51 -06:00
Ed Santiago fea3eea68b system tests: new tests for run, exec
- Issue #6735 : problem with multiple namespaces; confirms
   combinations of --userns=keep-id, --privileged, --user=XX

 - Issue #6829 : --userns=keep-id will add a /etc/passwd entry

 - Issue #6593 : podman exec, with --userns=keep-id, errors
   (test is currently skipped because issue remains live)

...and, addendum: add new helper function, remove_same_dev_warning.
Some CI systems issue a warning on podman run --privileged:

   WARNING: The same type, major and minor should not be used for multiple devices.

We already had special-case code to ignore than in the SELinux
test, but now we're seeing it in the new run tests I added, so
I've refactored the "ignore this warning" code and written
tests for the removal code.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-14 14:19:22 -06:00
Ed Santiago 10ad46eb73 BATS system tests for new sdnotify
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-07-06 17:47:22 +00:00
OpenShift Merge Robot d90e8b6873
Merge pull request #6810 from vrothberg/auto-update-test
systemd system test: run auto-update
2020-06-29 11:52:57 -04:00
Valentin Rothberg 43714cac21 systemd system test: run auto-update
Run `podman auto-update` in the systemd system tests.  Note that this is
a first step to at least exercise parts of `auto-update` in the CI.  The
service won't get updated just yet as we need to set up a local
registry, and push a new image.  I do not have enough time at the moment
to do that but consider this change already as an improvement.

We are experiencing some issues in #6793 w.r.t. to auto-updates but
couldn't track down the root cause yet.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-29 15:36:34 +02:00
Ed Santiago f4643ac02a system tests: add pod, inspect testing
Followup to #6761: confirm that 'podman ps' shows the ports
on a running container in a pod created with -p (not to
be confused with the container itself running with -p,
tested in 500-networking.bats).

While we're at it, test that the port handling itself works,
by sending random text to the container and making sure the
container receives it.

Followup to #6752: 'podman inspect' should show multiple
security opts

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-26 06:44:20 -06:00
OpenShift Merge Robot f8036c548c
Merge pull request #6754 from edsantiago/man_page_xref
Docs: consistency between man / --help
2020-06-25 08:33:39 -04:00
OpenShift Merge Robot cd36499d10
Merge pull request #6751 from vrothberg/fix-6744
podman run/create: support all transports
2020-06-25 06:16:54 -04:00
Ed Santiago cf7222172e Friendly amendment for pr 6751
More robust system test for podman run/create docker-archive

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-24 11:10:50 -06:00
Ed Santiago c6090c290e Docs: consistency between man / --help
New functionality in hack/man-page-checker: start cross-
referencing the man page 'Synopsis' line against the
output of 'podman foo --help'. This is part 1, flag/option
consistency. Part 2 (arg consistency) is too big and will
have to wait for later.

flag/option consistency means: if 'podman foo --help'
includes the string '[flags]' in the Usage message,
make sure the man page includes '[*options*]' in its
Synopsis line, and vice-versa. This found several
inconsistencies, which I've fixed.

While doing this I realized that Cobra automatically
includes a 'Flags:' subsection in its --help output
for all subcommands that have defined flags. This
is great - it lets us cross-check against the
usage synopsis, and make sure that '[flags]' is
present or absent as needed, without fear of
human screwups. If a flag-less subcommand ever
gets extended with flags, but the developer forgets
to add '[flags]' and remove DisableFlagsInUseLine,
we now have a test that will catch that. (This,
too, caught two instances which I fixed).

I don't actually know if the new man-page-checker
functionality will work in CI: I vaguely recall that
it might run before 'make podman' does; and also
vaguely recall that some steps were taken to remedy
that.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-24 10:39:10 -06:00
OpenShift Merge Robot 988fd27541
Merge pull request #6746 from vrothberg/untag
podman untag: error if tag doesn't exist
2020-06-24 12:19:42 -04:00
Valentin Rothberg f80461078e podman run/create: support all transports
Support all image transports in podman run/create.  It seems we
regressed with v2 on that.  Also add tests to make sure we're
not regressing again.

Fixes: #6744
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-24 17:20:04 +02:00
Valentin Rothberg 1c6c12581c podman untag: error if tag doesn't exist
Throw an error if a specified tag does not exist.  Also make sure that
the user input is normalized as we already do for `podman tag`.

To prevent regressions, add a set of end-to-end and systemd tests.

Last but not least, update the docs and add bash completions.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-24 15:34:46 +02:00
Ed Santiago 6864a5547a BATS tests: new too-many-arguments test
...plus a few others. And fixes to actual parsing.

If a command's usage message includes '...' in the
argument list, assume it can take unlimited arguments.
Nothing we can check.

For all others, though, the ALL-CAPS part on the
right-hand side of the usage message will define
an upper bound on the number of arguments accepted
by the command. So in our 'podman --help' test,
generate N+1 args and run that command. We expect
a 125 exit status and a suitably helpful error message.

Not all podman commands or subcommands were checking,
so I fixed that. And, fixed some broken usage messages
(all-caps FLAGS, and '[flags]' at the end of 'ARGS').
Add new checks to the help test to prevent those in
the future.

Plus a little refactoring/cleanup where necessary.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-23 14:17:48 -06:00
OpenShift Merge Robot 0d961a40ba
Merge pull request #6726 from edsantiago/bats
system tests: invoke with abs path to podman
2020-06-23 15:31:02 -04:00
OpenShift Merge Robot 73514b1465
Merge pull request #6722 from vrothberg/fix-6718
image load: no args required
2020-06-23 16:47:42 +02:00
Ed Santiago aa16a0aab1 system tests: invoke with abs path to podman
Reversion of one part of #6679: my handling of 'realpath'
would not work when $PODMAN is 'podman-remote --url etc'.
Trying to handle that case got unmaintainable; so instead
let's just force 'make {local,remote}system' to invoke
with a full PODMAN path. This breaks down if someone
runs the tests with a manual 'bats' invocation, but I
think I'm the only one who ever does that.

Since podman path will now be very long in the logs,
add code to logformatter to abbreviate it like we do
for the ginkgo logs.

And, one thing that has bugged me for a long time:
in the error logs, show a different prompt ('#' vs '$')
to distinguish root vs rootless. This should make it
much easier to see at-a-glance whether a log file
is root or not. Add tests for it.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-23 08:10:57 -06:00
Valentin Rothberg 138d447eb4 image load: no args required
Disable the args requirement of `image load`.  Instead of requiring a
lower bound, we really need an upper one with at most 1 argument.
Extend the system tests to prevent future regressions.

Fixes: #6718
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-23 14:53:29 +02:00
OpenShift Merge Robot bbaba9fb86
Merge pull request #6679 from edsantiago/bats
system tests: new rm, build tests
2020-06-23 12:21:49 +02:00
Ed Santiago d4504e6f53 system tests: new rm, build tests
- rm: confirm 'rm' and 'rm -f' on running container

 - build: shotgun test of workdir, cmd, env, labels

The new build test cd's to a temporary directory, which broke
test invocations using a relative path (./bin/podman). Added
code to detect relative paths and convert them to absolute.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-22 15:57:18 -06:00
Qi Wang f61a7f25a8 Add --preservefds to podman run
Add --preservefds to podman run. close https://github.com/containers/libpod/issues/6458

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-19 09:40:13 -04:00
Valentin Rothberg 334d3b1ef3 CI: force registry:2.6
For using the `registry:2.6` image. 2.7 and beyond dropped the
`htpasswd` binary from the rootfs which parts of our CI depends
on.

While this is not a sustainable solution (assuming `htpasswd` is gone
for ever), it unblocks the CI for now.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-19 12:58:02 +02:00
Daniel J Walsh fe69aa9ba3
Handle dropping capabilties correctly when running as non root user
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-17 17:20:53 -04:00