Commit graph

2015 commits

Author SHA1 Message Date
OpenShift Merge Robot 4351e33947
Merge pull request #6846 from mheon/fix_pod_errors
Print errors from individual containers in pods
2020-07-06 06:26:19 -04:00
Matthew Heon e996bb583d Print errors from individual containers in pods
The infra/abi code for pods was written in a flawed way, assuming
that the map[string]error containing individual container errors
was only set when the global error for the pod function was nil;
that is not accurate, and we are actually *guaranteed* to set the
global error when any individual container errors. Thus, we'd
never actually include individual container errors, because the
infra code assumed that err being set meant everything failed and
no container operations were attempted.

We were originally setting the cause of the error to something
nonsensical ("container already exists"), so I made a new error
indicating that some containers in the pod failed. We can then
ignore that error when building the report on the pod operation
and actually return errors from individual containers.

Unfortunately, this exposed another weakness of the infra code,
which was discarding the container IDs. Errors from individual
containers are not guaranteed to identify which container they
came from, hence the use of map[string]error in the Pod API
functions. Rather than restructuring the structs we return from
pkg/infra, I just wrapped the returned errors with a message
including the ID of the container.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-02 12:59:10 -04:00
Matthew Heon 9e4cf6ca51 Fix system service panic from early hangup in events
We weren't actually halting the goroutine that sent events, so it
would continue sending even when the channel closed (the most
notable cause being early hangup - e.g. Control-c on a curl
session). Use a context to cancel the events goroutine and stop
sending events.

Fixes #6805

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-02 09:57:39 -04:00
OpenShift Merge Robot c2a0ccd394
Merge pull request #6747 from giuseppe/fix-user-volumes
container: move volume chown after spec generation
2020-06-30 12:01:40 -04:00
Giuseppe Scrivano b32172e20b
container: move volume chown after spec generation
move the chown for newly created volumes after the spec generation so
the correct UID/GID are known.

Closes: https://github.com/containers/libpod/issues/5698

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-29 17:58:50 +02:00
Giuseppe Scrivano 688cc0aee3
libpod: volume copyup honors namespace mappings
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-29 17:51:55 +02:00
OpenShift Merge Robot 6ac009d530
Merge pull request #6666 from giuseppe/conmon-delegate
podman: add new cgroup mode split
2020-06-29 10:53:41 -04:00
Giuseppe Scrivano 6ee5f740a4
podman: add new cgroup mode split
When running under systemd there is no need to create yet another
cgroup for the container.

With conmon-delegated the current cgroup will be split in two sub
cgroups:

- supervisor
- container

The supervisor cgroup will hold conmon and the podman process, while
the container cgroup is used by the OCI runtime (using the cgroupfs
backend).

Closes: https://github.com/containers/libpod/issues/6400

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-25 17:16:12 +02:00
Matthew Heon d78e83f47d Add support for dangling filter to volumes
The dangling filter determine whether a volume is dangling - IE,
it has no containers attached using it. Unlike our other filters,
this one is a boolean - must be true or false, not arbitrary
values.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-24 15:12:56 -04:00
OpenShift Merge Robot b61e429f19
Merge pull request #6732 from mheon/fix_stopsignal_set
Set stop signal to 15 when not explicitly set
2020-06-24 13:02:43 -04:00
OpenShift Merge Robot 988fd27541
Merge pull request #6746 from vrothberg/untag
podman untag: error if tag doesn't exist
2020-06-24 12:19:42 -04:00
OpenShift Merge Robot 6bc5dcc282
Merge pull request #6729 from QiWang19/inspect-format
Reformat inspect network settings
2020-06-24 09:35:25 -04:00
Valentin Rothberg 1c6c12581c podman untag: error if tag doesn't exist
Throw an error if a specified tag does not exist.  Also make sure that
the user input is normalized as we already do for `podman tag`.

To prevent regressions, add a set of end-to-end and systemd tests.

Last but not least, update the docs and add bash completions.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-24 15:34:46 +02:00
Matthew Heon 7fe4c5204e Set stop signal to 15 when not explicitly set
When going through the output of `podman inspect` to try and
identify another issue, I noticed that Podman 2.0 was setting
StopSignal to 0 on containers by default. After chasing it
through the command line and SpecGen, I determined that we were
actually not setting a default in Libpod, which is strange
because I swear we used to do that. I re-added the disappeared
default and now all is well again.

Also, while I was looking for the bug in SpecGen, I found a bunch
of TODOs that have already been done. Eliminate the comments for
these.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-24 09:27:20 -04:00
Giuseppe Scrivano 370195cf78
libpod: specify mappings to the storage
specify the mappings in the container configuration to the storage
when creating the container so that the correct mappings can be
configured.

Regression introduced with Podman 2.0.

Closes: https://github.com/containers/libpod/issues/6735

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-24 11:26:49 +02:00
Qi Wang f586c006f8 Reformat inspect network settings
Reformat ports of inspect network settings to compatible with docker inspect. Close #5380

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-23 16:14:27 -04:00
OpenShift Merge Robot 9e37fd43e4
Merge pull request #6625 from QiWang19/fd
Add --preservefds to podman run
2020-06-23 10:00:21 +02:00
OpenShift Merge Robot 11dd5f51b6
Merge pull request #6702 from jgallucci32/follow-logs-poll
Stop following logs using timers
2020-06-22 18:10:06 +02:00
jgallucci32 8926e1f03b Use POLL_DURATION for timer
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-21 09:31:22 -07:00
jgallucci32 78dd4f2ecb Stop following logs using timers
This incorporates code from PR #6591 and #6614 but does not use
event channels to detect container state and rather uses timers
with a defined wait duration before calling t.StopAtEOF() to
ensure the last log entry is output before a container exits.

The polling interval is set to 250 milliseconds based on polling
interval defined in hpcloud/tail here:
https://github.com/hpcloud/tail/blob/v1.0.0/watch/polling.go#L117

Co-authored-by: Qi Wang <qiwan@redhat.com>
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-20 09:48:55 -07:00
Daniel J Walsh 5b3503c0a1
Add container name to the /etc/hosts within the container
This will allow containers that connect to the network namespace be
able to use the container name directly.

For example you can do something like

podman run -ti --name foobar fedora ping foobar

While we can do this with hostname now, this seems more natural.

Also if another container connects on the network to this container it
can do

podman run --network container:foobar fedora ping foobar

And connect to the original container,without having to discover the name.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-20 06:20:46 -04:00
OpenShift Merge Robot f403aa3baa
Merge pull request #6621 from vrothberg/bz-1846629
search: allow wildcards
2020-06-20 05:57:25 -04:00
Brent Baude f46664546a Poll on events for file reading
When multiple connections are monitoring events via the remote API, the inotify in the hpcloud library seems unable to consistently send events.  Switching from inotify to poll seems to clear this up.

Fixes: #6664

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-06-19 09:00:03 -05:00
Qi Wang f61a7f25a8 Add --preservefds to podman run
Add --preservefds to podman run. close https://github.com/containers/libpod/issues/6458

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-19 09:40:13 -04:00
Valentin Rothberg b05888a97d search: allow wildcards
Allow wildcards in the search term.  Note that not all registries
support wildcards and it may only work with v1 registries.

Note that searching implies figuring out if the specified search term
includes a registry.  If there's not registry detected, the search term
will be used against all configured "unqualified-serach-registries" in
the registries.conf.  The parsing logic considers a registry to be the
substring before the first slash `/`.

With these changes we now not only support wildcards but arbitrary
input; ultimately it's up to the registries to decide whether they
support given input or not.

Fixes: bugzilla.redhat.com/show_bug.cgi?id=1846629
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-19 14:47:36 +02:00
Matthew Heon b20619e5b0 Allow recursive dependency start with Init()
As part of APIv2 Attach, we need to be able to attach to freshly
created containers (in ContainerStateConfigured). This isn't
something Libpod is interested in supporting, so we use Init() to
get the container into ContainerStateCreated, in which attach is
possible. Problem: Init() will fail if dependencies are not
started, so a fresh container in a fresh pod will fail. The
simplest solution is to extend the existing recursive start code
from Start() to Init(), allowing dependency containers to be
started when we initialize the container (optionally, controlled
via bool).

Also, update some comments in container_api.go to make it more
clear how some of our major API calls work.

Fixes #6646

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-06-18 09:34:04 -04:00
OpenShift Merge Robot 7b00e49f65
Merge pull request #6560 from mheon/fix_exec_logdriver
Do not share container log driver for exec
2020-06-17 17:17:27 -04:00
OpenShift Merge Robot fd184fa4a1
Merge pull request #6522 from mheon/unless-stopped
Add support for the unless-stopped restart policy
2020-06-17 15:25:09 -04:00
jgallucci32 03e99c9b40 Revert #6591 to fix issue with failed tests
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-17 08:31:09 -07:00
Matthew Heon 6f1440a3ec Add support for the unless-stopped restart policy
We initially believed that implementing this required support for
restarting containers after reboot, but this is not the case.
The unless-stopped restart policy acts identically to the always
restart policy except in cases related to reboot (which we do not
support yet), but it does not require that support for us to
implement it.

Changes themselves are quite simple, we need a new restart policy
constant, we need to remove existing checks that block creation
of containers when unless-stopped was used, and we need to update
the manpages.

Fixes #6508

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-17 11:16:12 -04:00
Matthew Heon 0e171b7b33 Do not share container log driver for exec
When the container uses journald logging, we don't want to
automatically use the same driver for its exec sessions. If we do
we will pollute the journal (particularly in the case of
healthchecks) with large amounts of undesired logs. Instead,
force exec sessions logs to file for now; we can add a log-driver
flag later (we'll probably want to add a `podman logs` command
that reads exec session logs at the same time).

As part of this, add support for the new 'none' logs driver in
Conmon. It will be the default log driver for exec sessions, and
can be optionally selected for containers.

Great thanks to Joe Gooch (mrwizard@dok.org) for adding support
to Conmon for a null log driver, and wiring it in here.

Fixes #6555

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-17 11:11:46 -04:00
Daniel J Walsh fb4148bc41
Fix podman-remote images
Looks like we went too far with the linters.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-16 12:29:25 -04:00
OpenShift Merge Robot 8a42a32c71
Merge pull request #6591 from jgallucci32/patch-1
Merged request to fix -f to stop following logs
2020-06-15 13:57:13 -04:00
jgallucci32 6d9863e773 Remove redundant break in for loop.
Remove redundant `break` call in for loop.

Co-authored-by: Qi Wang <qiwan@redhat.com>
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-15 07:42:05 -07:00
Daniel J Walsh 200cfa41a4
Turn on More linters
- misspell
    - prealloc
    - unparam
    - nakedret

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-15 07:05:56 -04:00
jgallucci32 d514e3c097 Do not print error message when container does not exist
This fixes a condition when a container is removed while
following the logs and prints an error when the container
is removed forcefully.

Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-12 12:59:58 -07:00
jgallucci32 e714352501 Changed from t.StopAtEOF() to t.Stop() and added error check
Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-12 11:10:08 -07:00
jgallucci32 9ac115e691 Fix -f logs to stop when a container exits
Fixes an issue with the previous PR where a container would exit while following logs and the log tail continued to follow. This creates a subroutine which checks the state of the container and instructs the tailLog to stop when it reaches EOF.

Tested the following conditions:
* Tail and follow logs of running container
* Tail and follow logs of stopped container
* Tail and follow logs of running container which exits after some time

Signed-off-by: jgallucci32 <john.gallucci.iv@gmail.com>
2020-06-12 10:14:35 -07:00
Qi Wang 033743cbee Fix -f logs follow with stopped container
Fix -f logs follow with stopped container. Close #6531

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-11 17:55:26 -04:00
OpenShift Merge Robot 39ad0387ca
Merge pull request #6415 from vrothberg/systemd-new-pod
podman-generate-systemd --new for pods
2020-06-11 10:56:11 -04:00
OpenShift Merge Robot 1060a94efb
Merge pull request #6568 from giuseppe/fix-check-for-rootless-net
libpod: fix check for slirp4netns netns
2020-06-11 08:55:50 -04:00
OpenShift Merge Robot 09e4faa7df
Merge pull request #6529 from mheon/v6_ports
Enable IPv6 port binding
2020-06-11 08:50:13 -04:00
Giuseppe Scrivano 8ef1b461ae
libpod: fix check for slirp4netns netns
fix the check for c.state.NetNS == nil.  Its value is changed in the
first code block, so the condition is always true in the second one
and we end up running slirp4netns twice.

Closes: https://github.com/containers/libpod/issues/6538

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-06-11 13:06:26 +02:00
Valentin Rothberg 8d8746adee generate systemd: create pod template
Create a new template for generating a pod unit file. Eventually, this
allows for treating and extending pod and container generation
seprately.

The `--new` flag now also works on pods.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-11 11:01:13 +02:00
Valentin Rothberg 35ae53067f generate systemd: refactor
Refactor the systemd-unit generation code and move all the logic into
`pkg/systemd/generate`.  The code was already hard to maintain but I
found it impossible to wire the `--new` logic for pods in all the chaos.

The code refactoring in this commit will make maintaining the code
easier and should make it easier to extend as well.  Further changes and
refactorings may still be needed but they will easier.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-11 11:01:13 +02:00
Valentin Rothberg b4a410215e add (*Pod).CreateCommand()
Add a method to Pod to easily access its .config.CreateCommand.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-11 11:01:13 +02:00
Valentin Rothberg 402c68b41d pod create: add --infra-conmon-pidfile
Add an `--infra-conmon-pidfile` flag to `podman-pod-create` to write the
infra container's conmon process ID to a specified path.  Several
container sub-commands already support `--conmon-pidfile` which is
especially helpful to allow for systemd to access and track the conmon
processes.  This allows for easily tracking the conmon process of a
pod's infra container.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-11 11:01:13 +02:00
Valentin Rothberg 636881ece5 pod config: add a CreateCommand field
Add a `CreateCommand` field to the pod config which includes the entire
`os.Args` at pod-creation.  Similar to the already existing field in a
container config, we need this information to properly generate generic
systemd unit files for pods.  It's a prerequisite to support the `--new`
flag for pods.

Also add the `CreateCommand` to the pod-inspect data, which can come in
handy for debugging, general inspection and certainly for the tests that
are added along with the other changes.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-11 11:01:13 +02:00
Will Haines 86ffa552d2 Fixed bug where 'podman log <container>' would truncate some lines.
Signed-off-by: Will Haines <william.haines@colorado.edu>
2020-06-10 15:08:48 -06:00
Matthew Heon 4e2a0b5b9c Enable IPv6 port binding
Two areas needed tweaking to accomplish this: port parsing and
binding ports on the host.

Parsing is an obvious problem - we have to accomodate an IPv6
address enclosed by [] as well as a normal IPv4 address. It was
slightly complicated by the fact that we previously just counted
the number of colons in the whole port definition (a thousand
curses on whoever in the IPv6 standard body decided to reuse
colons for address separators), but did not end up being that
bad.

Libpod also (optionally) binds ports on the host to prevent their
reuse by host processes. This code was IPv4 only for TCP, and
bound to both for UDP (which I'm fairly certain is not correct,
and has been adjusted). This just needed protocols adjusted to
read "tcp4"/"tcp6" and "udp4"/"udp6" based on what we wanted to
bind to.

Fixes #5715

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-10 13:28:09 -04:00