Commit graph

441 commits

Author SHA1 Message Date
Daniel J Walsh f22791aec7
Handle hard links in remote builds
Fixes: https://github.com/containers/podman/issues/9893

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-22 05:27:03 -04:00
Daniel J Walsh 4c095aa7e2
Improve OCI Runtime error
ErrOCIRuntimeNotFound error is misleading. Try to make it more
understandable to the user that the OCI Runtime IE crun or runc is not
missing, but the command they attempted to run within the container is
missing.

[NO TESTS NEEDED] Regular tests should handle this.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-22 04:58:48 -04:00
OpenShift Merge Robot 6a6ef402c3
Merge pull request #10400 from rhatdan/root
Clear the storage-options from the graphdriver if users specifies --root
2021-05-21 17:40:24 +02:00
Valentin Rothberg 8352e5bc3b add libimage events
libimage now supports events which `libpod.Runtime` now uses for image
events.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-20 12:33:09 +02:00
Daniel J Walsh 55f00bac02
Clear the storage-options from the graphdriver if users specifies --root
Fixes: https://github.com/containers/podman/issues/10393

Currently if a user specifies a --root flag to override the location of
the container storage, we still enforce the storage-opts from
storage.conf. This causes issues with people trying to intereact with
the additional stores feature, and then forces them to use the obscure
--storage-opt="" option. I belive this should be the default and we
already do this when the user specifies the --storage-driver option.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-19 15:35:59 -04:00
Daniel J Walsh bc0e12a047
Fix problem copying files when container is in host pid namespace
When attempting to copy files into and out of running containers
within the host pidnamespace, the code was attempting to join the
host pidns again, and getting an error. This was causing the podman
cp command to fail. Since we are already in the host pid namespace,
we should not be attempting to join.  This PR adds a check to see if
the container is in NOT host pid namespace, and only then attempts to
join.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-19 07:55:48 -04:00
OpenShift Merge Robot 3aa4746fb6
Merge pull request #10339 from rhatdan/selinux
Support automatic labeling of kube volumes
2021-05-17 16:27:20 -04:00
OpenShift Merge Robot f65d9309cb
Merge pull request #10270 from rhatdan/mtab
Create the /etc/mtab file if does not exists
2021-05-17 15:35:20 -04:00
OpenShift Merge Robot 62a7d4b61e
Merge pull request #9972 from bblenard/issue-5651-hostname-for-container-gateway
Add host.containers.internal entry into container's etc/hosts
2021-05-17 10:45:23 -04:00
Baron Lenardson c8dfcce6db Add host.containers.internal entry into container's etc/hosts
This change adds the entry `host.containers.internal` to the `/etc/hosts`
file within a new containers filesystem. The ip address is determined by
the containers networking configuration and points to the gateway address
for the containers networking namespace.

Closes #5651

Signed-off-by: Baron Lenardson <lenardson.baron@gmail.com>
2021-05-17 08:21:22 -05:00
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