Commit graph

681 commits

Author SHA1 Message Date
Paul Holzinger 4462113c5e podman network reload add rootless support
Allow podman network reload to be run as rootless user. While it is
unlikely that the iptable rules are flushed inside the rootless cni
namespace, it could still happen. Also fix podman network reload --all
to ignore errors when a container does not have the bridge network mode,
e.g. slirp4netns.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-05-17 10:55:02 +02:00
Daniel J Walsh 4cc19f9e0f
Support automatic labeling of kube volumes
Allow users to specify options on the volume mount path.
This will trigger relabels of user specifies :z,:Z
Also will handle User Relabels if the user specifies :U

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-16 07:09:22 -04:00
Daniel J Walsh b75bb4665e
Create the /etc/mtab file if does not exists
We should create the /etc/mtab->/proc/mountinfo link
so that mount command will work within the container.

Docker does this by default.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-15 03:56:38 -04:00
OpenShift Merge Robot d6507fcfbc
Merge pull request #10222 from vrothberg/image-tree
podman image tree: restore previous behavior
2021-05-12 15:59:46 -04:00
Valentin Rothberg d32863bbb4 podman image tree: restore previous behavior
The initial version of libimage changed the order of layers which has
now been restored to remain backwards compatible.

Further changes:

 * Fix a bug in the journald logging which requires to strip trailing
   new lines from the message.  The system tests did not pass due to
   empty new lines.  Triggered by changing the default logger to
   journald in containers/common.

 * Fix another bug in the journald logging which embedded the container
   ID inside the message rather than the specifid field.  That surfaced
   in a preceeding whitespace of each log line which broke the system
   tests.

 * Alter the system tests to make sure that the k8s-file and the
   journald logging drivers are executed.

 * A number of e2e tests have been changed to force the k8s-file driver
   to make them pass when running inside a root container.

 * Increase the timeout in a kill test which seems to take longer now.
   Reasons are unknown.  Tests passed earlier and no signal-related
   changes happend.  It may be CI VM flake since some system tests but
   other flaked.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-12 17:56:59 +02:00
Paul Holzinger fa6b6b873f fix network restart always test
The added test in 30544f225e is flaking. Podman inspect is always
working so we have to check the pid instead.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-05-12 11:27:39 +02:00
Paul Holzinger 30544f225e fix restart always with slirp4netns
When a container is automatically restarted due its restart policy and
the container used the slirp4netns netmode, the slirp4netns process
died. This caused the container to lose network connectivity.

To fix this we have to start a new slirp4netns process.

Fixes #8047

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-05-11 22:37:32 +02:00
OpenShift Merge Robot 02b0979528
Merge pull request #10291 from edsantiago/remove_obsolete_skips
Remove obsolete skips
2021-05-10 14:30:40 -04:00
Ed Santiago 471f4898f0 Remove obsolete skips
The following bugs seem to be fixed:

* #6510 (e2e tests) - podman rmi gives "layer not known"

* #9915 (buildah-bud tests) - podman build --arch

* #10248 - spurious warning from first-ever invocation
  of rootless podman

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-05-10 07:43:35 -06:00
Paul Holzinger 77e6ae2436 Add envars to the generated systemd unit
The with --new generated systemd unit loses the environment variables
when the create command only contains the key without the value. Since
podman tries to lookup those values from the environment the unit can
fail.

This commits ensures that we will add the environment variables to the
unit file when this is the case. The container environment variables are
looked up in the container spec.

Fixes #10101

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-05-10 12:01:24 +02:00
OpenShift Merge Robot 29b13176a2
Merge pull request #10237 from edsantiago/ci_rootless_add_ubuntu
CI: run rootless tests under ubuntu
2021-05-07 05:30:26 -04:00
Daniel J Walsh f528511bf6
Revert Patch to relabel if selinux not enabled
Revert : https://github.com/containers/podman/pull/9895

Turns out that if Docker is in --selinux-enabeled, it still relabels if
the user tells the system to, even if running a --privileged container
or if the selinux separation is disabled --security-opt label=disable.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-06 18:00:16 -04:00
Ed Santiago 95a50a936a CI: run rootless tests under ubuntu
Reason: to catch errors before they surface in RHEL.

One of the Ubuntus is specially crafted to run with cgroups v1
and runc. Although this isn't quite the same as RHEL, it's as
close as we can come in our CI environment, and I suspect it
would have caught #10234 (a regression).

Sorry, team.

Also: play kube limits test: skip on all rootless, not just
rootless+fedora. There was a complicated and unnecessary
check in there for Fedora.

Also: workaround for bug #10248, a spurious error message on
the first invocation of rootless podman on Ubuntu.Old

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-05-06 08:40:11 -06:00
Boaz Shuster efdc7d8465 Add restart-policy to container filters & --filter to podman start
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2021-05-06 14:35:15 +03:00
Valentin Rothberg 0f7d54b026 migrate Podman to containers/common/libimage
Migrate the Podman code base over to `common/libimage` which replaces
`libpod/image` and a lot of glue code entirely.

Note that I tried to leave bread crumbs for changed tests.

Miscellaneous changes:

 * Some errors yield different messages which required to alter some
   tests.

 * I fixed some pre-existing issues in the code.  Others were marked as
   `//TODO`s to prevent the PR from exploding.

 * The `NamesHistory` of an image is returned as is from the storage.
   Previously, we did some filtering which I think is undesirable.
   Instead we should return the data as stored in the storage.

 * Touched handlers use the ABI interfaces where possible.

 * Local image resolution: previously Podman would match "foo" on
   "myfoo".  This behaviour has been changed and Podman will now
   only match on repository boundaries such that "foo" would match
   "my/foo" but not "myfoo".  I consider the old behaviour to be a
   bug, at the very least an exotic corner case.

 * Futhermore, "foo:none" does *not* resolve to a local image "foo"
   without tag anymore.  It's a hill I am (almost) willing to die on.

 * `image prune` prints the IDs of pruned images.  Previously, in some
   cases, the names were printed instead.  The API clearly states ID,
   so we should stick to it.

 * Compat endpoint image removal with _force_ deletes the entire not
   only the specified tag.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-05 11:30:12 +02:00
OpenShift Merge Robot 8eefca5a25
Merge pull request #10199 from edsantiago/system_tests_with_runc_override
System tests: honor $OCI_RUNTIME (for CI)
2021-05-04 14:46:17 -04:00
OpenShift Merge Robot af2418018b
Merge pull request #8828 from boaz0/closes_8779
Add --all to podman start
2021-05-04 16:44:19 +02:00
Ed Santiago 9fd7ab50f8 System tests: honor $OCI_RUNTIME (for CI)
Some CI systems set $OCI_RUNTIME as a way to override the
default crun. Integration (e2e) tests honor this, but system
tests were not aware of the convention; this means we haven't
been testing system tests with runc, which means RHEL gating
tests are now failing.

The proper solution would be to edit containers.conf on CI
systems. Sorry, that would involve too much CI-VM work.
Instead, this PR detects $OCI_RUNTIME and creates a dummy
containers.conf file using that runtime.

Add: various skips for tests that don't work with runc.

Refactor: add a helper function so we don't need to do
the complicated 'podman info blah blah .OCIRuntime.blah'
thing in many places.

BUG: we leave a tmp file behind on exit.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-05-03 20:15:21 -06:00
Ed Santiago 0c634ff339 system test image: add arm64v8 image
The RHEL multi-arch team informed me that we were missing
aarch64; add it, using the new name (arm64v8).

(This is from last week, so the image date tag does not
match today's date. I was waiting for confirmation that
things were working).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-05-03 14:23:36 -06:00
Boaz Shuster a726a3d79c Add --all to podman start
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
Co-authored-by: Ed Santiago <santiago@redhat.com>
2021-05-03 22:17:06 +03:00
OpenShift Merge Robot 4d2ba323f2
Merge pull request #10063 from ParkerVR/autoupdate-local
Autoupdate Local
2021-04-29 13:37:50 -04:00
Parker Van Roy caf19efdab TODO complete
changed struct to policyMapper
change "image" to "registry" in multiple locations

Updated documentation with registry alias & autoupdate local

Added relevant test

Signed-off-by: Parker Van Roy <pvanroy@redhat.com>
2021-04-29 02:40:11 -04:00
Ed Santiago 0dfd5a151d system tests: networking: fix another race condition
Our current #1 flake; this is a simple one: we can't run 'logs'
on a container run with '-d --rm'.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-28 08:41:27 -06:00
OpenShift Merge Robot 99e5a76f09
Merge pull request #10157 from edsantiago/bats
System tests: fix two race conditions
2021-04-28 06:22:45 -04:00
Ed Santiago c11e9b01b3 System tests: fix two race conditions
Basically, add 'podman wait' before 'podman rm'. See if this
fixes gating tests run on ppc64le (possibly very very slow hosts)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-27 15:10:18 -06:00
OpenShift Merge Robot f613a2a8d5
Merge pull request #10119 from rhatdan/timeout
Add podman run --timeout option
2021-04-27 16:47:32 -04:00
Daniel J Walsh 3538815c5b
Add podman run --timeout option
This option allows users to specify the maximum amount of time to run
before conmon sends the kill signal to the container.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-23 11:18:05 -04:00
Paul Holzinger f99b7a314b Fix rootlesskit port forwarder with custom slirp cidr
The source ip for the rootlesskit port forwarder was hardcoded to the
standard slirp4netns ip. This is incorrect since users can change the
subnet used by slirp4netns with `--network slirp4netns:cidr=10.5.0.0/24`.
The container interface ip is always the .100 in the subnet. Only when
the rootlesskit port forwarder child ip matches the container interface
ip the port forwarding will work.

Fixes #9828

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-23 11:12:49 +02:00
OpenShift Merge Robot 21c77846e4
Merge pull request #9495 from rhatdan/groups
Add '--group-add keep-groups': supplementary groups into container
2021-04-22 09:29:28 -04:00
OpenShift Merge Robot 979f047d73
Merge pull request #10102 from edsantiago/bats
corrupt-image test: fix an oops
2021-04-21 15:45:47 -04:00
Daniel J Walsh e356160f41
Add --group-add keep-groups: suplimentary groups into container
Currently we have rootless users who want to leak their groups access
into containers, but this group access is only able to be pushed in by
a hard to find OCI Runtime annotation.  This PR makes this option a lot
more visable and hides the complexity within the podman client.

This option is only really needed for local rootless users. It makes
no sense for remote clients, and probably makes little sense for
rootfull containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-21 13:28:36 -04:00
Daniel J Walsh 9c8277247d
Fixes from make codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-21 13:16:33 -04:00
Ed Santiago a273d25ed1 corrupt-image test: fix an oops
Followup to #10033: actually implement the system reset test.
And, just out of paranoia, extend the warning-message check.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-21 06:09:31 -06:00
Daniel J Walsh 8ebeadc3c6
Add --noheading flag to all list commands
Currently we have only podman images list --noheading.
This PR Adds this option to volumes, containers, pods, networks,
machines, and secrets.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-21 05:22:29 -04:00
Nalin Dahyabhai fd9dd7065d rmi: don't break when the image is missing a manifest
In libpod/image.Image.Remove(), if the attempt to find the image's
parent fails for any reason, log a warning and proceed as though it
didn't have one instead of failing, which would leave us unable to
remove the image without resetting everything.

In libpod/Runtime.RemoveImage(), if we can't determine if an image has
children, log a warning, and assume that it doesn't have any instead of
failing, which would leave us unable to remove the image without
resetting everything.

In pkg/domain/infra/abi.ImageEngine.Remove(), when attempting to remove
all images, if we encounter an error checking if a given image has
children, log a warning, and assume that it doesn't have any instead of
failing, which would leave us unable to remove the image without
resetting everything.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-20 15:44:39 -04:00
OpenShift Merge Robot b82ae19acf
Merge pull request #10046 from edsantiago/bats
system tests: build --pull-never: deal with flakes
2021-04-16 01:19:12 -04:00
Ed Santiago cfcf5f9ddc system tests: build --pull-never: deal with flakes
This test continues to flake on podman-remote (especially Ubuntu)
even after #10030 and #10034. I give up. Stop checking the error
message in podman-remote tests.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-15 12:15:15 -06:00
OpenShift Merge Robot 405331ff90
Merge pull request #10032 from nalind/trace-level
Recognize "trace" logging, and use it for lone errors at exit
2021-04-15 09:08:37 -04:00
OpenShift Merge Robot a7bbb78c8d
Merge pull request #10028 from edsantiago/bats
System tests: fix racy podman-inspect
2021-04-14 15:12:51 -04:00
Nalin Dahyabhai bc86c50cd8 Test that we don't error out on advertised --log-level values
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-04-14 14:16:09 -04:00
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 83930a03c5 System tests: fix racy podman-inspect
Add 'podman wait' between kill & inspect.

Fixes: #9751

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-04-14 08:09:20 -06: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
Valentin Rothberg f3a8e3324f podman cp: test /dev/stdin correctly
/dev/stdin should not be treated as "-" to remain compatible with Docker
and to have a more consistent and idiomatic interface.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 16:45:31 +01:00
Valentin Rothberg 8577be72e8 podman cp: treat /dev/stdout correctly
/dev/stdout should not be treated as "-" to remain compatible with
Docker and to have a more consistent and idiomatic interface.

Fixes: #9362
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 16:45:30 +01:00
OpenShift Merge Robot 6fbf73ed8b
Merge pull request #9420 from rhatdan/kube
[NO TESTS NEEDED] Allow podman play kube to read yaml file from stdin
2021-02-22 09:08:33 -05:00
OpenShift Merge Robot 10d52c05e2
Merge pull request #9275 from rhatdan/build
Add missing params for podman-remote build
2021-02-22 06:29:32 -05:00
Daniel J Walsh f06dd45e0c
Allow podman play kube to read yaml file from stdin
Fixes: https://github.com/containers/podman/issues/8996

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-19 12:53:25 -05:00
Valentin Rothberg 71689052a1 cp: treat "." and "/." correctly
Make sure to treat "." and "/." correctly.  Both cases imply to copy the
contents of a directory in contrast to the directory.  This implies to
unset the KeepDirectoryNames options of the copiah package.

Previously, the code was performing a simple string suffix check which
is not enough since it would match files and directories ending with
".".

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-18 18:23:23 +01:00
OpenShift Merge Robot 7fb347a3d4
Merge pull request #9399 from vrothberg/home-sweet-home
do not set empty $HOME
2021-02-16 11:39:27 -05:00
Valentin Rothberg 2ec0e3b650 do not set empty $HOME
Make sure to not set an empty $HOME for containers and let it default to
"/".

https://github.com/containers/crun/pull/599 is required to fully
address #9378.

Partially-Fixes: #9378
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-16 14:21:45 +01:00
Valentin Rothberg 2845f7b832 podman build: pass runtime to buildah
Make sure that Podman's default OCI runtime is passed to Buildah in
`podman build`.  In theory, Podman and Buildah should use the same
defaults but the projects move at different speeds and it turns out
we caused a regression in v3.0.

Fixes: #9365
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-16 13:01:56 +01:00
Daniel J Walsh 690c02f602
Add missing params for podman-remote build
Fixes: https://github.com/containers/podman/issues/9290

Currently we still have hard coded --isolation=chroot for podman-remote build.

Implement missing arguments for podman build

Implements
--jobs, --disable-compression, --excludes

Fixes:
MaxPullPushRetries
RetryDuration

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-16 06:48:35 -05:00
Paul Holzinger 1cc387bf78 Add shell completion tests for secrets
Add the SECRET keyword to the shell completion test. Also update the
use line for podman secret create to use `NAME` instead of `SECRET`.
This matches the other commands such as network/volume create.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-10 10:41:51 +01:00
Valentin Rothberg 821ef6486a fix logic when not creating a workdir
When resolving the workdir of a container, we may need to create unless
the user set it explicitly on the command line.  Otherwise, we just do a
presence check.  Unfortunately, there was a missing return that lead us
to fall through into attempting to create and chown the workdir.  That
caused a regression when running on a read-only root fs.

Fixes: #9230
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-05 09:50:07 +01:00
OpenShift Merge Robot 4945abb7d1
Merge pull request #9208 from edsantiago/bats
System test for #9096 (truncated stdout)
2021-02-03 12:06:40 -05:00
Ed Santiago 1c50e09b06 System test for #9096 (truncated stdout)
This actually tests conmon, not podman; but that's the whole
point of system tests in the first place: if a problem exists,
we want to fail loudly, no matter whose fault it is.

(I can't get this to fail on my f33 laptop; OP on #9096 claims
it only fails on Ubuntu. We'll see what happens in CI).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-02-02 17:48:00 -07:00
Ed Santiago e0bc8ffb59 Gating tests: diff test: workaround for RHEL8 failure
RHEL8 rootless gating tests are inconsistently failing with:

   $ podman diff --format json -l
   #
   {"changed":["/etc"],"added":["/sys/fs","/sys/fs/cgroup","/pMOm1Q0fnN"],"deleted":["/etc/services"]}
   # #/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
   # #|     FAIL: added
   # #| expected: '/pMOm1Q0fnN'
   # #|   actual: '/sys/fs'
   # #|         > '/sys/fs/cgroup'
   # #|         > '/pMOm1Q0fnN'
   # #\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Reason: PR #8561, I think (something to do with /sys on RHEL).

Workaround: ignore '/sys/fs' in diffs.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-02-02 15:23:48 -07:00
OpenShift Merge Robot 628b0d79b5
Merge pull request #9116 from iwita/ls-volumes-before-pruning
List volumes before pruning
2021-02-02 14:02:58 -05:00
Achilleas Tzenetopoulos 9b5b03d1e0 list volumes before pruning
Signed-off-by: Achilleas Tzenetopoulos <atzenetopoulos@gmail.com>
2021-01-31 16:31:43 +02:00
OpenShift Merge Robot 8f3bcf6247
Merge pull request #9144 from vrothberg/fix-9134
Revert "podman build --pull: use correct policy"
2021-01-29 13:27:19 -05:00
OpenShift Merge Robot a4c255a939
Merge pull request #9115 from rhatdan/pull
Switch podman image push handlers to use abi
2021-01-28 14:37:30 -05:00
Valentin Rothberg c450092fde Revert "podman build --pull: use correct policy"
This reverts commit 15caebfe56.

The previous behaviour of `--pull` to *always* attempt to pull the image
and error out if the pull failed aligns with Docker.  Since Podman aims
at feature parity with Docker, the `--pull` behaviour must match.

Fixes: #9134
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-28 17:53:12 +01:00
OpenShift Merge Robot 14cc4aaf0a
Merge pull request #9127 from vrothberg/fix-9111
podman build --pull: use correct policy
2021-01-27 14:56:07 -05:00
OpenShift Merge Robot 1814fa2d21
Merge pull request #9105 from vrothberg/fix-8281
remote exec: write conmon error on hijacked connection
2021-01-27 14:25:06 -05:00
Valentin Rothberg 15caebfe56 podman build --pull: use correct policy
The `--pull` flag should be using the "pull if newer" pull policy rather
than "pull always".  This aligns with what the help message states, what
Buildah does and, according to #9111, what was done before,

Also add a test to prevent future regressions.

Fixes: #9111
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-27 16:49:47 +01:00
Daniel J Walsh 84f7bdc4db
Switch podman image push handlers to use abi
Change API Handlers to use the same functions that the
local podman uses.

At the same time:

Cleanup and pass proper bindings.  Remove cli options from
podman-remote push.  Cleanup manifest push.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-27 09:27:25 -05:00
Daniel J Walsh 21cb3043fc
podman-remote ps --external --pod --sort do not work.
Fixup the bindings and the handling of the --external --por and --sort
flags.

The --storage option was renamed --external, make sure we use
external up and down the stack.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-27 06:44:43 -05:00
Valentin Rothberg c63599d361 remote exec: write conmon error on hijacked connection
Make sure to write error from conmon on the hijacked http connection.
This fixes issues where errors were not reported on the client side,
for instance, when specified command was not found on the container.

To future generations: I am sorry.  The code is complex, and there are
many interdependencies among the concurrent goroutines.  I added more
complexity on top but I don't have a good idea of how to reduce
complexity in the available time.

Fixes: #8281
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-27 09:58:27 +01:00
OpenShift Merge Robot ad1e0bb77f
Merge pull request #9054 from vrothberg/fix-9040
make sure the workdir exists on container mount
2021-01-26 16:59:57 +01:00
Valentin Rothberg 0f668aa085 workdir presence checks
A container's workdir can be specified via the CLI via `--workdir` and
via an image config with the CLI having precedence.

Since images have a tendency to specify workdirs without necessarily
shipping the paths with the root FS, make sure that Podman creates the
workdir.  When specified via the CLI, do not create the path, but check
for its existence and return a human-friendly error.

NOTE: `crun` is performing a similar check that would yield exit code
127.  With this change, however, Podman performs the check and yields
exit code 126.  Since this is specific to `crun`, I do not consider it
to be a breaking change of Podman.

Fixes: #9040
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-26 09:02:21 +01:00
Daniel J Walsh 97f5e9458c
Pass DefaultMountsFile to podman build
The --default-mounts-file path was not being handled in
podman build.  This will enable it to use for testing.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-25 17:54:43 -05:00
Ed Santiago 33179c281e System tests: cover gaps from the last month
- stop: test --all and --ignore (#9051)
- build: test /run/secrets (#8679, but see below)
- sensitive mount points: deal with 'stat' failures
- selinux: confirm useful diagnostics on unknown labels (#8946)

The 'build' test is intended as a fix for #8679, in which
'podman build' does not mount secrets from mounts.conf.
Unfortunately, as of this writing, 'podman build' does
not pass the --default-mounts-file option to buildah,
so there's no reasonable way to test this path. Still,
we can at least confirm /run/secrets on 'podman run'.

The /sys thing is related to #8949: RHEL8, rootless, cgroups v1.
It's just a workaround to get gating tests to pass on RHEL.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-01-25 13:34:26 -07:00
Giuseppe Scrivano 0ba1942f26
networking: lookup child IP in networks
if a CNI network is added to the container, use the IP address in that
network instead of hard-coding the slirp4netns default.

commit 5e65f0ba30 introduced this
regression.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-01-23 18:28:56 +01:00
Giuseppe Scrivano 5e65f0ba30
rootlessport: set source IP to slirp4netns device
set the source IP to the slirp4netns address instead of 127.0.0.1 when
using rootlesskit.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-01-22 08:08:26 +01:00
Daniel J Walsh e7df73efad
Fix handling of container remove
I found several problems with container remove

podman-remote rm --all
Was not handled

podman-remote rm --ignore
Was not handled

Return better errors when attempting to remove an --external container.
Currently we return the container does not exists, as opposed to container
is an external container that is being used.

This patch also consolidates the tunnel code to use the same code for
removing the container, as the local API, removing duplication of code
and potential problems.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-20 07:37:13 -05:00
OpenShift Merge Robot a1b49749af
Merge pull request #8906 from vrothberg/fix-8501
container stop: release lock before calling the runtime
2021-01-14 13:37:16 -05:00
Valentin Rothberg d54478d8ea container stop: release lock before calling the runtime
Podman defers stopping the container to the runtime, which can take some
time.  Keeping the lock while waiting for the runtime to complete the
stop procedure, prevents other commands from acquiring the lock as shown
in #8501.

To improve the user experience, release the lock before invoking the
runtime, and re-acquire the lock when the runtime is finished.  Also
introduce an intermediate "stopping" to properly distinguish from
"stopped" containers etc.

Fixes: #8501
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-14 17:45:30 +01:00
Daniel J Walsh a6046dceef
Remove the ability to use [name:tag] in podman load command
Docker does not support this, and it is confusing what to do if
the image has more then one tag.  We are dropping support for this
in podman 3.0

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-12 17:38:32 -05:00
Valentin Rothberg 1d7e5227f8 image list: ignore bare manifest list
Handle empty/bare manifest lists when listing images.

Fixes: #8931
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-11 19:15:33 +01:00
Daniel J Walsh d9ebbbfe5b
Switch references of /var/run -> /run
Systemd is now complaining or mentioning /var/run as a legacy directory.
It has been many years where /var/run is a symlink to /run on all
most distributions, make the change to the default.

Partial fix for https://github.com/containers/podman/issues/8369

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-07 05:37:24 -05:00
OpenShift Merge Robot 54b82a175f
Merge pull request #8787 from jsoref/spelling
Spelling
2020-12-23 17:38:43 +01:00
Hironori Shiina d61887037d Fix podman build --logfile
A opened file object of a logfile gets lost because the variable
`logfile` is redefined in a `if` block. This fix stops redefining
the variable.

Signed-off-by: Hironori Shiina <Hironori.Shiina@fujitsu.com>
2020-12-22 21:48:07 -05:00
Josh Soref 4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
Valentin Rothberg 641272d411 system tests: set PODMAN_TIMEOUT to 120
The new Ubuntu 20.04 VMs seem very slow and fail reproducibly in a build
test (i.e, "wordir, cmd, env, label").  Bumping up the time out to 120
seconds will help get the CI green.

See github.com/containers/podman/pull/8747.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-12-18 14:34:13 +01:00
Valentin Rothberg adcb3a7a60 remote copy
Implement `podman-remote cp` and break out the logic from the previously
added `pkg/copy` into it's basic building blocks and move them up into
the `ContainerEngine` interface and `cmd/podman`.

The `--pause` and `--extract` flags are now deprecated and turned into
nops.

Note that this commit is vendoring a non-release version of Buildah to
pull in updates to the copier package.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-12-18 12:08:49 +01:00
Ed Santiago be0d56ce1c System tests: better diagnostics in completion test
Tracking down a CI failure earlier today, I was slightly
delayed by the absence of context information in a test
failure. This PR adds full command context to each
subtest, making it much easier for the developer to
narrow down the cause of a failure.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-16 12:20:07 -07:00
OpenShift Merge Robot bacb2fc526
Merge pull request #8312 from cevich/new_ubuntu_images
Cirrus: Update VM Images; Both Fedora and Ubuntu "prior" flavors run with CGroupsV1 & runc
2020-12-16 15:52:25 +00:00
Chris Evich f66ecc882d
Fix: unpause not supported for CGv1 rootless
Thanks Ed Santiago <santiago@redhat.com> for the fix.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-12-16 08:55:16 -05:00
OpenShift Merge Robot f1f7b8f6c8
Merge pull request #8730 from rhatdan/log
Add LogSize to container inspect
2020-12-16 11:23:23 +00:00
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 1345d0358b system tests: the catch-up game
- run test: minor cleanup to .containerenv test. Basically,
  make it do only two podman-runs (they're expensive) and
  tighten up the results checks

- ps test: add ps -a --storage. Requires small tweak to
  run_podman helper, so we can have "timeout" be an expected
  result

- sdnotify test: workaround for #8718 (seeing MAINPID=xxx as
  last output line instead of READY=1). As found by the
  newly-added debugging echos, what we are seeing is:

      MAINPID=103530
      READY=1
      MAINPID=103530

  It's not supposed to be that way; it's supposed to be just
  the first two. But when faced with reality, we must bend
  to accommodate it, so let's accept READY=1 anywhere in
  the output stream, not just as the last line.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-12-14 15:06:43 -07: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
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
Ed Santiago 2d5a2a7640 BATS and APIv2: more tests and tweaks
- (minor): apiv2 tests: check for full ID

   Observation made while reviewing #6461: tests were checking
   only for a 12-character container/image ID in return value.
   It's actually 64, and we should test for that. This should
   also minimize confusion in a future maintainer.

 - podman pause/unpause: new test

   Runs a 'date/sleep' loop, pauses container, sleeps 3s,
   restarts, then confirms that there's a 3- to 6-second
   gap in the logs for the container.

 - podman healthcheck: new test

   run a container with healthcheck, test both healthy
   and unhealthy conditions

 - podman pod: check '{{.Pod}}' field in podman ps

   Hey, as long as we have a pod with two running
   containers, might as well confirm that 'podman ps'
   returns the expected pod ID.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-03 16:13:33 -06:00
Ed Santiago 03d32d05ac system tests : more tests
- exec: add test for #5046, in which conmon swallowed chars
  on a large byte transfer

- pod: add 'pod exists' tests, both positive and negative;
  consolidate tests; add '--label', and check in 'pod inspect'
  add 'pod ps' tests

- networking: add test for #5466, in which detached run
  with --userns=keep-id would not forward a port

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-01 12:00:47 -06:00
OpenShift Merge Robot 9037908b78
Merge pull request #5594 from edsantiago/bats
system tests: enable skopeo REGISTRY_AUTH_FILE
2020-05-30 05:17:18 -04:00
Jhon Honce 5626c2163b V2 verify JSON output is consistent and doesn't drift
$ cd test/apiv2
$ python -m unittest -v test_rest_v1_0_0.TestApi

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-05-28 16:20:29 -07:00
Boaz Shuster 1f8a78747a Add --format to pod inspect
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2020-05-27 09:48:38 +03:00
OpenShift Merge Robot 3f2ab6bc2e
Merge pull request #6331 from sujil02/iidfile-battest
Enables iidfile test as issue fixed now
2020-05-22 12:09:18 +02:00
Sujil02 9f5e661cfe Enables iidfile test as issue fixed now
Signed-off-by: Sujil02 <sushah@redhat.com>
2020-05-21 18:37:31 -04:00
Daniel J Walsh 7b188f7b5b
podman version --format ... was not working
This patch fixes the podman --version --format command.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-21 16:31:34 -04:00
OpenShift Merge Robot 835d2644b8
Merge pull request #6280 from mheon/switch_off_noexec
Turn off 'noexec' option by default for named volumes
2020-05-21 16:26:20 +02:00
Matthew Heon cc65430145 Turn off 'noexec' option by default for named volumes
We previously enforced this for security reasons, but as Dan has
explained on several occasions, it's not very valuable there
(it's trivially easy to bypass) and it does seriously annoy folks
trying to use named volumes. Flip the default from 'on' to 'off'.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-05-20 16:48:20 -04:00
Ed Santiago a4bfcd75aa system tests: more podman-pod tests
* rename pod-top.bats to pod.bats
* add test for TCP port communication between pods
* add test for various podman-pod-create options

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-20 11:04:54 -06:00
Ed Santiago cd85ba196d system tests: small fixes for rawhide+cgroups v1
Three small fixes for breaking tests on rawhide:

  1) run test: looks like runc changed the format of
     an error message, adding a colon in one place.
     runc is used on rawhide when booted in cgroups v1

  2) volumes test: difference in exit status and error
     message between runc and crun.

  3) systemd test: define XDG_RUNTIME_DIR if unset.
     podman helpfully sets this to a reasonable default,
     but the 'systemctl' commands used in this test do not.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-14 09:55:25 -06:00
Ed Santiago 3ec335bc9f system tests: add volume tests
Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-12 14:43:17 -06:00
Ed Santiago a82de0e3a0 Some BATS cleanup: run and systemd tests
run test: run positive test before negative; and actually
implement real negative tests. Also, add confirmation tests for
cidfile/pidfile, not just 'exit status is good'.

systemd test: enable rootless, and again add actual content
testing.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-11 09:30:09 -06:00
Valentin Rothberg 42c6aa1a42 fix and enable systemd system tests
The systemd unit test never ran in CI and was broken for various
reasons.  Fix the test to execute Podman in systemd units and to also
run generated units files.

Note: more tests will be added in the future.  The simple check for now
will prevent regressions.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-08 13:05:25 +02:00
Valentin Rothberg 676efd89d5 set --conmon-pidfile
The --conmon-pidfile was not set in the spec leading to failing systemd
units.  Also add a system test to prevent future regressions.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-08 10:53:11 +02:00
Ed Santiago 29d39e35e4 BATS help test: check usage string
Now that we've agreed that usage messages should match
what the user typed, confirm it. IOW 'podman foo --help'
should not issue a usage message for 'podman container foo'.

Fix one broken instance, 'unpause'.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-05 07:19:58 -06:00
baude 52371057cd fix commands without input
in cases where commands require input and we dont provide it, we often would segv.  This can be attributed in many cases to the subcommand not picked up the cobra Args attribute or neither had them.

Signed-off-by: baude <bbaude@redhat.com>
2020-04-30 15:10:49 -05:00
Ed Santiago 91a42fefcb System tests: help messages: check required-arg
If a usage message is of the form '... [flags] ARGNAME',
where ARGNAME is all-caps and not in brackets, it must
be a required argument. Try running podman subcommand
without ARGNAME, and make sure that podman bails out
with an informative message. (Since this message is
freeform in each subcommand, not Cobra-generated,
we have a lot of possible variations to check for).

Fix podman login/logout Use messages to indicate that
REGISTRY is now optional (as of #5233).

This test has actually been in place for over a year but
due to a typo on my part -- a missing space -- it was
not being run. "For want of a space, much testing was lost".

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-30 14:55:10 -05:00
baude e1f1dee006 enable final system test
Signed-off-by: baude <bbaude@redhat.com>
2020-04-29 12:01:18 -05:00
Valentin Rothberg 5c108f75eb login system test: enable "push ok"
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-29 15:23:30 +02:00
Ed Santiago daeb6f00b2 system tests: enable skopeo REGISTRY_AUTH_FILE
skopeo pr #829 adds REGISTRY_AUTH_FILE support; this lets us
enable the following test:

  podman login - shares credentials with skopeo - via envariable

(I seriously doubt that the CI VMs have been updated with the
new skopeo, but I can leave this PR in limbo until that happens.
Otherwise I'll forget to enable the test).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-29 05:45:11 -06:00
Valentin Rothberg b2414b580e generate systemd
Implement `podman generate systemd` for Podman v2 and enable associated
tests.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-29 07:22:18 +02:00
Brent Baude 517bc28360 system tests must pass
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-28 15:17:00 -05:00
Brent Baude 44a8cf8676 Fixes for system tests
Various fixes to protect against regressions in system tests

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-17 13:22:06 -05:00
Brent Baude 90ead05903 Fixes for load and other system tests
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-13 13:08:04 -05:00
Brent Baude e20ecc733c refactor info
the current implementation of info, while typed, is very loosely done so.  we need stronger types for our apiv2 implmentation and bindings.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-06 12:45:42 -05:00
Kunal Kushwaha 19bf7adedb Improved readability in image json output
Changes made in json output to improve readability of
podman images output.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
2020-03-22 21:38:07 +09:00
Ed Santiago 3585780876 run --rmi test: make it work
The recently-added 'run --rmi' test was not actually doing
what it thinks it was doing: for one, 'run_podman | grep'
is never going to work; also, the test was leaving behind
stray images.

Rework to do what I believe the intention was; and, combine
into one test (down from two) for readability.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-03-12 07:57:11 -06:00
Boaz Shuster 11e5c53d11 Add the rmi flag to podman-run to delete container image
The --rmi flag will delete the container image after its execution
unless that image is already been used by another container(s).

This is useful when one wants to execute a container once and remove
any resources attached to it.

Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2020-03-03 14:27:11 +02:00
Ed Santiago 40470b45d3 kill test: clean up warnings; document better
9f69c4eca (part of the f31 pr, #3091) semi-broke the kill test,
there's now an ugly warning:

    setup(): removing stray images quay.io/libpod/fedora-minimal:latest 7bb5a60e8a78

The comments also didn't actually explain the problem
being addressed, and included a misleading reference
to busybox.

Here we switch to using fedora-minimal only with podman-remote,
clean it up (rmi) when finished, and include an explanation in
the comments about why this is needed; making it clear that
this workaround can be removed once we get rid of podman-remote.
We also reformat back to 80 columns.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-26 11:01:38 -07:00
Chris Evich 4511e15f8c
Fix kill test obtaining CID
It's possible/likely the container image for the test will need to be
pulled as part of the `run` command.  Due to the way BATS handles
output, messages regarding image-pull could be misinterpreted as the
container's CID.  Force the CID to be obtained by only the last line of
output.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-02-25 12:34:26 -05:00
Chris Evich 9f69c4ecaf
System Tests: Force default signal handlers
Recommended as part of:
https://github.com/containers/libpod/issues/5004

and

https://github.com/containers/crun/issues/230

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-02-25 12:34:26 -05:00
Ed Santiago fab5b35b2a Friendly amendment: tests, and a help message
1) Help message for podman port was missing [PORT]

2) Add test for 'podman port'. And, actually, an entire
   networking test that I'd written some weeks ago but
   apparently didn't 'git add'.

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-23 11:04:39 -06:00
Ed Santiago 9ecf8e13dc Login test: use --password-stdin
Great timing: this new test collided against #5268, which added
a warning about using command-line --password. CI is now going
to fail all over.

Fix: rework test to use --password-stdin. Am doing so only
in the places where output string is checked; other instances
can keep using '--password xxx' because it's simpler.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-20 11:18:36 -07:00
Ed Santiago 29930fae70 podman images: add --filter=since=XX
Looks like a bit of a misunderstanding from early on.

Docker implements --filter=since=IMAGE. Podman implements 'after'
instead of 'since'. Add an equivalent case statement to handle
both, keeping 'after' because we have no way of knowing if it
is used in the field.

Update documentation ... and fix what looks like a complete
misinterpretation of what the code actually does: the man page
claimed that these were time fields, but I don't see any
possible incantation in which a time value works or could
work. Updated docs to reflect IMAGE usage. Also changed
nonworking '==' to single '='.

Added tests. [UPDATE: skip with broken podman-remote]

Fixes: #5040

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-20 07:55:29 -07:00
Ed Santiago 67c1b7e3b4 New login and push tests
Test podman login/logout, login with wrong credentials,
auth file contents, auth file path override, push/pull,
and, if skopeo is installed, credentials sharing

Fixes: #4283

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-02-19 09:51:06 -07:00
Valentin Rothberg 85b7374491 add pkg/signal
Add pkg/signal to deal with parts of signal processing and translating
signals from string to numeric representations.  The code has been
copied from docker/docker (and attributed with the copyright) but been
reduced to only what libpod needs (on Linux).

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-02-14 15:04:14 +01:00
OpenShift Merge Robot 0870e88ff4
Merge pull request #4824 from edsantiago/bats
more BATS tests
2020-01-15 23:33:02 +01:00
Ed Santiago 1298f19773 more BATS tests
- run: --name (includes 'podman container exists' tests)
- run: --pull (always, never, missing)
- build: new test for ADD URL (#4420)
- exec: new test for issue #4785 (pipe getting lost)
- diff: new test
- selinux (mostly copied from docker-autotest)

Plus a bug fix: the wait_for_output() helper would continue
checking, eventually timing out, even if the container had
already exited (probably because of an error). Fix: as
part of the loop, run 'podman inspect' and bail out if
container is not running. Include exit code and logs.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-01-13 06:29:52 -07:00
Daniel J Walsh 4093b2c011
Add codespell to validate spelling mistakes in code.
Fix all errors found by codespell

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-11 06:32:19 -05:00
Ed Santiago 0f78f345d9 Fix race condition in kill test leading to hang
When you open a FIFO for reading, but there's no writer, you hang.
This is just one of those obscure UNIXisms we all know but just
forget all too often.

My last PR was guilty of introducing such a condition; I caught
it by accident while testing other stuff. In short, the signal
container was doing 'echo DONE' as its last step, and we (BATS)
were reading the FIFO to check for it; but if the container
exited before we opened the FIFO for read, the open would hang.
This is not a hang that we can catch in the test: it would hang
the entire job forever. CI would presumably time out eventually,
but with no useful indication of the cause of the error.

Solution: use 'exec' to open the FIFO early and keep it open,
and use 'read -u FD' instead of 'read <$fifo': the former
reads from an open FD, the latter forces a new open() each time.

There is a shorter, more maintainable solution -- see #4755 -- but
that suffers from the same hanging problem in the (unlikely) case
where the signal-handling container exits, e.g. if signal handling
is broken in podman. The test would hang, with no helpful indicator.
Although this PR is a little more advanced scripting, I have
commented the relevant code well and believe the maintenance
cost is worth the risk of undebuggable hangs.

There is still a hang risk: if 'podman logs -f' fails and exits
immediately, the 'exec' will hang. I can't think of a non-racy
way to prevent that, and choose to live with that risk.

Tested by temporarily including 9 (SIGKILL) in the signals list.
The read timeout triggers, and the end user has a fair chance
of tracking down the root cause.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-28 08:00:05 -07:00
Ed Santiago 40f55ca3fe signal parsing - better input validation
The helper function we use for signal name mapping does not
check for negative numbers nor invalid (too-high) ones. This
can yield unexpected error messages:

   # podman kill -s -1 foo
   ERRO[0000] unknown signal "18446744073709551615"

This PR introduces a small wrapper for it that:

  1) Strips off a leading dash, allowing '-1' or '-HUP'
     as valid inputs; and
  2) Rejects numbers <1 or >64 (SIGRTMAX)

Also adds a test suite checking signal handling as well as
ensuring that invalid signals are rejected by the command line.

Fixes: #4746

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-26 16:50:21 -07:00
Ed Santiago ebc4ae660d podman images history test - clean up
As initially written the test does not work other than in
a CI environment because it relies on an empty tag history.
Rewrite so we can guarantee that, by creating a new image.

Also add slightly more helpful tests: the initial tests
would just show "expected 0, got 1" which is unhelpful.
Tweak so we test on actual history contents, which will
show more informative messages on failure.

And, finally, clean up after ourselves.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-12 08:56:44 -07:00
Ed Santiago 235d4e457a test for #3920 (improper caching of tarballs in build)
See https://github.com/containers/buildah/pull/1955

I've confirmed that this test fails under podman-1.6.2-2.fc30
and passes under current master.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-05 07:28:18 -07:00
Sascha Grunert 63e46cc85c
Add support for image name history
We leverage the containers/storage image history tracking feature to
show the previously used image names when running:
`podman images --history`

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-11-27 13:42:06 +01:00
Valentin Rothberg 77a2bbb1c0 stats: list all running containers unless specified otherwise
Unless specified otherwise by --all, --latest or via arguments, list all
running containers.  This matches the behaviour of Docker and is also
illustrated in the man pages where containers and options are marked to
be optional.

Fixes: #4274
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-10-23 13:48:54 +02:00
Alex Jia 774a36d177 System tests: make sure exec pid hash w/o leaking
podman exec leaks an exec_pid_<hash> file for every exec in tmpfs,
it's known rhbz#1731117, this case makes sure leakage issue has
been fixed.

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

Signed-off-by: Alex Jia <chuanchang.jia@gmail.com>
2019-10-18 15:04:09 +08:00
Matthew Heon cab7bfbb21 Add a MissingRuntime implementation
When a container is created with a given OCI runtime, but then it
is uninstalled or removed from the configuration file, Libpod
presently reacts very poorly. The EvictContainer code can
potentially remove these containers, but we still can't see them
in `podman ps` (aside from the massive logrus.Errorf messages
they create).

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

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-10-15 15:59:20 -04:00
OpenShift Merge Robot 86c8650c23
Merge pull request #4174 from cevich/use_bash_not_sh
System-tests: Use bash explicitly
2019-10-03 11:28:58 -07:00
Ed Santiago 0ed9763b72 system tests: info: deal with hyphen in username
...e.g. cloud-user. 9822f54ac was intended to fix this,
but it doesn't. Simple and standard solution is to
move the dash to the end of the character class.

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

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

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

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-10-02 06:22:36 -06:00
Qi Wang 0144c3796b fix cp none exists dest path ends with '/'
close #3894
This patch let podman cp return 'no such file or directory' error if DEST_PATH does not exist and ends with / when copying file.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2019-09-25 12:48:05 -04:00
Ed Santiago c146f8d7d2 system tests: run test: reenable and fix
Test had incorrectly been disabled for all podman; it
should've been disabled only for podman-remote. Fixed
that, and fixed the problem that was causing failures:
podman-remote is gobbling up stdin (#4095), so no
tests were actually being run at all, or only one.
Fixed by redirecting input on the run_podman invocation.
Added, as backup, a confirmation mechanism to ensure
that all expected tests are being run.

Note that test is reenabled, but the output check is
disabled for podman-remote due to #4096; this at least
lets us check exit status.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-09-24 08:46:40 -06:00
Chris Evich 52c4df0f9a
System-test: Temporarily disable 030-run
While investigating issue
https://github.com/containers/libpod/issues/4044 there is no sense
subjecting forward progress elsewhere.  Skip the test with a note
temporarily, until a resolution to 4044 and any other related issues
is found and fix implemented.

Signed-off-by: Chris Evich <cevich@redhat.com>
2019-09-17 12:54:49 -04:00
OpenShift Merge Robot 7875e00c66
Merge pull request #3934 from rhatdan/wait
Podman-remote run should wait for exit code
2019-09-13 18:12:25 +02:00
Jhon Honce a6836eae52 Do not support wildcards on cp
* symlink processing and wildcarding led to unexpected files
  being copied

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-09-12 16:56:38 -07:00