Commit graph

2513 commits

Author SHA1 Message Date
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
OpenShift Merge Robot a26b15265e
Merge pull request #9598 from rhatdan/kvm
Check for supportsKVM based on basename of the runtime
2021-03-04 14:54:53 -05:00
OpenShift Merge Robot 87a78c059d
Merge pull request #9601 from jwhonce/issues/9207
Use version package to track all versions
2021-03-04 09:46:24 -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
Paul Holzinger aa0a57f095 Fix cni teardown errors
Make sure to pass the cni interface descriptions to cni teardowns.
Otherwise cni cannot find the correct cache files because the
interface name might not match the networks. This can only happen
when network disconnect was used.

Fixes #9602

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-03-04 11:43:59 +01:00
Jhon Honce f86d641308 Use version package to track all versions
* Server, bindings, and CLI all now pull version information from version
package.
* Current /libpod API version slaved to podman/libpod Version
* Bindings validate against libpod API Minimal version
* Remove pkg/bindings/bindings.go and updated tests

Fixes: #9207

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-03-03 17:03:19 -07: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 5fd8a84949
Merge pull request #9575 from mheon/rewrite_rename
Rewrite Rename backend in a more atomic fashion
2021-03-03 09:16:19 -05:00
OpenShift Merge Robot 2a3460b26d
Merge pull request #9521 from adrianreber/2021-02-25-checkpointctl
Reorder checkpoint/restore code for CRI-O
2021-03-03 02:06:19 -08:00
Ashley Cui b19791c0b6 Tidy duplicate log tests
Some log tests were duplicated, and some didn't need to be repeated for
every driver. Also, added some comments

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-03-02 14:28:16 -05:00
Matthew Heon 43e899c2ec Rewrite Rename backend in a more atomic fashion
Move the core of renaming logic into the DB. This guarantees a
lot more atomicity than we have right now (our current solution,
removing the container from the DB and re-creating it, is *VERY*
not atomic and prone to leaving a corrupted state behind if
things go wrong. Moving things into the DB allows us to remove
most, but not all, of this - there's still a potential scenario
where the c/storage rename fails but the Podman rename succeeds,
and we end up with a mismatched state.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2021-03-02 13:30:28 -05:00
Adrian Reber 91b2f07d5b
Use functions and defines from checkpointctl
No functional changes.

[NO TESTS NEEDED] - only moving code around

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-03-02 17:00:06 +00:00
Adrian Reber bf92e21113
Move checkpoint/restore code to pkg/checkpoint/crutils
To be able to reuse common checkpoint/restore functions this commit
moves code to pkg/checkpoint/crutils.

This commit has not functional changes. It only moves code around.

[NO TESTS NEEDED] - only moving code around

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-03-02 17:00:06 +00:00
Valentin Rothberg 3752016338 podman rmi: handle corrupted storage better
The storage can easily be corrupted when a build or pull process (or any
process *writing* to the storage) has been killed.  The corruption
surfaces in Podman reporting that a given layer could not be found in
the layer tree.  Those errors must not be fatal but only logged, such
that the image removal may continue.  Otherwise, a user may be unable to
remove an image.

[NO TESTS NEEDED] as I do not yet have a reliable way to cause such a
storage corruption.

Reported-in: https://github.com/containers/podman/issues/8148#issuecomment-787598940
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-03-01 09:52:03 +01:00
OpenShift Merge Robot b154c519ac
Merge pull request #9509 from mlegenovic/master
Correct compat images/create?fromImage response
2021-03-01 08:27:47 +01:00
Milivoje Legenovic fcce1da1bb Correct compat images/create?fromImage response
Signed-off-by: Milivoje Legenovic <m.legenovic@gmail.com>
2021-02-26 03:08:10 +01:00
baude 24d9bda7ff prune remotecommand dependency
prune a dependency that was only being used for a simple struct.  Should
correct checksum issue on tarballs

[NO TESTS NEEDED]

Fixes: #9355

Signed-off-by: baude <bbaude@redhat.com>
2021-02-25 10:02:41 -06:00
OpenShift Merge Robot dec06b1c3f
Merge pull request #9494 from mheon/sort_caps
Sort CapDrop in inspect to guarantee order
2021-02-24 09:27:24 -05:00
Paul Holzinger 90050671b7 Add dns search domains from cni response to resolv.conf
This fixes slow local host name lookups.
see containers/dnsname#57

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-24 10:41:56 +01:00
Paul Holzinger f152f9cf09 Network connect error if net mode is not bridge
Only the the network mode bridge supports cni networks.
Other network modes cannot use network connect/disconnect
so we should throw a error.

Fixes #9496

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-23 22:30:04 +01:00
OpenShift Merge Robot ca0af71bef
Merge pull request #9485 from vrothberg/fix-9479
container removal: handle already removed containers
2021-02-23 14:53:26 -05:00
Matthew Heon fc32ec768d Sort CapDrop in inspect to guarantee order
The order of CapAdd when inspecting containers is deterministic.
However, the order of CapDrop is not (for unclear reasons). Add a
quick sort on the final array to guarantee a consistent order.

Fixes #9490

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-02-23 14:05:18 -05: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
Eduardo Vega 874f2327e6 Add U volume flag to chown source volumes
Signed-off-by: Eduardo Vega <edvegavalerio@gmail.com>
2021-02-22 22:55:19 -06:00
Paul Holzinger 9d818be732 Fix podman network IDs handling
The libpod network logic knows about networks IDs but OCICNI
does not. We cannot pass the network ID to OCICNI. Instead we
need to make sure we only use network names internally. This
is also important for libpod since we also only store the
network names in the state. If we would add a ID there the
same networks could accidentally be added twice.

Fixes #9451

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-22 15:51:49 +01:00
Valentin Rothberg 5dded6fae7 bump go module to v3
We missed bumping the go module, so let's do it now :)

* Automated go code with github.com/sirkon/go-imports-rename
* Manually via `vgrep podman/v2` the rest

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 09:03:51 +01:00
Daniel J Walsh 05eb06f568 Turn on journald and k8s file logging tests
Signed-off-by: Ashley Cui <acui@redhat.com>
2021-02-19 16:11:41 -05:00
Ashley Cui 612ba6aa82 Fix journald logs with more than 1 container
A podman logs on multiple containers will correctly display the
container ID next to the log line

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-02-19 02:21:12 -05:00
Ashley Cui 9016387bba Fix journald logs --follow
Previously, --follow with a podman logs using journald would not exit

Signed-off-by: Ashley Cui <acui@redhat.com>
2021-02-19 02:21:12 -05:00
Ashley Cui f2d057c943 Fix journald logs --since
Signed-off-by: Ashley Cui <acui@redhat.com>
2021-02-19 02:21:12 -05:00
Ashley Cui fbc50e5285 fix journald logs --tail 0
Signed-off-by: Ashley Cui <acui@redhat.com>
2021-02-19 02:21:12 -05:00
Matthew Heon a9d548bf77 Change source path resolution for volume copy-up
Instead of using the container's mountpoint as the base of the
chroot and indexing from there by the volume directory, instead
use the full path of what we want to copy as the base of the
chroot and copy everything in it. This resolves the bug, ends up
being a bit simpler code-wise (no string concatenation, as we
already have the full path calculated for other checks), and
seems more understandable than trying to resolve things on the
destination side of the copy-up.

Fixes #9354

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2021-02-17 14:57:06 -05:00
OpenShift Merge Robot d48f4a0e1f
Merge pull request #9383 from mheon/fix_copyup_empty
Fix an issue where copyup could fail with ENOENT
2021-02-17 13:18:33 -05:00
Daniel J Walsh 5d1ec2960d
Do not reset storage when running inside of a container
Currently if the host shares container storage with a container
running podman, the podman inside of the container resets the
storage on the host. This can cause issues on the host, as
well as causes the podman command running the container, to
fail to unmount /dev/shm.

podman run -ti --rm --privileged -v /var/lib/containers:/var/lib/containers quay.io/podman/stable podman run alpine echo hello
	* unlinkat /var/lib/containers/storage/overlay-containers/a7f3c9deb0656f8de1d107e7ddff2d3c3c279c11c1635f233a0bffb16051fb2c/userdata/shm: device or resource busy
	* unlinkat /var/lib/containers/storage/overlay-containers/a7f3c9deb0656f8de1d107e7ddff2d3c3c279c11c1635f233a0bffb16051fb2c/userdata/shm: device or resource busy

Since podman is volume mounting in the graphroot, it will add a flag to
/run/.containerenv to tell podman inside of container whether to reset storage or not.

Since the inner podman is running inside of the container, no reason to assume this is a fresh reboot, so if "container" environment variable is set then skip
reset of storage.

Also added tests to make sure /run/.containerenv is runnig correctly.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-16 14:18:53 -05: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
OpenShift Merge Robot aadb16da38
Merge pull request #9380 from baude/podinfra
Fix panic in pod creation
2021-02-16 09:25:28 -05:00
Matthew Heon 759fc93343 Fix an issue where copyup could fail with ENOENT
This one is rather bizarre because it triggers only on some
systems. I've included a CI test, for example, but I'm 99% sure
we use images in CI that have volumes over empty directories, and
the earlier patch to change copy-up implementation passed CI
without complaint.

I can reproduce this on a stock F33 VM, but that's the only place
I have been able to see it.

Regardless, the issue: under certain as-yet-unidentified
environmental conditions, the copier.Get method will return an
ENOENT attempting to stream a directory that is empty. Work
around this by avoiding the copy altogether in this case.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-02-16 09:21:49 -05:00
OpenShift Merge Robot 6639b218a2
Merge pull request #9368 from vrothberg/fix-9365
podman build: pass runtime to buildah
2021-02-16 08:53: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
baude f2f18768a8 Fix panic in pod creation
when creating a pod with --infra-image and using a untagged image for
the infra-image (none/none), the lookup for the image's name was
creating a panic.

Fixes: #9374

Signed-off-by: baude <bbaude@redhat.com>
2021-02-16 06:29:49 -06: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 3d50393f09
Don't chown workdir if it already exists
Currently podman is always chowning the WORKDIR to root:root
This PR will return if the WORKDIR already exists.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-02-16 04:52:02 -05:00
OpenShift Merge Robot 1d15ed708f
Merge pull request #9341 from vrothberg/layer-tree-errors
make layer-tree lookup errors non-fatal
2021-02-12 13:32:00 -05:00
Valentin Rothberg adfcb74602 make layer-tree lookup errors non-fatal
Internally, Podman constructs a tree of layers in containers/storage to
quickly compute relations among layers and hence images.  To compute the
tree, we intersect all local layers with all local images.  So far,
lookup errors have been fatal which has turned out to be a mistake since
it seems fairly easy to cause storage corruptions, for instance, when
killing builds.  In that case, a (partial) image may list a layer which
does not exist (anymore).  Since the errors were fatal, there was no
easy way to clean up and many commands were erroring out.

To improve usability, turn the fatal errors into warnings that guide the
user into resolving the issue.  In this case, a `podman system reset`
may be the approriate way for now.

[NO TESTS NEEDED] because I have no reliable way to force it.

[1] https://github.com/containers/podman/issues/8148#issuecomment-778253474

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-12 17:23:01 +01:00
Paul Holzinger 78c8a87362 Enable whitespace linter
Use the whitespace linter and fix the reported problems.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-11 23:01:56 +01:00
Paul Holzinger 69ab67bf90 Enable golint linter
Use the golint linter and fix the reported problems.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-11 23:01:49 +01:00
Paul Holzinger ef2fc90f2d Enable stylecheck linter
Use the stylecheck linter and fix the reported problems.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-11 23:01:29 +01:00
OpenShift Merge Robot ca354f13f2
Merge pull request #9308 from mheon/fix_6003
Rewrite copy-up to use buildah Copier
2021-02-11 05:23:34 -05:00
baude 5ccb1596b4 Display correct value for unlimited ulimit
When doing a container inspect on a container with unlimited ulimits,
the value should be -1.  But because the OCI spec requires the ulimit
value to be uint64, we were displaying the inspect values as a uint64 as
well.  Simple change to display as an int64.

Fixes: #9303

Signed-off-by: baude <bbaude@redhat.com>
2021-02-10 14:17:58 -06:00
Matthew Heon ea910fc535 Rewrite copy-up to use buildah Copier
The old copy-up implementation was very unhappy with symlinks,
which could cause containers to fail to start for unclear reasons
when a directory we wanted to copy-up contained one. Rewrite to
use the Buildah Copier, which is more recent and should be both
safer and less likely to blow up over links.

At the same time, fix a deadlock in copy-up for volumes requiring
mounting - the Mountpoint() function tried to take the
already-acquired volume lock.

Fixes #6003

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-02-10 14:21:37 -05:00