Commit graph

340 commits

Author SHA1 Message Date
OpenShift Merge Robot 4ee203dde7
Merge pull request #9945 from rhatdan/runlabel
Fix handling of $NAME and $IMAGE in runlabel
2021-04-14 10:47:50 -04:00
Ed Santiago bc2f60ad6d System tests: setup: better cleanup of stray images
Fix a corner case in basic_setup(), where we rmi stray images.
If a test tags $IMAGE and fails to rmi by tag name, cleanup
could rmi both tag name and IID, wiping out the desired image:

   podman tag $IMAGE foo
   ...
   cleanup: rmi foo $FOO_IID   [this removes $IMAGE!]

Solution: rmi by name, but only rmi by IID if != $IMAGE.

TOTH to ypu for bringing this to my attention.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-13 06:50:56 -06:00
Giuseppe Scrivano 2fad29ccb2
cgroup: do not set cgroup parent when rootless and cgroupfs
do not set the cgroup parent when running as rootless with cgroupfs,
even if cgroup v2 is used.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1947999

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-04-12 16:55:55 +02:00
Daniel J Walsh 8f16742187
Fix handling of $NAME and $IMAGE in runlabel
Fixes: https://github.com/containers/podman/issues/9405

Add system runlabel tests.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-12 08:41:08 -04:00
OpenShift Merge Robot 0e67053b9a
Merge pull request #9955 from edsantiago/bats
System tests: special case for RHEL: require runc
2021-04-07 09:27:41 -04:00
Paul Holzinger f230214db1 rootless cni add /usr/sbin to PATH if not present
The CNI plugins need access to iptables in $PATH. On debian /usr/sbin
is not added to $PATH for rootless users. This will break rootless
cni completely. To prevent breaking existing users add /usr/sbin to
$PATH in podman if needed.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-06 23:55:05 +02:00
Ed Santiago 2ab5a294b9 System tests: special case for RHEL: require runc
As discussed in watercooler 2021-04-06: make sure that RHEL8
and CentOS are using runc. Using crun is probably a packaging
error that should be caught early.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-06 14:21:46 -06:00
OpenShift Merge Robot 4f57a10344
Merge pull request #9940 from rhatdan/auth
Verify existence of auth file if specified
2021-04-05 21:15:15 +02:00
OpenShift Merge Robot 6b23fece73
Merge pull request #9911 from rhatdan/storage
Allow users to override default storage opts with --storage-opt
2021-04-05 20:55:15 +02:00
OpenShift Merge Robot e9e4898048
Merge pull request #9907 from rhatdan/options
Add support for podman --context default
2021-04-05 20:54:15 +02:00
Daniel J Walsh 6831c72f6a
Don't relabel volumes if running in a privileged container
Docker does not relabel this content, and openstack is running
containers in this manner.  There is a penalty for doing this
on each container, that is not worth taking on a disable SELinux
container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-05 13:07:36 -04:00
Daniel J Walsh 69ace20535
Allow users to override default storage opts with --storage-opt
We define in the man page that this overrides the default storage
options, but the code was appending to the existing options.

This PR also makes a change to allow users to specify --storage-opt="".
This will turn off all storage options.

https://github.com/containers/podman/issues/9852

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-05 12:48:09 -04:00
Daniel J Walsh c6a21a38b3
Add support for podman --context default
This is a noop but helps with scripting and docker-compose.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-05 12:41:47 -04:00
Daniel J Walsh 28251f41ff
Verify existence of auth file if specified
Fixes: https://github.com/containers/podman/issues/9572

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-05 12:36:04 -04:00
OpenShift Merge Robot 131458e956
Merge pull request #9423 from Luap99/rootless-cni-no-infra
rootless cni without infra container
2021-04-05 17:12:14 +02:00
OpenShift Merge Robot 1c8d3d0f6f
Merge pull request #9928 from pendulm/fix_rootless_socket_activation
Fix rootless socket activation
2021-04-05 16:02:15 +02:00
pendulm 11917a1a6b Move socket activation check into init() and set global condition.
So rootless setup could use this condition in parent and child, child
podman should adjust LISTEN_PID to its self PID.

Add system test for systemd socket activation

Signed-off-by: pendulm <lonependulm@gmail.com>
2021-04-05 17:43:11 +08:00
Daniel J Walsh 052732857a
Fix missing podman-remote build options
Fix handling of SecurityOpts
   LabelOpts
   SeccompProfilePath
   ApparmorProfile

Fix Ulimits

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-02 09:19:03 -04:00
Paul Holzinger 54b588c07d rootless cni without infra container
Instead of creating an extra container create a network and mount
namespace inside the podman user namespace. This ns is used to
for rootless cni operations.
This helps to align the rootless and rootful network code path.
If we run as rootless we just have to set up a extra net ns and
initialize slirp4netns in it. The ocicni lib will be called in
that net ns.

This design allows allows easier maintenance, no extra container
with pause processes, support for rootless cni with --uidmap
and possibly more.

The biggest problem is backwards compatibility. I don't think
live migration can be possible. If the user reboots or restart
all cni containers everything should work as expected again.
The user is left with the rootless-cni-infa container and image
but this can safely be removed.

To make the existing cni configs work we need execute the cni plugins
in a extra mount namespace. This ensures that we can safely mount over
/run and /var which have to be writeable for the cni plugins without
removing access to these files by the main podman process. One caveat
is that we need to keep the netns files at `XDG_RUNTIME_DIR/netns`
accessible.

`XDG_RUNTIME_DIR/rootless-cni/{run,var}` will be mounted to `/{run,var}`.
To ensure that we keep the netns directory we bind mount this relative
to the new root location, e.g. XDG_RUNTIME_DIR/rootless-cni/run/user/1000/netns
before we mount the run directory. The run directory is mounted recursive,
this makes the netns directory at the same path accessible as before.

This also allows iptables-legacy to work because /run/xtables.lock is
now writeable.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-01 17:27:03 +02:00
OpenShift Merge Robot 5e156c892c
Merge pull request #9857 from edsantiago/bats
system tests: friendier messages for 2-arg is()
2021-03-29 14:37:42 +00:00
Ed Santiago 06ae12bd4e system tests: friendier messages for 2-arg is()
The 'is' check was intended to be called with three arguments,
the last one being a nice helpful test name. There's a fallback
for two-argument calls, but it was a horrible FIXME.

New fallback: the most recently run podman command. We keep
track of it in each run_podman() invocation.

This is not ideal, because it's theoretically possible to
invoke 'is' on something other than the output of run_podman,
but this at least fixes the by-far-most-common case.

[NO TESTS NEEDED]

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-03-29 06:10:42 -06:00
Daniel J Walsh 4d51995377
Fix podman build --pull-never
Currently pull policy is set incorrectly when users set --pull-never.

Also pull-policy is not being translated correctly when using
podman-remote.

Fixes: #9573

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-27 05:33:30 -04:00
Daniel J Walsh dcabf6dd71
Remove resize race condition
Since podman-remote resize requests can come in at random times, this
generates a real potential for race conditions. We should only be
attempting to resize TTY on running containers, but the containers can
go from running to stopped at any time, and returning an error to the
caller is just causing noice.

This change will basically ignore requests to resize terminals if the
container is not running and return the caller to success.  All other
callers will still return failure.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-26 15:15:17 -04:00
Anders F Björklund 826c228035 Fix swapped dimensions from terminal.GetSize
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
2021-03-26 07:14:47 +01:00
Ed Santiago 4b23bc7aa4 system tests: new interactive tests
socat can create a dummy PTY that we can manipulate. This
lets us run a variety of tests that we couldn't before,
involving "run -it", and stty, and even "load" with no args.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-03-25 10:48:55 -06:00
Daniel J Walsh 00949d0bd8
Check if stdin is a term in --interactive --tty mode
If you are attempting to run a container in interactive mode, and want
a --tty, then there must be a terminal in use.

Docker exits right away when a user specifies to use a --interactive and
--TTY but the stdin is not a tty.

Currently podman will pull the image and then fail much later.

Podman will continue to run but will print an warning message.

Discussion in : https://github.com/containers/podman/issues/8916

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-24 16:33:30 -04:00
OpenShift Merge Robot 9ec936a856
Merge pull request #9757 from jwhonce/wip/load
Cleanup /libpod/images/load handler
2021-03-22 08:18:56 -07:00
Ed Santiago afce37671f System tests: reenable a bunch of skipped tests
Checking for 'skip.*[0-9]{4,5}', and checking status on said
issues, finds several that have been closed. Let's see if
they're really fixed.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-03-20 08:21:46 -06:00
Jhon Honce 417f362811 Cleanup /libpod/images/load handler
* Remove orphaned code
* Add meaningful error from LoadImageFromSingleImageArchive() when
  heuristic fails to determine payload format
* Correct swagger to output correct types and headers

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-03-19 09:25:12 -07:00
Ed Santiago 963d19c759 System test cleanup
- cp test: clean up stray image

- build test: add workaround for #9567 (ultra-slow ubuntu).
  We're seeing CI flakes (timeouts) due to ubuntu 2004 being
  absurdly slow. Workaround: double our timeout on one specific
  test when ubuntu + remote.

- build test: clean up new copy-from test (from #9275).
  The test was copy-pasted from buildah system tests, without
  really adapting for podman environment (e.g. it was using
  images that we don't use here, and would cause pulls, which
  will cause flakes). Rewrite test so it references only $IMAGE,
  remove some confusing/unnecessary stuff, selectively run
  parts of it even when rootless or remote, and add a
  test to confirm that copy-from succeeded.

- load test: add error-message test to new load-invalid (#9672).
  Basically, make sure the command fails for the right reason.

- play test (kube): use $IMAGE, not alpine; and add pause-image
  cleanup to teardown()

- apiv2 mounts test: add a maintainability comment in a tricky
  section of code; and tighten up the mount point test.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-03-15 15:27:06 -06:00
Ed Santiago 660a72993c sdnotify tests: try real hard to kill socat processes
podman gating tests are hanging in the new Fedora CI setup;
long and tedious investigation suggests that 'socat' processes
are being left unkilled, which then causes BATS to hang when
it (presumably) runs a final 'wait' in its end cleanup.

The two principal changes are to exec socat in a subshell
with fd3 closed, and to pkill its child processes before
killing the process itself. I don't know if both are needed.
The pkill definitely is; the exec may just be superstition.
Since I've wasted more than a day of PTO time on this, I'm
okay with a little superstition. What I do know is that with
these two changes, my reproducer fails to reproduce in over
one hour of trying (normally it fails within 5 minutes).

AND, update: only rawhide (f35) leaves stray socat processes
behind. f33 and ubuntu do not, so 'pkill -P' fails.

I really have no idea what's going on.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-03-11 16:21:51 -07:00
Daniel J Walsh f1eb8e8162
Removing a non existing container API should return 404
Currently we were overwrapping error returned from removal
of a non existing container.

$ podman rm bogus -f
Error: failed to evict container: "": failed to find container "bogus" in state: no container with name or ID bogus found: no such container

Removal of wraps gets us to.

./bin/podman rm bogus -f
Error: no container with name or ID "bogus" found: no such container

Finally also added quotes around container name to help make it standout
when you get an error, currently it gets lost in the error.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-10 04:08:29 -05:00
OpenShift Merge Robot 09473d4300
Merge pull request #9677 from vrothberg/fix-9672
podman load: fix error handling
2021-03-09 15:11:49 +01:00
Valentin Rothberg 930bec4d3a podman load: fix error handling
Make sure to properly return loading errors and to set the exit code
accordingly.

Fixes: #9672
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-03-09 11:53:50 +01:00
Valentin Rothberg 1f2f7e7459 podman cp: evaluate symlink correctly when copying from container
When copying from a container, make sure to evaluate the symlinks
correctly.  Add tests copying a symlinked directory from a running and
a non-running container to execute both path-resolution paths.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-03-09 10:45:15 +01:00
Valentin Rothberg 31b11b5cd6 podman cp: fix copying to a non-existent dir
Copy is full of perils.  Some of them are the nuances when copying
directories.  Who would have thought that
 * cp dir   foo
 * cp dir/  foo
 * cp dir/. foo
are all supposed to yield the same result when foo does not exist.

`podman cp` now supports all three notations, which required to massage
the front-end code in `cmd/podman` a bit.  The tests have been extended
and partially rewritten to test container->host and host->container
copy operations.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-03-09 09:02:14 +01:00
Valentin Rothberg a61d70cf8e podman cp: fix ownership
Make sure the files are chowned to the host/container user, depending on
where things are being copied to.

Fixes: #9626
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-03-09 09:02:14 +01:00
Daniel J Walsh 9e75cafd5c
build-arg
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-07 08:08:32 -05:00
Daniel J Walsh 326f3eda31
Handle podman build --dns-search
Fixes: https://github.com/containers/podman/issues/9574

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-07 08:08:32 -05:00
Daniel J Walsh 2c500a8145
Add support for podman build --ignorefile
Fixes: https://github.com/containers/podman/issues/9570

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-07 06:42:02 -05:00
OpenShift Merge Robot 2a7815726c
Merge pull request #9599 from rhatdan/selinux
Add tests for selinux kvm/init labels
2021-03-05 14:49:25 -05:00
OpenShift Merge Robot 05080a12a9
Merge pull request #9593 from vrothberg/cp-tmp
podman cp: support copying on tmpfs mounts
2021-03-05 03:57:17 -05:00
Daniel J Walsh 793c52dd56
Add tests for selinux kvm/init labels
spc_t tests should be able to run rootless as well.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-04 17:01:04 -05:00
Valentin Rothberg a090301bbb podman cp: support copying on tmpfs mounts
Traditionally, the path resolution for containers has been resolved on
the *host*; relative to the container's mount point or relative to
specified bind mounts or volumes.

While this works nicely for non-running containers, it poses a problem
for running ones.  In that case, certain kinds of mounts (e.g., tmpfs)
will not resolve correctly.  A tmpfs is held in memory and hence cannot
be resolved relatively to the container's mount point.  A copy operation
will succeed but the data will not show up inside the container.

To support these kinds of mounts, we need to join the *running*
container's mount namespace (and PID namespace) when copying.

Note that this change implies moving the copy and stat logic into
`libpod` since we need to keep the container locked to avoid race
conditions.  The immediate benefit is that all logic is now inside
`libpod`; the code isn't scattered anymore.

Further note that Docker does not support copying to tmpfs mounts.

Tests have been extended to cover *both* path resolutions for running
and created containers.  New tests have been added to exercise the
tmpfs-mount case.

For the record: Some tests could be improved by using `start -a` instead
of a start-exec sequence.  Unfortunately, `start -a` is flaky in the CI
which forced me to use the more expensive start-exec option.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-03-04 15:43:12 +01:00
Daniel J Walsh 252aec1c9a
Check for supportsKVM based on basename of the runtime
Fixes: https://github.com/containers/podman/issues/9582

This PR also adds tests to make sure SELinux labels match the runtime,
or if init is specified works with the correct label.

Add tests for selinux kvm/init labels

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-03 16:49:51 -05:00
OpenShift Merge Robot 397aae32b9
Merge pull request #8749 from edsantiago/upgrade_test
podman upgrade tests
2021-02-26 13:19:25 +01:00
Ed Santiago bee21f1e42 system test image: build it multiarch
buildah now supports running under emulation[1] as well as
creating manifests. Use those features to create a multiarch
testimage that can be used to test podman on other arches.

 [1] on Fedora 33, this requires the qemu-user-static package

We also build a new :00000001 image, replacing :00000000,
because (sigh) some tests try to run 'true' in the container.
Include instructions on building said image.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-02-24 15:09:58 -07:00
Ed Santiago 79eaadd3fb podman upgrade tests
Initial validation of using podman-in-podman to create an
old-podman root, then use new-podman to play with the
containers created therein.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-02-23 06:58:54 -07:00
Valentin Rothberg e5ac28f3b9 container removal: handle already removed containers
Since commit d54478d8ea, a container's lock is released before
attempting to stop it via the OCI runtime.  This opened the window
for various kinds of race conditions.  One of them led to #9479 where
the removal+cleanup sequences of a `run --rm` session overlapped with
`rm -af`.  Make both execution paths more robust by handling the case of
an already removed container.

Fixes: #9479
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-23 13:02:35 +01:00
OpenShift Merge Robot e64669cb96
Merge pull request #9469 from vrothberg/cp-stdout
podman cp: /dev/std{in,out} fixes
2021-02-22 15:44:40 -05:00