Commit graph

8576 commits

Author SHA1 Message Date
Matthew Heon
ae2ee65eff HACK: Manually include c/storage #698
We need this release out by end of day, so we don't have time to
do this right. Disable the vendor task and manually add c/storage
PR #698 to the vendored copy of c/storage to make the tests pass.

Once #698 merges into c/storage, we need to remove this commit
and backport it to the v1.20 stable branch, then cut a release
there.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-24 15:10:53 -04:00
Matthew Heon
884355c681 Final release notes update for v2.0.5.
Really. I promise. No more after this.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-24 11:31:37 -04:00
Matthew Heon
c5723785b7 Clean up pods before returning from Pod Stop API call
This should help alleviate races where the pod is not fully
cleaned up before subsequent API calls happen.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-24 11:31:37 -04:00
Matthew Heon
484bd0af1d Ensure pod infra containers have an exit command
Most Libpod containers are made via `pkg/specgen/generate` which
includes code to generate an appropriate exit command which will
handle unmounting the container's storage, cleaning up the
container's network, etc. There is one notable exception: pod
infra containers, which are made entirely within Libpod and do
not touch pkg/specgen. As such, no cleanup process, network never
cleaned up, bad things can happen.

There is good news, though - it's not that difficult to add this,
and it's done in this PR. Generally speaking, we don't allow
passing options directly to the infra container at create time,
but we do (optionally) proxy a pre-approved set of options into
it when we create it. Add ExitCommand to these options, and set
it at time of pod creation using the same code we use to generate
exit commands for normal containers.

Fixes #7103

Signed-off-by: Matthew Heon <mheon@redhat.com>

<MH: Fixed cherry-pick conflicts>

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-24 11:31:37 -04:00
Brent Baude
23251149ab error when adding container to pod with network information
because a pod's network information is dictated by the infra container at creation, a container cannot be created with network attributes.  this has been difficult for users to understand.  we now return an error when a container is being created inside a pod and passes any of the following attributes:

* static IP (v4 and v6)
* static mac
* ports -p (i.e. -p 8080:80)
* exposed ports (i.e. 222-225)
* publish ports from image -P

Signed-off-by: Brent Baude <bbaude@redhat.com>

<MH: Fixed cherry pick conflicts and compile>

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-24 11:31:37 -04:00
OpenShift Merge Robot
c78c6b44ce
Merge pull request #7410 from rhatdan/v2.0
Vendor in containers/common v0.14.9
2020-08-24 08:59:22 -04:00
Daniel J Walsh
6505322c51
Vendor in containers/common v0.14.9
This will fix the localions of the containers.conf file
on Windows and MacOS Boxes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-23 06:41:37 -04:00
OpenShift Merge Robot
e06cb25e81
Merge pull request #7399 from rhatdan/v2.0
In podman 1.* regression on --cap-add
2020-08-21 19:22:22 +02:00
Daniel J Walsh
7ed653804c
In podman 1.* regression on --cap-add
In podman 1.0 if  you executed a command like:

podman run --user dwalsh --cap-add net_bind_service alpine nc -l 80

It would work, and the user dwalsh would get the capability,  in
podman 2.0, only root and the binding set gets the capability.

This change restores us back to the way podman 1.0 worked.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-21 10:55:22 -04:00
OpenShift Merge Robot
11372c4c4d
Merge pull request #7363 from mheon/lets_try_this_again
Lets try this again: v2.0.5 backports, round 2
2020-08-21 12:58:55 +02:00
OpenShift Merge Robot
84180d99bc
Merge pull request #7353 from rhatdan/v2.0
Cleanup handling of podman mount/unmount
2020-08-20 22:08:25 +02:00
Paul Holzinger
7fc3c25410 fix pod creation with "new:" syntax followup + allow hostname
Fixes: 4c75fe3f70 ("fix pod creation with "new:" syntax")

Commit 4c75fe3f70 passes all net options to the pod but forgot
to unset the options for the container creation. This leads to
erros when using flags like `--ip` since we tried setting
the ip on the pod and container which obviously fails.

I didn't notice the bug because we don't throw an error when
specifing port bindings on a container which joins the pods
network namespace. (#7373)

Also allow the use of `--hostname` and pass that option to the
pod and unset it for the container. The container has to use
the pods hostname anyway. This would error otherwise.

Added tests to prevent regression.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-20 14:59:21 -04:00
Matthew Heon
f12f2456af Fix a Makefile issue
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 14:18:12 -04:00
Matthew Heon
7fc0fbfb65 Fix a system test failure
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 14:17:48 -04:00
Daniel J Walsh
4e31c8136d
Cleanup handling of podman mount/unmount
We should default to the user name unmount rather then the internal
name of umount.

Also User namespace was not being handled correctly. We want to inform
the user that if they do a mount when in rootless mode that they have
to be first in the podman unshare state.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-20 13:35:11 -04:00
Matthew Heon
de75ae29ff Fix imports (podman -> libpod for v2.0 branch)
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 13:21:17 -04:00
Matthew Heon
314813c162 Final set of updates to release notes
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:43:25 -04:00
Daniel J Walsh
bcd9b8125c Add support for --connection
* override --url and/or --identity fields from containers.conf
* --connection flag has higher precedence than ActiveService from
containers.conf. Which is set via podman system connection default
* Add newline to error message printed on stderr
* Added --connection to bash completion and documentation
* Updated bindings to query server in case of no path or /

Closes #jira-991
Fixes #7276

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Jhon Honce <jhonce@redhat.com>

Squashed commits to work around CI issue

<MH: Fixed rebase conflicts on v2.0>

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:42:28 -04:00
Brent Baude
14379d6dbd remove --latest for all remote commands
instead of hiding the latest options for podman-remote or catching an error if podman --remote <cmd> -l is used, we no longer add the latest option to any remote command.  podman will error with a "unknown flag" option.

Fixes: #7127

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-20 12:40:08 -04:00
Matthew Heon
855ce48a92 Further release notes updates for v2.0.5
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:26:33 -04:00
Paul Holzinger
0ef6688785 fix podman create/run UTS NS docs
Add better error message when using `--pod` and `--hostname`.
Improve the docs to better explain the uts hostname relation.
Add more valid options for the `--uts` flag.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-20 12:25:55 -04:00
Giuseppe Scrivano
ce1389bde7 abi: fix detection for systemd
create a scope everytime we don't own the current cgroup and we are
running on systemd.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-08-20 12:24:38 -04:00
Paul Holzinger
d3ef4770d4 fix podman version output to include git commit and builttime
Add the go module version v2 to the libpod path.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-20 12:24:16 -04:00
Valentin Rothberg
b5b782f258 generate systemd: quote arguments with whitespace
Make sure that arguments with whitespace are properly quoted so they are
interpreted as one (and not multiple ones) by systemd.

Now `-e tz="america/new york"` will be generated as `-e "tz=america/new york"`.
The quotes are moving but the argument is still correct.

Fixes: #7285
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-08-20 12:21:49 -04:00
Matthew Heon
402d002184 Unmount c/storage containers before removing them
When `podman rmi --force` is run, it will remove any containers
that depend on the image. This includes Podman containers, but
also any other c/storage users who may be using it. With Podman
containers, we use the standard Podman removal function for
containers, which handles all edge cases nicely, shutting down
running containers, ensuring they're unmounted, etc.

Unfortunately, no such convient function exists (or can exist)
for all c/storage containers. Identifying the PID of a Buildah,
CRI-O, or Podman container is extremely different, and those are
just the implementations under the containers org. We can't
reasonably be able to know if a c/storage container is *in use*
and safe for removal if it's not a Podman container.

At the very least, though, we can attempt to unmount a storage
container before removing it. If it is in use, this will fail
(probably with a not-particularly-helpful error message), but if
it is not in use but not fully cleaned up, this should make our
removing it much more robust than it normally is.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:18:22 -04:00
Jhon Honce
ee956b04b0 [WIP] Refactor podman system connection
* Add support to manage multiple connections
  * Add connection
  * Remove connection
  * Rename connection
  * Set connection as default
  * Add markdown/man pages
* Fix recursion in hack/xref-helpmsgs-manpages

Signed-off-by: Jhon Honce <jhonce@redhat.com>

<MH: Fixed build after rebase>

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Jhon Honce
7c13b8c12f Fix podman system connection panic
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-20 12:16:53 -04:00
Matthew Heon
b216b3391c Revert "remove podman system connection"
This reverts commit 66e1626282. We
are reenabling podman-system-connection.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Matthew Heon
98a4f89854 Bump github.com/containers/common to v0.14.7
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Matthew Heon
579360e862 Fix imports for runtime_img.go
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Matthew Heon
e2a1242cee Fix one import path pointing to containers/podman
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Matthew Heon
44e5d0c1e8 HACK: Disable build-each-commit
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Matthew Heon
23348e7f31 Ensure DefaultEnvVariables is used in Specgen
When we rewrote Podman's pkg/spec, one of the things that was
lost was our use of a set of default environment variables, that
ensure all containers have at least $PATH and $TERM set.

While we're in the process of re-adding it, change it from a
variable to a function, so we can ensure the Join function does
not overwrite it and corrupt the defaults.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Matthew Heon
dbcb6f5892 Update release notes for v2.0.5
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
TomSweeneyRedHat
a8a3325445 [CI:DOCS] BZ1860126 - Fix userns defaults in run man page
Addresses the multiple "default" userns values found
in the podman-run(1) man page:  http://docs.podman.io/en/latest/markdown/podman-run.1.html.

This in response to: https://bugzilla.redhat.com/show_bug.cgi?id=1860126
which this PR wil fix.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-08-20 12:16:53 -04:00
Matthew Heon
eff0c29098 Unconditionally retrieve pod names via API
The ListContainers API previously had a Pod parameter, which
determined if pod name was returned (but, notably, not Pod ID,
which was returned unconditionally). This was fairly confusing,
so we decided to deprecate/remove the parameter and return it
unconditionally.

To do this without serious performance implications, we need to
avoid expensive JSON decodes of pod configuration in the DB. The
way our Bolt tables are structured, retrieving name given ID is
actually quite cheap, but we did not expose this via the Libpod
API. Add a new GetName API to do this.

Fixes #7214

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Jhon Honce
35d2db8072 Default .Repository and .Tag values to <none>
Refactor the processing of Repository and Tag fields to default to <none>
when printing via --format flag. Previously, the default format would
print <none> but --format {{.Tag}} would not in some cases.

Fixes #7123

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-20 12:16:53 -04:00
Parker Van Roy
4f349554ad Error pass through for more accurate error reporting
Included old error + wrapped

Signed-off-by: Parker Van Roy <pvanroy@redhat.com>
2020-08-20 12:16:53 -04:00
Daniel J Walsh
fc24c0cc10 Fix handling of working dir
Buildah and podman build can create images without a working dir.

FROM fedora
WORKDIR /test

If you build this image with caching twice, the second time the image
will not have a working dir.

Similarly if you execute

podman run --workdir /foobar fedora

It blows up since the workingdir is not created automatically.

Finally there was duplicated code for getting the workingdir
out of an image, that this PR removes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-20 12:16:53 -04:00
Matthew Heon
32f0c8f624 Do not use image CMD if user gave ENTRYPOINT
This matches Docker behavior, and seems to make sense - the CMD
may have been specific to the original entrypoint and probably
does not make sense if it was changed.

While we're in here, greatly simplify the logic for populating
the SpecGen's Command. We create the full command when making the
OCI spec, so the client should not be doing any more than setting
it to the Command the user passed in, and completely ignoring
ENTRYPOINT.

Fixes #7115

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-20 12:16:53 -04:00
Matthew Heon
d4c3365454 Ensure WORKDIR from images is created
A recent crun change stopped the creation of the container's
working directory if it does not exist. This is arguably correct
for user-specified directories, to protect against typos; it is
definitely not correct for image WORKDIR, where the image author
definitely intended for the directory to be used.

This makes Podman create the working directory and chown it to
container root, if it does not already exist, and only if it was
specified by an image, not the user.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Sascha Grunert
66fcafa4d4 Allow specifying seccomp profiles for privileged containers
To sync the behavior between AppArmor and seccomp it is now possible to
also specify seccomp profiles for privileged containers.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-20 12:16:53 -04:00
Christian Heimes
7fb53bc240 Use set for systemd commands
Signed-off-by: Christian Heimes <cheimes@redhat.com>
2020-08-20 12:16:52 -04:00
Christian Heimes
76ae0c9075 Enable systemd mode for /usr/local/sbin/init
Podman 1.6.2 changed systemd mode auto-detection from commands ending in
``init`` to hard-coded paths ``/sbin/init`` and ``/usr/sbin/init``. This
broke FreeIPA container. ``podman run`` and ``podman create`` now
activate systemd mode when the command is ``/usr/local/sbin/init``.

Fixes: https://github.com/containers/podman/issues/7287
Signed-off-by: Christian Heimes <cheimes@redhat.com>
2020-08-20 12:16:52 -04:00
Brent Baude
c539091bb0 Replace deepcopy on history results
the deepcopy in the remote history code path was throwing an uncaught error on a type mismatch.  we now manually do the conversion and fix the type mismatch on the fly.

Fixes: #7122

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-20 12:16:52 -04:00
zhangguanzhang
09bd563e2b Add parameter verification for api creation network
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-20 12:16:52 -04:00
Brent Baude
c22ea20bf6 add event for image build
upon image build completion, a new image type event is written for "build". more intricate details, like pulling an image, that might be done by build must be implemented in different vendored packages only after libpod is split from podman.

Fixes: #7022

Signed-off-by: Brent Baude <bbaude@redhat.com>

<MH: Fixed imports during cherry-pick>

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2020-08-20 12:16:52 -04:00
Matthew Heon
c14b6c3662 Change /sys/fs/cgroup/systemd mount to rprivate
I used the wrong propagation first time around because I forgot
that rprivate is the default propagation. Oops. Switch to
rprivate so we're using the default.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-20 12:16:52 -04:00
Qi Wang
34f4a892e4 podman save use named pipe
podman save uses named pipe as output path, not directly using /dev/stdout.
fix #7017

Signed-off-by: Qi Wang <qiwan@redhat.com>

<MH: Corrected imports during cherry-pick>

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2020-08-20 12:16:52 -04:00
Jonathan Dieter
ceae3a99d5 Fix hang when path doesn't exist
I'm not sure if this is an OS-specific issue, but on CentOS 8, if `path`
doesn't exist, this hangs while waiting to read from this socket, even
though the socket is closed by the `reexec_in_user_namespace`.  Switching
to a pipe fixes the problem, and pipes shouldn't be an issue since this is
Linux-specific code.

Signed-off-by: Jonathan Dieter <jonathan.dieter@spearline.com>
2020-08-20 12:16:52 -04:00