Commit graph

616 commits

Author SHA1 Message Date
OpenShift Merge Robot 8f3fb743ee
Merge pull request #12270 from rhatdan/auth
--authfile command line argument for image sign command.
2021-11-13 13:10:48 +01:00
Valentin Rothberg f517510bc8 play kube: don't force-pull infra image
Do not force-pull the infra image in `play kube` but let the backend
take care of that when creating the pod(s) which may build a local
`podman-pause` image instead of using the default infra image.

Fixes: #12254
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-12 13:44:13 +01:00
José Guilherme Vanz 6762d5e238
--authfile command line argument for image sign command.
Adds the --authfile command line argument to allow users to use
alternative authfile paths when signing images.

Replaces: https://github.com/containers/podman/pull/10975
Fixes: https://github.com/containers/podman/issues/10866

Signed-off-by: José Guilherme Vanz <jvanz@jvanz.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-11-11 15:11:19 -05:00
OpenShift Merge Robot fa8184c807
Merge pull request #12240 from umohnani8/table
Print headers for system connection ls
2021-11-10 23:29:36 +01:00
Paul Holzinger 27de152b5a
network reload without ports should not reload ports
When run as rootless the podman network reload command tries to reload
the rootlessport ports because the childIP could have changed.
However if the containers has no ports we should skip this instead of
printing a warning.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-11-10 21:16:08 +01:00
Urvashi Mohnani a55fdbb49c Print headers for system connection ls
Print out the headers even if the system connection list
is empty to match the behavior of other list commands.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2021-11-10 14:48:08 -05:00
OpenShift Merge Robot 4bf0146c29
Merge pull request #12255 from vrothberg/fix-11970
podman load: support downloading files
2021-11-10 18:27:39 +01:00
Valentin Rothberg 1ef66d6d7f podman load: support downloading files
Support downloading files, for instance via
`podman load -i server.com/image.tar`.  The specified URL is downloaded
in the frontend and stored as a temp file that gets passed down to the
backend.

Also vendor in c/common@main to use the new `pkg/download`.

Fixes: #11970
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-10 15:43:16 +01:00
Valentin Rothberg df06664363 pod create: read infra image from containers.conf
Fix a bug where pods would be created with the hard-coded default infra
image instead of the custom one from containers.conf.  Add a simple
regression test.

Fixes: #12245
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-11-10 12:59:42 +01:00
OpenShift Merge Robot 5437568fcd
Merge pull request #12227 from Luap99/net-setup
Fix rootless networking with userns and ports
2021-11-09 21:11:30 +01:00
Paul Holzinger 216e2cb366
Fix rootless networking with userns and ports
A rootless container created with a custom userns and forwarded ports
did not work. I refactored the network setup to make the setup logic
more clear.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-11-09 15:58:57 +01:00
Boaz Shuster 6ee3b33d38 change from run to create in 250-systemd.bats
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2021-11-09 11:54:18 +02:00
Ed Santiago 2ed31f9f1d Minor test tweaks
- remove 'NO TESTS NEEDED' as a valid bypass string. Henceforth
  only 'NO NEW TESTS NEEDED' will work.

- add a debugging aid for #11871, in which bodhi tests time out
  in nslookup.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-08 14:23:55 -07:00
OpenShift Merge Robot abfec8144a
Merge pull request #11953 from markusthoemmes/help-default
Display help text on empty subcommand by default
2021-11-08 18:23:17 +01:00
Aditya Rajan 338eb9d75e
system: Adds support for removing all named destination via --all
Adds support of dropping all named destination from system connections via `--all`.

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

Signed-off-by: Aditya Rajan <arajan@redhat.com>
2021-11-08 19:42:45 +05:30
Markus Thömmes 756dda298c Keep error semantics intact
Signed-off-by: Markus Thömmes <markusthoemmes@me.com>
2021-11-05 09:34:22 +01:00
OpenShift Merge Robot 82dba97547
Merge pull request #12158 from edsantiago/more_bats
System tests: enhance volume test, add debug prints
2021-11-02 18:51:24 +01:00
OpenShift Merge Robot 0686f0bb2f
Merge pull request #12118 from hshiina/log-f-journald
Set flags to test 'logs -f' with journald driver
2021-11-02 13:18:26 +01:00
Ed Santiago 7b2531c135 System tests: enhance volume test, add debug prints
Volume test: add a sequence of stat()s to confirm that volumes
are mounted as a different device than root.

Network test: add debugging code for #11825 (dnsmasq inotify
failure in bodhi only).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-11-01 13:03:05 -06:00
Boaz Shuster 7494876000 Use systemctl in local system test
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2021-10-29 09:37:15 +03:00
Valentin Rothberg c5f0a5d788 volumes: be more tolerant and fix infinite loop
Make Podman more tolerant when parsing image volumes during container
creation and further fix an infinite loop when checking them.

Consider `VOLUME ['/etc/foo', '/etc/bar']` in a Containerfile.  While
it looks correct to the human eye, the single quotes are wrong and yield
the two volumes to be `[/etc/foo,` and `/etc/bar]` in Podman and Docker.

When running the container, it'll create a directory `bar]` in `/etc`
and a directory `[` in `/` with two subdirectories `etc/foo,`.  This
behavior is surprising to me but how Docker behaves.  We may improve on
that in the future.  Note that the correct way to syntax for volumes in
a Containerfile is `VOLUME /A /B /C` or `VOLUME ["/A", "/B", "/C"]`;
single quotes are not supported.

This change restores this behavior without breaking container creation
or ending up in an infinite loop.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2014149
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-10-28 16:37:33 +02:00
Hironori Shiina e68fbf03aa Set flags to test 'logs -f' with journald driver
`logs -f` with `journald` is supported only when `journald` events
backend is used. To pass system tests using `logs -f` in an environment
where `events_logger` is not set to `journald` in `containers.conf`,
this fix sets `--events-backend` or `--log-driver` temporally.

Signed-off-by: Hironori Shiina <shiina.hironori@jp.fujitsu.com>
2021-10-27 10:28:16 -04:00
Valentin Rothberg 75f478c08b pod create: remove need for pause image
So far, the infra containers of pods required pulling down an image
rendering pods not usable in disconnected environments.  Instead, build
an image locally which uses local pause binary.

Fixes: #10354
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-10-26 13:51:45 +02:00
Boaz Shuster ece0c7e5d3 Support template unit files in podman generate systemd
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2021-10-22 04:19:18 +03:00
OpenShift Merge Robot 6338e74cc9
Merge pull request #12028 from edsantiago/test_system_connection
Add test for system connection
2021-10-21 13:44:28 +00:00
Ed Santiago 70a5d8cd1d System tests: confirm that -a and -l clash
...and fix one instance where there was no check

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-10-20 11:09:32 -06:00
OpenShift Merge Robot 2c6c801067
Merge pull request #12041 from edsantiago/container_env
system tests: CONTAINER_* and --help: cleanup
2021-10-20 08:40:10 +00:00
Ed Santiago 960a55c09d system tests: CONTAINER_* and --help: cleanup
A small part of this test was written in a confusing and fragile
way: it was very hard to understand, and in fact only worked
through pure luck (using 'echo $output', which emitted everything
in one long line, vs the standard quoted 'echo "$output"' which
would've kept the formatting and caused the test to pass,
incorrectly, no matter whether --remote was in the output
or not). Plus, the '$?' check in the next line would never
trigger on failure anyway, so the failure message would've
been unhelpful if the test were ever to fail.

Anyhow. Make it readable and make it work.

(Followup to #11990)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-10-19 14:22:50 -06:00
Daniel J Walsh 20b5a8599b
podman run --memory=0 ... should not set memory limit
On Docker this is ignored, and it should be on Podman as
well. This is documented in the man page.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-19 14:06:33 -04:00
Ed Santiago d24ce0a33f Add test for system connection
First a basic (connectionless) one to make sure we 'add', 'ls',
and 'rm' work; then an actual one with a service; then (if
ssh to localhost is set up and works) test ssh

Requires a little trickery to work around the CI definition
of $PODMAN, which includes "--url /path/to/sock", which
overrides podman's detection of whether to use a connection
or not.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-10-19 09:18:51 -06:00
OpenShift Merge Robot e0ffc431fe
Merge pull request #11959 from rhatdan/selinux
We should only be relabeling when on first run
2021-10-18 19:53:46 +02:00
Ed Santiago c8cffe1b35 system tests: socket activation: clean up
Multiarch folks are seeing flakes in this test. I can't reproduce
them, but I did notice that the test isn't doing the best possible
job of reporting failures nor of confirming what it purports to test.

Major fix here is to check the exit status of each curl: if we
see the flake again, that will help us track down the failure.

Other fixes are just refactoring, cleanup, and disambiguation
(using the random service name consistently)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-10-18 08:47:15 -06:00
Daniel J Walsh 468e7c689b
Move CONTAINER_HOST and _CONNECTION to IsRemote Function
Current code does not check early enough.

Follow up to https://github.com/containers/podman/pull/11978

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-15 14:40:02 -04:00
Daniel J Walsh 207abc4a9a
We should only be relabeling when on first run
On the second runs, the labels should be the same so no
need to relabel.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2013548

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-15 14:27:14 -04:00
Daniel J Walsh 4f857bc106
If CONTAINER_HOST env variable is set default podman --remote=true
Users enabling CONTAINER_HOST==PATH is indicating to podman they intend
to use remote functionality.

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

Update man pages to document all of the environment variables.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-14 17:08:48 -04:00
Markus Thömmes 184de3955c Adjust tests to verify all subcommands show the help message
Signed-off-by: Markus Thömmes <markusthoemmes@me.com>
2021-10-14 13:54:52 +02:00
Daniel J Walsh 8600bce53a
codespell code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-12 16:44:25 -04:00
Daniel J Walsh 7580c22734
Remove a volume with --force if container is running
Currently we are not passing the force flag down to the removal of
the running container. If the container is running, and we set
--force when removing the volume, the container should be stopped.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-11 15:02:04 -04:00
OpenShift Merge Robot 60c711f789
Merge pull request #11869 from jwhonce/wip/pprof
Enable /debug/pprof API service endpoints
2021-10-10 12:54:29 +02:00
Jhon Honce 8d3aec9d08 Enable /debug/pprof API service endpoints
* Refactor sidecar HTTP service for /debug/pprof endpoints to use a TCP
  address given via new podman system service --pprof-address flag

* Allow same URL parsing in "system service" as bindings/connection.go

* Refactor NewServerWithSettings() to use entities.ServiceOptions
  in place of deleted server.Options

* Updated godoc for impacted functions and types

* Fixed API service Shutdown() to do an orderly shutdown when
  terminated and running with --time=0

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2021-10-08 13:57:20 -07:00
Daniel J Walsh 48d26a893e
Warn if podman stop timeout expires that sigkill was sent
Note: the Warning message will not come to podman-remote.
It would be difficult to plumb, and not really worth the effort.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-08 07:06:37 -04:00
Paul Holzinger fbce7584d7
libpod: fix race when closing STDIN
There is a race where `conn.Close()` was called before `conn.CloseWrite()`.
In this case `CloseWrite` will fail and an useless error is printed. To
fix this we move the the `CloseWrite()` call to the same goroutine to
remove the race. This ensures that `CloseWrite()` is called before
`Close()` and never afterwards.
Also fixed podman-remote run where the STDIN was never was closed.
This is causing flakes in CI testing.

[NO TESTS NEEDED]

Fixes #11856

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-10-06 17:51:07 +02:00
Daniel J Walsh 21c9dc3c40
Add --time out for podman * rm -f commands
Add --time flag to podman container rm
Add --time flag to podman pod rm
Add --time flag to podman volume rm
Add --time flag to podman network rm

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-10-04 07:07:56 -04:00
Ed Santiago fb2355adb3 Gating tests: fix permissions error
...in volume test. Looks like Bodhi gating tests run from a
nonwritable directory. I feel really stupid for not realizing
this when I first tried to fix this bug two weeks ago.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-10-01 05:36:12 -06:00
OpenShift Merge Robot 317e20a8d5
Merge pull request #11776 from edsantiago/bats_is_cleanup
System tests: tighten 'is' operator
2021-10-01 03:36:11 -04:00
Ed Santiago bf94ebf423 System tests: tighten 'is' operator
Fix day-one sloppiness: when I first wrote this framework
it compared strings using 'expr', not '=', to be more
forgiving of extra cruft in output. This was a bad decision.
It means that warnings or additional text are ignored:

    is "all is ok, NOT!"  "all is ok"  <-- this would pass

Solution: tighten up the 'is' check. Use '=' (direct
compare) first. If it fails, look for wild cards ('*')
or character classes ('[') in the expect string. If
so, and only then, use 'expr'. And, thanks to a clever
suggestion from Luap99, include '(using expr)' in the
error message when we do so; this could make it easier
for a developer to understand a string mismatch.

This change exposes a lot of instances in which we weren't
doing proper comparisons. Fix those. Thankfully, there
weren't as many as I'd feared.

Also, and completely unrelated, add '-T' flag to bats
helper, for showing timing results. (I will open this
as a separate PR if requested. I too find it offensive
to jumble together unrelated commits.)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-30 13:32:51 -06:00
Ed Santiago cc42321697 sdnotify test: accept MAINPID anywhere
systemd sometimes spits out lines in the wrong order. Deal with it.

This fixes an infrequent flake that I haven't filed because I
didn't understand it well enough. (Hence, this reduces BUGS
but does not reduce BUG COUNT. Sorry!)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-30 12:09:48 -06:00
Giuseppe Scrivano 5c1b3e8d72
test: use new helper
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-30 13:59:46 +02:00
Giuseppe Scrivano 788106dad1
test: skip test on rootless cgroupsv1
skip the test "podman selinux: shared context in (some) namespaces" on
cgroupsv1 when running as rootless since the tests requires
--pid=container:.

If the container runtime cannot use cgroupsv1 and the container has no
pid namespace. then it is not possible to correctly terminate the
container.  Without a cgroup or a pid namespace, the runtime has no
control on what processes are in the container.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2021-09-30 13:58:47 +02:00
OpenShift Merge Robot 2d22d17066
Merge pull request #11751 from Luap99/net-alias
always add short container id as net alias
2021-09-28 10:03:17 -04:00
OpenShift Merge Robot 7a748f028c
Merge pull request #11762 from edsantiago/bats
System tests: speed up. They've gotten too slow.
2021-09-28 09:02:14 -04:00
Paul Holzinger 05614ee139
always add short container id as net alias
This matches what docker does. Also make sure the net aliases are also
shown when the container is stopped.

docker-compose uses this special alias entry to check if it is already
correctly connected to the network. [1]
Because we do not support static ips on network connect at the moment
calling disconnect && connect will loose the static ip.

Fixes #11748

[1] 0bea52b18d/compose/service.py (L663-L667)

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-28 13:40:22 +02:00
Valentin Rothberg a9a54eefab image prune: support removing external containers
Support removing external containers (e.g., build containers) during
image prune.

Fixes: #11472
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-28 10:24:16 +02:00
Ed Santiago 86083c580b System tests: speed up. They've gotten too slow.
- logs: remove unnecessary sleeps. This saves ~25s.
   Unfortunately, journald seems to have some sort of lag,
   so we need to keep retrying until we get the 'after' string.

 - ps: add placeholder test for once buildah 3544 is fixed

 - cp: bulk-kill containers when finished, instead of one by one.
   This is a big change and only saves about 8s per run, but hey.

 - mount,pause,healthcheck: 'podman stop -t 0' before rm'ing containers.
   Easy 50s.
   Have I mentioned, lately, that 'podman rm -f' needs a '-t 0' flag?

 - play: same, and also 'podman pod stop'. Seems to shave ~20s.

 - socket-activation: UGH! Buggy and useless tests! They were
   running "sleep 90" containers for no reason whatsoever. I
   assume the intention was to run them with "-d", so that's
   what I've done here. Also fixed some language. 180 seconds!

(Unrelated: cleanup in 070-build, use $IMAGE, not alpine)

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-27 20:06:18 -06:00
OpenShift Merge Robot 899d5d7d7c
Merge pull request #11755 from nalind/remote-build-eval-contextdir
remote build: EvalSymlinks() the context directory
2021-09-27 11:12:57 -04:00
Nalin Dahyabhai 464fec260c remote build: EvalSymlinks() the context directory
Use EvalSymlinks() to find the context directory, in case there's
shenanigans.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-09-27 09:27:06 -04:00
Daniel J Walsh 5a2ca77b9b Vendor in containers/common v0.46.0
Fixes: https://github.com/containers/podman/issues/11745

[NO TESTS NEEDED] Since this is just a revendor and a one line
change for the revendor

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-27 11:30:09 +02:00
OpenShift Merge Robot e8fc990aad
Merge pull request #11654 from Luap99/health-docker
podman inspect add State.Health field for docker compat
2021-09-23 11:34:42 -04:00
Paul Holzinger b6e5a4909a
shell completion: do not show images without tag
The shell completion should only suggest arguments that work. Using a
image without tag does not work in many cases. Having both the version
with and without tag also forces users to press one key more because
tab completion will always stop at the colon.

Fixes #11673

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-23 15:15:35 +02:00
Paul Holzinger 1199733754
podman inspect add State.Health field for docker compat
podman inspect shows the healthcheck status in `.State.Healthcheck`,
docker uses `.State.Health`. To make sure docker scripts work we
should add the `Health` key. Because we do not want to display both keys
by default we only use the new `Health` key. This is a breaking change
for podman users but matches what docker does. To provide some form of
compatibility users can still use `--format {{.State.Healthcheck}}`. IT
is just not shown by default.

Fixes #11645

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-23 14:44:34 +02:00
Valentin Rothberg 49c5688a30 podman save: add --uncompressed
Add an option to `podman save` to allow uncompressed layers when
copying OCI images.  Do the neccessary plumbing for the remote client,
add tests and vendor in the latest commit from c/common to fetch
the neccessary changes in libimage.

Closes: #11613
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-22 12:38:07 +02:00
Valentin Rothberg 92ee2f372b remote untag: support digests
Fix a bug when remotely untagging an image via tag@digest.
The digest has been lost in the remote client and hence led
to a wrong behaviour on the server.

Fixes: #11557
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-20 15:06:37 +02:00
Ed Santiago 22df773f77 System tests: cleanup, and remove obsolete skips
* 070-build:
  - remove workaround for #9567, which is closed.
  - add many more cases to the ignorefile test,
    to test complicated special cases of Buildah PR 3486.

* 160-volumes:
  - remove a skip_if_remote, volumes now work on remote
  - use a random name for tarball, and clean up when
    done using it. This fixes a gating-test failure
    (test runs as root, then rootless, and rootless
    can't clobber root's file).

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-17 14:29:18 -06:00
Daniel J Walsh 4216f7b7f4
Add no-trunc support to podman-events
Standardize on no-trunc through the code.
Alias notruncate where necessary.

Standardize on the man page display of no-trunc.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-16 09:41:29 -04:00
Paul Holzinger 85e8fbf7f3
Wire network interface into libpod
Make use of the new network interface in libpod.

This commit contains several breaking changes:
- podman network create only outputs the new network name and not file
  path.
- podman network ls shows the network driver instead of the cni version
  and plugins.
- podman network inspect outputs the new network struct and not the cni
  conflist.
- The bindings and libpod api endpoints have been changed to use the new
  network structure.

The container network status is stored in a new field in the state. The
status should be received with the new `c.getNetworkStatus`. This will
migrate the old status to the new format. Therefore old containers should
contine to work correctly in all cases even when network connect/
disconnect is used.

New features:
- podman network reload keeps the ip and mac for more than one network.
- podman container restore keeps the ip and mac for more than one
  network.
- The network create compat endpoint can now use more than one ipam
  config.

The man pages and the swagger doc are updated to reflect the latest
changes.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-15 20:00:20 +02:00
Aditya Rajan 962675c148 build.bats: fix copy tests after containers/buildah#3486
Fix copy tests after https://github.com/containers/buildah/pull/3486

[NO TESTS NEEDED]

Signed-off-by: Aditya Rajan <arajan@gmail.com>
2021-09-15 15:12:38 +05:30
Paul Holzinger 6221f269a8
fix restart always with rootlessport
When a container is automatically restarted due its restart policy and
the container uses rootless cni networking with ports forwarded we have
to start a new rootlessport process since it exits with conmon.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-13 22:52:39 +02:00
Daniel J Walsh 4fbc5b8fe7
Stop outputting 'healthy' on healthcheck
We should only print unhealthy if the check fails.  Currently this is
filling logs when users are running lots of healthchecks.

Improves: https://github.com/containers/podman/issues/11157

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-10 11:20:01 -04:00
OpenShift Merge Robot 63f6656f8f
Merge pull request #11426 from fj-tsubasa/system-test-scenario
Add a system test to modify and import an exported container
2021-09-09 16:11:22 -04:00
Tsubasa Watanabe 4ccb4f81f7 Add a system test to modify and import an exported container.
This test has completed one of TODO items in test/system/TODO.md.
The item is "Implied pull, build, export, modify, import, tag, run, kill"

Signed-off-by: Tsubasa Watanabe <w.tsubasa@fujitsu.com>
2021-09-10 02:47:57 +09:00
Paul Holzinger 7cf22279d9
Fix conmon attach socket buffer size
The conmon buffer size is 8192, however the attach socket needs two extra
bytes. The first byte of each message will be the STREAM type. The last
byte is a null byte. So when we want to read 8192 message bytes we need
to read 8193 bytes since the first one is special.
check 1ef246896b/src/ctr_stdio.c (L101-L107)

This problem can be seen in podman-remote run/exec when it prints output
with 8192 or more bytes. The output will miss the 8192 byte.

Fixes #11496

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-09 17:57:42 +02:00
Daniel J Walsh 2f967b81cb
Add logDriver to podman info
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-08 17:53:04 -04:00
Ed Santiago 1ff797e362 system tests: new random_free_port helper
Picks a pseudorandom open port within a range. Refactor existing
instances of such code.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-08 11:25:42 -06:00
OpenShift Merge Robot 558ba1b99e
Merge pull request #11468 from Luap99/play-kube-slirp
fix play kube --network options
2021-09-08 13:55:21 +02:00
Paul Holzinger f18ccbcc0f
fix play kube --network options
Commit 092902b455 introduced advanced network options for podman play
kube. However this never worked because it unconditionally set the
network mode to bridge after it parsed the network option.

Added a test to ensure the correct mode is set.

Truly fixes #10807

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-09-08 10:09:28 +02:00
Nalin Dahyabhai 748c2700b4 pkg/bindings/images.nTar(): set ownership of build context to 0:0
When attempting to run remote builds, users with UID/GID values that
were high enough that they wouldn't be mapped into their default user
namespace configurations would see their builds fail when the server
attempted to extract the build contexts that they supplied, and failed
to set ownership of the build context content to the UID/GID that were
originally assigned to them.

When archiving the build context at the client, set ownership of
everything to 0:0, which we know is always mapped.  Both ADD and COPY
require that we set the ownership of newly-added content to 0:0 (unless
the --chown flag is used), so throwing away the original ownership
information doesn't hurt, anyway.  As usual, tarballs that we extract
as part of ADD aren't going to be affected.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-09-07 15:29:33 -04:00
OpenShift Merge Robot 8a55363b80
Merge pull request #11459 from vrothberg/fix-11438
generate systemd: handle --restart
2021-09-07 15:51:41 +02:00
Valentin Rothberg d1573b95e3 generate systemd: handle --restart
Handle custom restart policies of containers when generating the unit
files; those should be set on the unit level and removed from ExecStart
flags.

Fixes: #11438
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-07 13:58:11 +02:00
Valentin Rothberg 1eaa449590 logs -f: file: fix dead lock
Fix a dead lock in the file log driver where one goroutine would wait on
the tail to hit EOF but reading is blocked for the function to return.

Fixes: 11461
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-09-07 12:46:56 +02:00
Ed Santiago 02a0d4b7fb auto-update systemd test: skip on RHEL
The "auto-update using systemd" test is failing on RHEL rootless.

Reason: it uses journalctl, which does not work on RHEL rootless.

Solution: add skip_if_journald_unavailable.

ALSO: add debugging info to test failure.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-02 12:28:51 -06:00
Ed Santiago e3c7e02a0e System tests: add cleanup & debugging output
Cleanup: the final 'play' test wasn't cleaning up after itself,
leading to angry warning messages when rerunning tests (in
my environment; never in CI)

Debug: I'm seeing a lot of "Could not parse READY=1 as MAINPID=nnn"
flakes in the sdnotify:container test (nine in the past month). Add
debug traces to help diagnose in future flakes.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2021-09-01 11:29:59 -06:00
Valentin Rothberg 10144b707e pass LISTEN_* environment into container
Make sure that Podman passes the LISTEN_* environment into containers.
Similar to runc, LISTEN_PID is set to 1.

Also remove conditionally passing the LISTEN_FDS as extra files.
The condition was wrong (inverted) and introduced to fix #3572 which
related to running under varlink which has been dropped entirely
with Podman 3.0.  Note that the NOTIFY_SOCKET and LISTEN_* variables
are cleared when running `system service`.

Fixes: #10443
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-08-31 17:23:05 +02:00
Valentin Rothberg de3920c0e9 auto-update: fix authfile label
Make sure that the container's authfile label is used when pulling down
a new image.

[NO TESTS NEEDED] since it would require some larger rewrite of the
auto-update system tests that I currently have no time for.  I added a
reminder to have some breadcrumbs when there is more time.

Fixes: #11171
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-08-30 13:49:35 +02:00
flouthoc d5507704e9 volumes: Add volume import to allow importing contents on tar into volume
Following feature makes sure that users can load contents of external
tarball into the podman volumes.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2021-08-26 14:14:14 +05:30
OpenShift Merge Robot 23f9565547
Merge pull request #11263 from nalind/journal-read
libpod/Container.readFromJournal(): don't skip the first entry
2021-08-24 14:16:22 -04:00
Valentin Rothberg 274d6fa19c generate systemd: use --cidfile again
Commit 9ac5267 changed the type of the generated systemd units from
`forking` to `notify`.  It further stopped using `--cidfile` and instead
intended systemd to take care of stopping the container, which turned
out to be a bad idea.

Systemd will send the stop/kill signals to conmon which in turn may exit
non-zero, depending on the signal, and ultimately breaking container
cleanup.

Hence, we need to use --cidfile again and let podman stop and remove the
container to make sure that everything's in order.

Fixes: #11304
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-08-24 15:46:00 +02:00
Valentin Rothberg 74ab2aaf9f Revert "generate systemd: custom stop signal"
This reverts commit 70801b3d71.

It turns out that letting systemd handle stopping the container is not
working as I thought it will.  Conmon is receiving the stop/kill signals
and may exit non-zero, which in turn lets the systemd service transition
into the `failed` state.

We need to get back to letting Podman stop the containers and do a
partial revert of commit 9ac5267 which removed using --cidfile.

Happening in a following commit.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-08-24 13:33:06 +02:00
Valentin Rothberg 70801b3d71 generate systemd: custom stop signal
Commit 9ac5267598 changed the type of the generated systemd units from
forking to notify.  Parts of these changes was also removing the need to
pass any information via the file system (e.g., PIDFILE, container ID).
That in turn implies that systemd takes care of stopping the container.

By default, systemd first sends a SIGTERM and after a certain timeout,
it'll send a SIGKILL.  That's pretty much what Podman is doing, unless
the container was created with a custom stop signal which is the case
when the --stop-signal flag was used or systemd is mounted.

Account for that by using systemd's KillSignal option which allows for
changing SIGTERM to another signal.  Also make sure that we're using the
correct timeout for units generated with --new.

Fixes: #11304
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-08-24 10:50:16 +02:00
Nalin Dahyabhai 3007bd4a99 130-kill.bats: increase timeouts from 10s to 60s
Increase the amount of time we're willing to wait for a log message that
a container should be printing to show up in the output of `logs -f`,
since on at least one CI configuration we're seeing a turnaround as high
as 46s, but it's not something we can directly control, so that's not a
hard maximum.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-08-23 18:09:56 -04:00
Nalin Dahyabhai b20a547059 330-corrupt-images: don't try to tag with a canonical name
In these tests, don't try to tag an image using a canonical ("with
digest") image name.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-08-23 18:00:08 -04:00
Daniel J Walsh c22f3e8b4e Implement SD-NOTIFY proxy in conmon
This leverages conmon's ability to proxy the SD-NOTIFY socket.
This prevents locking caused by OCI runtime blocking, waiting for
SD-NOTIFY messages, and instead passes the messages directly up
to the host.

NOTE: Also re-enable the auto-update tests which has been disabled due
to flakiness.  With this change, Podman properly integrates into
systemd.

Fixes: #7316
Signed-off-by: Joseph Gooch <mrwizard@dok.org>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-08-20 11:12:05 +02:00
Paul Holzinger 2a8c414488
Fix rootless cni dns without systemd stub resolver
When a host uses systemd-resolved but not the resolved stub resolver the
following symlinks are created: `/etc/resolv.conf` ->
`/run/systemd/resolve/stub-resolv.conf` -> `/run/systemd/resolve/resolv.conf`.
Because the code uses filepath.EvalSymlinks we put the new resolv.conf
to `/run/systemd/resolve/resolv.conf` but the `/run/systemd/resolve/stub-resolv.conf`
link does not exists in the mount ns.
To fix this we will walk the symlinks manually until we reach the first
one under `/run` and use this for the resolv.conf file destination.

This fixes a regression which was introduced in e73d482990.

Fixes #11222

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2021-08-16 11:30:11 +02:00
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