Commit graph

474 commits

Author SHA1 Message Date
Daniel J Walsh 404488a087
Run codespell to fix spelling
[NO TESTS NEEDED] Just fixing spelling.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-08-11 16:41:45 -04:00
Paul Holzinger 8b9b925e78
skip flaking auto-update test
This test flakes on almost every PR, so skip it for now until
someone can fix it, see #11175.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-08-10 11:06:38 +02:00
openshift-ci[bot] 6513adda18
Merge pull request #11134 from rhatdan/buildx
Alias build to buildx, so it won't fail
2021-08-09 20:09:16 +00:00
Daniel J Walsh 170fb25729
Alias build to buildx, so it won't fail
Add hidden --load and --progress flag as well.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-08-09 13:05:49 -04:00
Paul Holzinger 1adeb2b70f
podman info show correct slirp4netns path
The slirp4netns path can be set in the config file or with
--network-cmd-path. Podman info should read the version information
correctly and not use PATH in this case. Also show the slirp4netns
version information to root users.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-08-09 12:59:28 +02:00
Valentin Rothberg 30df551bde auto-update: simple rollback
Add support for simple rollbacks during `podman auto-update`.  Rollbacks
are enabled by default.  If a systemd unit cannot be restarted after an
update, the previous image will be retagged and the unit will be
restarted a second time.

Add system tests for rollbacks.  Also fix a bug in the restart sequence;
we have to use the channel to actually know whether the restart was
successful or not.

NOTE: To make rollbacks really useful, users must run their containers
with `--sdnotify=container` such that the containers send the ready
message over the (mounted) socket.  This way, restarting the systemd
units during auto update will block until the message has been received
(or a timeout kicked in).

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-08-05 15:20:38 +02:00
Daniel J Walsh 41f94a4dc1
Fix podman unpause,pause,kill --all to work like podman stop --all
Currently if you execute podman unpause --all, podman pause --all
Podman shows attempts to unpause containers that are not paused
and prints an error.  This PR catches this error and only prints errors if
a paused container was not able to be unpaused.

Currently if you execute podman pause --all or podman kill --all, Podman
Podman shows attempts to pause or kill containers that are not running
and prints an error.  This PR catches this error and only prints errors if
a running container was not able to be paused or killed.

Also change printing of multiple errors to go to stderr and to prefix
"Error: " in front to match the output of the last error.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-08-04 12:50:00 -04:00
Ed Santiago ecf1033023 podman info: try qfile before equery
podman info takes >20s on Gentoo, because equery is s..l..o..w.
qfile is much faster and, I suspect, present in most Gentoo
installations, so let's try it first.

And, because packageVersion() was scarily unmaintainable,
refactor it. Define a simple (string) list of packaging tools
to query (rpm, dpkg, ...) and iterate until we find one that
works.

IMPORTANT NOTE: the Debian (and, presumably, Ubuntu) query does not
include version number! There is no standard way on Debian to get
a package version from a file path, you can only do it via pipes
of chained commands, and I have no desire to implement that.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-08-03 14:54:06 -06:00
openshift-ci[bot] cbad561696
Merge pull request #11091 from Luap99/connect-disconnect
fix rootless port forwarding with network dis-/connect
2021-08-03 18:59:01 +00:00
Paul Holzinger e88d8dbeae
fix rootless port forwarding with network dis-/connect
The rootlessport forwarder requires a child IP to be set. This must be a
valid ip in the container network namespace. The problem is that after a
network disconnect and connect the eth0 ip changed. Therefore the
packages are dropped since the source ip does no longer exists in the
netns.
One solution is to set the child IP to 127.0.0.1, however this is a
security problem. [1]

To fix this we have to recreate the ports after network connect and
disconnect. To make this work the rootlessport process exposes a socket
where podman network connect/disconnect connect to and send to new child
IP to rootlessport. The rootlessport process will remove all ports and
recreate them with the new correct child IP.

Also bump rootlesskit to v0.14.3 to fix a race with RemovePort().

Fixes #10052

[1] https://nvd.nist.gov/vuln/detail/CVE-2021-20199

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-08-03 16:29:09 +02:00
Daniel J Walsh 985c717085
Fix handling of user specified container labels
Currently we override the SELinux labels specified by the user
if the container is runing a kata container or systemd container.

This PR fixes to use the label specified by the user.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-08-02 17:08:08 -04:00
Hironori Shiina 9d33abac65 Fix auto-update system test for older systemd
If the systemd version is older than v245, the systemd uses 'Started'
when a oneshot service finishes.

In systemd, the change was done at:
  https://github.com/systemd/systemd/pull/14851
  commit-id: eda0cbf07186d16a160bd1d810613586fdbdf587

Signed-off-by: Hironori Shiina <shiina.hironori@jp.fujitsu.com>
2021-07-30 21:16:36 -04:00
Ed Santiago d59391c047 system tests: fix race in stop test
In the unlock/timeout test, on slow systems, 'podman ps' could
catch the container before the just-backgrounded 'podman stop'
sends the signal. Wait for signal ack from container before
we inspect it.

Also: If I understand the test correctly, it wasn't actually
checking that 'ps' could grab the lock while the container
was exiting. Add a check.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-07-29 11:57:51 -06:00
Valentin Rothberg 4df6e31ccb remote build: fix streaming and error handling
Address a number of issues in the streaming logic in remote build, most
importantly an error in using buffered channels on the server side.

The pattern below does not guarantee that the channel is entirely read
before the context fires.

for {
	select {
		case <- bufferedChannel:
		...
		case <- ctx.Done():
		...
	}
}

Fixes: #10154
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-28 14:46:15 +02:00
Valentin Rothberg 0aec93edca cp system tests: reduce number of exec's
Reduce the amount of `podman exec`s in the cp system tests.
Exec is expensive and a number of them could easily be combined
into the container command.

This cuts down the costs of running the tests by around 25 percent
on my local machine.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-27 15:32:23 +02:00
Mehul Arora 6fe03b25ab support container to container copy
Implement container to container copy.  Previously data could only be
copied from/to the host.

Fixes: #7370
Co-authored-by: Mehul Arora <aroram18@mcmaster.ca>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-27 15:32:23 +02:00
OpenShift Merge Robot 5ef78c0bfa
Merge pull request #11019 from boaz0/test_cors
Add tests to verify CORs is enabled
2021-07-26 13:56:19 +02:00
Boaz Shuster 1a188f6223 Add tests to verify CORS is enabled
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2021-07-25 05:48:16 +03:00
OpenShift Merge Robot ec5c7c1f6a
Merge pull request #10895 from rhatdan/devices
Support DeviceCgroupRules to actually get added.
2021-07-24 06:09:17 -04:00
OpenShift Merge Robot d956500743
Merge pull request #10996 from cdoern/untilLog
Implemented --until flag for Libpod's Container Logs
2021-07-24 05:56:18 -04:00
OpenShift Merge Robot c44c298ae7
Merge pull request #11018 from vrothberg/fix-10994
import: write stdin to tmp file
2021-07-24 05:53:16 -04:00
Valentin Rothberg dcb5c92c0d import: write stdin to tmp file
If importing an archive via stdin write it to a temporary file such that
the temporary file can be opened multiple times later on.  Otherwise, we
may end up with an empty image.

Also fix a bug in the URL parsing code; we need to check whether there's
actually a scheme.

Add system tests for `podman import` exercising the basics.

Fixes: #10994
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-23 10:21:37 +02:00
Ed Santiago 8f9d33b7f7 Networking test: fix silent breakage
Wow did I screw up. #10982 introduced (at my suggestion) a
new wait_for_port() helper, with the goal of eliminating a
race condition. It didn't work.

First: wait_for_port() tests by connecting to the port, which
is a Bad Idea when you have a one-shot server that exits upon
the first connection closing. We should've caught that, but:

Second: I wrote wait_for_port() for a non-BATS test framework,
and used the conventional file descriptor 3. BATS uses fd3
for internal control. Overriding that made the test silently
just disappear, no "not ok" message, no warnings, nothing
except vanishing into the ether.

Third: this was caught by my log-colorizer script, which
loudly yelled "WARNING: expected 234" (tests) at the
bottom of the log. Unfortunately, since this wasn't
my PR, I didn't actually look at the test logs.

Solution: we can't use wait_for_port() in the network port
test. Use wait_for_output() instead, triggering on the
'listening' message emitted by netcat in the container.

Also: fix wait_for_port() to use fd5 instead of 3. Although
no code currently uses wait_for_port() as of this PR, it's
a useful helper that we may want to keep.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-07-22 18:27:13 -06:00
cdoern 0f708efd8b Implemented --until flag for libpod's container logs
compat containers/logs was missing actual usage of until query param.
This led me to implement the until param for libpod's container logs as well. Added e2e tests.

Signed-off-by: cdoern <cdoern@redhat.com>
2021-07-22 10:56:56 -04:00
Daniel J Walsh 3e79296a81
Support DeviceCgroupRules to actually get added.
Fixes: https://github.com/containers/podman/issues/10302

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-07-21 16:10:09 -04:00
Matthew Heon 4376f14c30 Ensure journald events tests only run where supported
We don't support the journald events backend on RHEL8, for
example. So we can't unconditionally run these tests.

Partial fix for RHBZ1955166

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-07-21 11:23:01 -04:00
Ed Santiago 313c7118ea system tests: cleaner, safer use of systemd
First and foremost: use ephemeral (/run, $XDG) directories
for systemd unit files, so as not to vandalize a working system.

Second, refactor common systemd-related functionality into
a new helper file, loaded by the systemd-related tests.
Shared functionality includes:

  * setting $XDG_RUNTIME_DIR if unset and rootless
  * setting $UNIT_DIR for use by tests
  * new systemctl() and journalctl() functions, which
    include "--user" when rootless (why can't systemd
    figure this out on its own?)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-07-20 08:57:26 -06:00
Ed Santiago 2b98a226b9 system test: auto-update: multiarch fixes
auto-update test is failing on non-x86_64 arch:

   https://gitlab.com/cki-project/kernel-tests/-/issues/614#note_630010734

Reason: test was relying on alpine_nginx image; this is
a custom libpod image that only has a x86_64 version.

Solution: use busybox instead. Busybox was copied from
docker.io using skopeo copy --all, so it has all arches.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-07-20 07:10:14 -06:00
Ed Santiago caf03fd7a4 system test: auto-update: allow running as rootless
They were being skipped for no clear reason.

Also: use --files and --name option in generate-systemd. Before,
output went to stdout, resulting in completely unreadable logs
on test failure.

Also: use volatile systemd directories (/run, $XDG_RUNTIME_DIR)
instead of permanent ones. Thanks to @Luap99 for the reference.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-07-20 07:10:14 -06:00
Chris Evich 80e807a191
Flake Fix: Wait before connecting container port
It was observed during periodic testing, this test can fail due to the
container process being not fully running and listening on the expected
port:

```
[+1069s] not ok 220 podman networking: port with --userns=keep-id
[+1069s] # (in test file test/system/500-networking.bats, line 144)
[+1069s] #   `echo "$teststring" | nc 127.0.0.1 $myport' failed
[+1069s] # # /var/tmp/go/src/github.com/containers/podman/bin/podman rm
--all --force
[+1069s] # # /var/tmp/go/src/github.com/containers/podman/bin/podman ps
--all --external --format {{.ID}} {{.Names}}
[+1069s] # # /var/tmp/go/src/github.com/containers/podman/bin/podman
images --all --format {{.Repository}}:{{.Tag}} {{.ID}}
[+1069s] # quay.io/libpod/testimage:20210610 9f9ec7f2fdef
[+1069s] # # /var/tmp/go/src/github.com/containers/podman/bin/podman run
-d --userns=keep-id -p 127.0.0.1:54322:54322
quay.io/libpod/testimage:20210610 nc -l -n -v -p 54322
[+1069s] #
252c562c9a3c96892d867d1d72fb52b2efdfe62855ebedbccd2d281c472c2988
[+1069s] # Ncat: No route to host.
```

Fix this by using a new `wait_for_port()` function (thanks @edsantiago)
before attempting to communicate with the service.

Signed-off-by: Chris Evich <cevich@redhat.com>
2021-07-19 15:36:13 -04:00
Valentin Rothberg 6f1c7a0b6b systemd: require network*-online*.target
Require the network to be online in all (generated) systemd units to
make sure that containers and Podman run only after the network has been
fully configured.

Fixes: #10655
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-16 14:58:08 +02:00
OpenShift Merge Robot ce28dc3c4c
Merge pull request #10820 from jvanz/indfra-container-name-issue-10794
--infra-name command line argument
2021-07-16 07:53:43 -04:00
José Guilherme Vanz af40dfc2bf
--infra-name command line argument
Adds the new --infra-name command line argument allowing users to define
the name of the infra container

Issue #10794

Signed-off-by: José Guilherme Vanz <jvanz@jvanz.com>
2021-07-15 21:27:51 -03:00
Ed Santiago e4dcb1004f System tests: fix a multiarch problem
The multi-image load test was failing on non-x86_64 arch,
because the images used by the test (:00000000, :20200902)
did not have manifests for the given arch.

Solution: all we need are two nonlocal images. Use the
predefined NONLOCAL_IMAGE for one, and a new :multiimage
tag (manually created, currently == :20210610) for the other.
Document, so if/when RHEL adds new supported arches, the
test will fail but a maintainer will have a clue what to do.

Also, as long as I'm in here: add 'image prune -f' to teardown
in build.bats, to avoid seeing lots of red "stray image"
warnings in test logs.

Also: skip a broken/flaky python test

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-07-15 11:29:58 -06:00
OpenShift Merge Robot 5d6a366017
Merge pull request #10937 from vrothberg/auto-update
auto-update: add --dry-run
2021-07-15 10:50:13 -04:00
Valentin Rothberg 59f31d86ac auto-update: add --dry-run
Add a --dry-run flag to `podman auto-update` which will look for new
images but won't perform any pull or restart any service or container.

The "UPDATED" column will now indicate the availability of a newer image
via "pending".

```
$ podman auto-update --dry-run
UNIT                    CONTAINER            IMAGE                   POLICY      UPDATED
container-test.service  08fd34e533fd (test)  localhost:5000/busybox  registry    false
```

Fixes: #9949
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-15 11:39:50 +02:00
Daniel J Walsh c9970647ba
podman-remote build use .containerignore over .dockerignore
$ mkdir zzz;cd zzz
$ printf "FROM quay.io/libpod/testimage:20210610\nCOPY ./ ./\nCOPY subdir ./\n" >Dockerfile
$ printf "*\nsubdir\n\!*/sub1*\n" >.dockerignore
$ mkdir subdir; touch subdir/sub1.txt
$ ../bin/podman-remote build .

Should fail, but succeeds because we are not sending over the
.dockerignore file to the server side.  This PR will send the
.dockerignore so the server side and use it.

Fixes: #10907

Also if both .containerignore and .dockerignore in the context
directory, podman-remote should prefer .containerignore and not use
.dockerignore.

Fixes: #10908

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-07-14 20:22:51 -04:00
OpenShift Merge Robot ce4c23c4af
Merge pull request #10880 from vrothberg/auto-update
auto-update: make output more user friendly
2021-07-14 15:26:01 -04:00
OpenShift Merge Robot ace19c75ad
Merge pull request #10916 from mheon/fix_7360
Perform a one-sided close of HTTP attach conn on EOF
2021-07-14 13:39:58 -04:00
Valentin Rothberg 01cfb51fe9 auto-update: make output more user friendly
The rather raw and scarce output of `podman auto-update` has been a
thorn in my eyes for a longer while.  So far, Podman would only print
updated systemd units, one per line, without further formatting.

Motivated by issue #9949 which is asking for some more useful
information in combination with a dry-run feature, I sat down and
reflected which information may come in handy.

Running `podman auto-update` will now look as follows:

```
$ podman auto-update
Trying to pull [...]

UNIT                    CONTAINER            IMAGE                   POLICY      UPDATED
container-test.service  08fd34e533fd (test)  localhost:5000/busybox  registry    false
```

Also refactor the spaghetti code in the backend a bit to make it easier
to digest and maintain.

For easier testing and for the sake of consistency with other commands
listing output, add a `--format` flag.

The man page will get an overhaul in a follow up commit.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-14 16:23:51 +02:00
Matthew Heon cbbb1a80f5 Perform a one-sided close of HTTP attach conn on EOF
On EOF of STDIN, we need to perform a one-sided close of the
attach connection on the client side, to ensure that STDIN
finishing will also cause the exec session to terminate, instead
of hang.

Fixes #7360

Signed-off-by: Matthew Heon <mheon@redhat.com>
2021-07-13 16:26:53 -04:00
Valentin Rothberg db26e1ef94 auto-update: make restarted unit more obvious
The output of auto-update leaves quite some space for improvements.  One
thing is to make it more obvious which systemd units were restarted.

With this change, the output looks as follows:
```
$ podman auto-update
Trying to pull...

Restarted the following systemd units:
$unit-1
$unit-2
$unit-3
```

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-07-13 13:52:46 +02:00
Daniel J Walsh 48ff2ef5a3
Don't exclude Dockerfile, Containerfiles from tar content
If the user specifies "*" in a .dockerignore or a .containerignore
then podman-remote build should not exclude the Dockerfile or
Containerfile or any content pointed to by `-f` in the context
directory.

We still need these files on the server side to complete the build.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-07-10 06:47:59 -04:00
Matej Vasek 86c6014145 Implement --archive flag for podman cp
Signed-off-by: Matej Vasek <mvasek@redhat.com>
2021-07-01 12:01:46 +02:00
Daniel J Walsh 092902b455
Handle advanced --network options in podman play kube
Since Podman create/run can support this, so should play.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-30 13:32:27 -04:00
Daniel J Walsh 05f39af5bd
Bump github.com/containers/storage from 1.32.3 to 1.32.5
Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.32.3 to 1.32.5.
- [Release notes](https://github.com/containers/storage/releases)
- [Changelog](https://github.com/containers/storage/blob/main/docs/containers-storage-changes.md)
- [Commits](https://github.com/containers/storage/compare/v1.32.3...v1.32.5)

---
updated-dependencies:
- dependency-name: github.com/containers/storage
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-06-29 15:58:32 -04:00
Valentin Rothberg b1082696eb cp: do not allow dir->file copying
Fix a bug in `podman-cp` to forbid copying directories to files.
Previously, the directory was copied to the parent directory of the file
which is wrong.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-06-24 13:53:36 +02:00
OpenShift Merge Robot 7ed18eaec6
Merge pull request #10739 from vrothberg/fix-10682
create: support images with invalid platform
2021-06-23 13:05:31 -04:00
Valentin Rothberg 5fc622f945 create: support images with invalid platform
Much to my regret, there is a number of images in the wild with invalid
platforms breaking the platform checks in libimage that want to make
sure that a local image is matching the expected platform.

Imagine a `podman run --arch=arm64 fedora` with a local amd64 fedora
image.  We really shouldn't use the local one in this case and pull down
the arm64 one.

The strict platform checks in libimage in combination with invalid
platforms in images surfaced in Podman being able to pull an image but
failing to look it up in subsequent presence checks.  A `podman run`
would hence pull such an image but fail to create the container.

Support images with invalid platforms by vendoring the latest HEAD from
containers/common.  Also remove the partially implemented pull-policy
logic from Podman and let libimage handle that entirely.  However,
whenever --arch, --os or --platform are specified, the pull policy will
be forced to "newer".  This way, we pessimistically assume that the
local image has an invalid platform and we reach out to the registry.
If there's a newer image (i.e., one with a different digest), we'll pull
it down.

Please note that most of the logic has either already been implemented
in libimage or been moved down which allows for removing some clutter
from Podman.

[NO TESTS NEEDED] since c/common has new tests.  Podman can rely on the
existing tests.

Fixes: #10648
Fixes: #10682
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-06-23 15:42:13 +02:00
Valentin Rothberg d12027e0d0 disable tty-size exec checks in system tests
As discussed in #10710, the additional checks for podman-exec added by
commit 666f555aa5 are extremely flaky and appear in nearly every PR
I have see this week.

Let's temporarily disable the checks and reenable them on #10710 is
fixed.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-06-23 10:10:19 +02:00