1693 Commits

Author SHA1 Message Date
8bc394ce6e Add the pod name when we use podman ps -p
The pod name does not appear when doing `podman ps -p`.
It is missing as the documentation says:
-p, --pod              Print the ID and name of the pod the containers are associated with

The pod name is added in the ps output and checked in unit tests.

Closes #4703

Signed-off-by: NevilleC <neville.cain@qonto.eu>
2019-12-28 00:03:57 +01:00
4f09cfdacc add struct response for removal of images
when removing an image from storage, we should return a struct that
details what was untagged vs deleted.  this replaces the simple
println's used previously and assists in API development.

Signed-off-by: baude <bbaude@redhat.com>
2019-12-23 10:02:14 -06:00
e33d7e9fab Merge pull request #4727 from rhatdan/pidns
if container is not in a pid namespace, stop all processes
2019-12-20 12:13:22 +01:00
a359ca0d18 Merge pull request #4723 from mheon/pod_volume_postremove
Remove volumes after containers in pod remove
2019-12-19 19:37:00 +01:00
dde48b44e7 Merge pull request #4684 from vrothberg/systemd-improvements
container config: add CreateCommand
2019-12-19 19:36:52 +01:00
123b8c627d if container is not in a pid namespace, stop all processes
When a container is in a PID namespace, it is enought to send
the stop signal to the PID 1 of the namespace, only send signals
to all processes in the container when the container is not in
a pid namespace.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-19 13:33:17 -05:00
88917e4a93 Remove volumes after containers in pod remove
When trying to reproduce #4704 I noticed that the named volumes
from the Postgres containers in the reproducer weren't being
removed by `podman pod rm -f` saying that the container they were
attached to was still in use. This was rather odd, considering
they were only in use by one container, and that container was in
the process of being removed with the pod.

After a bit of tracing, I realized that the cause is the ordering
of container removal when we remove a pod. Normally, it's done
in removeContainer() before volume removal (which is the last
thing in that function). However, when we are removing a pod, we
remove containers all at once, after removeContainer has already
finished - meaning the container still exists when we try to
remove its volumes, and thus the volume can't be removed.

Solution: collect a list of all named volumes in use by the pod,
and remove them all at once after every container in the pod is
gone. This ensures that there are no dependency issues.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-17 21:41:31 -05:00
e6b843312b Merge pull request #4643 from adrianreber/master
Correctly export the root file-system changes
2019-12-17 18:08:36 +01:00
1e440a3a3f Merge pull request #4681 from jvanz/issue4553
podman: mirror information
2019-12-17 14:05:15 +01:00
87194a6f79 Fix F30-F31 migration for Podman 1.7.0
The earlier attempt to re-add config migration only worked with
user-specified configs (podman run --config). This version works
more in line with that we want - the first rootless config file
will be changed from runc to crun.

Verified on my system after an F31 migration - everything seems
to be working well.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-12-13 13:51:39 -05:00
40f4a00eb3 runtime.go: show registries data and search table
Update podman info command to show the registries data and the search
table.

Signed-off-by: José Guilherme Vanz <jvanz@jvanz.com>
2019-12-13 11:11:28 -03:00
437bc61f4e container config: add CreateCommand
Store the full command plus arguments of the process the container has
been created with.  Expose this data as a `Config.CreateCommand` field
in the container-inspect data as well.

This information can be useful for debugging, as we can find out which
command has created the container, and, if being created via the Podman
CLI, we know exactly with which flags the container has been created
with.

The immediate motivation for this change is to use this information for
`podman-generate-systemd` to generate systemd-service files that allow
for creating new containers (in contrast to only starting existing
ones).

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-12-13 14:39:45 +01:00
71a0c0f69c Merge pull request #4692 from mheon/reap_exec_sessions
Reap exec sessions on cleanup and removal
2019-12-13 10:19:31 +01:00
95d26e3f6f runtime.go: show search table in podman info
Updates the podman info command to show registries from v1 config file
in the search table format.

Signed-off-by: José Guilherme Vanz <jvanz@jvanz.com>
2019-12-12 20:54:16 -03:00
4f9672e94c podman: mirror information
Updates the podman info command to show the mirror information

Issue https://github.com/containers/libpod/issues/4553

Signed-off-by: José Guilherme Vanz <jvanz@jvanz.com>
2019-12-12 19:53:46 -03:00
bd44fd5c81 Reap exec sessions on cleanup and removal
We currently rely on exec sessions being removed from the state
by the Exec() API itself, on detecting the session stopping. This
is not a reliable method, though. The Podman frontend for exec
could be killed before the session ended, or another Podman
process could be holding the lock and prevent update (most
notable in `run --rm`, when a container with an active exec
session is stopped).

To resolve this, add a function to reap active exec sessions from
the state, and use it on cleanup (to clear sessions after the
container stops) and remove (to do the same when --rm is passed).
This is a bit more complicated than it ought to be because Kata
and company exist, and we can't guarantee the exec session has a
PID on the host, so we have to plumb this through to the OCI
runtime.

Fixes #4666

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-12 16:35:37 -05:00
dd64038192 Merge pull request #4664 from baude/movefilters
move image filters under libpod/images
2019-12-11 16:58:54 +01:00
8be7b466d8 move image filters under libpod/images
to make things more effecient for the api work we are doing, we should
process image filters internally (as opposed to in main).  this allows
for better api responses and more closely affiliated functions.

Signed-off-by: baude <bbaude@redhat.com>
2019-12-10 13:05:18 -06:00
0355c28edf Re-add Fedora 31 migration code.
In the process, make everything in the config omitempty in TOML.
We're seeing issues (notably [1]) where, after rewriting
libpod.conf, fields that were not previously populated are
written - and, because they were not previously written, they are
included as empty. This is unfortunately different from not
included at all - it means that we need to assume the user
explicitly unset the value, and we can't use defaults. Setting
omitempty prevents us from writing things that should not be
written as they were not set originally.

[1] https://github.com/containers/libpod/issues/4210

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-10 13:50:17 -05:00
225c7ae6c9 Correctly export the root file-system changes
When doing a checkpoint with --export the root file-system diff was not
working as expected. Instead of getting the changes from the running
container to the highest storage layer it got the changes from the
highest layer to that parent's layer. For a one layer container this
could mean that the complete root file-system is part of the checkpoint.

With this commit this changes to use the same functionality as 'podman
diff'. This actually enables to correctly diff the root file-system
including tracking deleted files.

This also removes the non-working helper functions from libpod/diff.go.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-12-09 13:29:36 +01:00
8924a302a2 Merge pull request #4563 from mheon/fix_change_parsing
Fix parsing for arrays of values in image changes
2019-12-06 04:09:06 -08:00
60bfa305a8 Add ONBUILD support to --change
Return types had to change a bit for this, but since we can wrap
the old v1.ImageConfig, changes are overall not particularly bad.

At present, I believe this only works with commit, not import.
This matches how things were before we changed to the new parsing
so I think this is fine.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-05 15:11:40 -05:00
c4fbd2fc94 Move Commit() to new parsing for --change
It turns out we had two independent parsing impkementations for
Dockerfile instructions out of --change. My previous commit fixed
the one used in --change, but as I discovered to my dismay,
commit used a different implementation. Remove that and use the
new parsing implementation instead.

While we're at it, fix some bugs in the current commit code. The
addition of anonymous named volumes to Libpod recently means we
can now include those in the image config when committing. Some
changes (VOLUME, ENV, EXPOSE, LABEL) previously cleared the
config of the former image when used; Docker does not do this, so
I removed that behavior.

Still needs fixing: the new implementation does not support
ONBUILD, while the old one did.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-05 13:19:47 -05:00
3f1675d902 libpod: fix stats for rootless pods
honor the systemd parent directory when specified.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-12-04 11:13:40 +01:00
5c3af009c6 Merge pull request #4629 from mheon/fix_indirect_netnsctr_lookup
Allow chained network namespace containers
2019-12-03 09:16:31 -08:00
b0b9103cca Allow chained network namespace containers
The code currently assumes that the container we delegate network
namespace to will never further delegate to another container, so
when looking up things like /etc/hosts and /etc/resolv.conf we
won't pull the correct files from the chained dependency. The
changes to resolve this are relatively simple - just need to keep
looking until we find a container without NetNsCtr set.

Fixes #4626

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-03 10:27:15 -05:00
689329f749 Ensure volumes reacquire locks on state refresh
After a restart, pods and containers both run a refresh()
function to prepare to run after a reboot. Until now, volumes
have not had a similar function, because they had no per-boot
setup to perform.

Unfortunately, this was not noticed when in-memory locking was
introduced to volumes. The refresh() routine is, among other
things, responsible for ensuring that locks are reserved after a
reboot, ensuring they cannot be taken by a freshly-created
container, pod, or volume. If this reservation is not done, we
can end up with two objects using the same lock, potentially
needing to lock each other for some operations - classic recipe
for deadlocks.

Add a refresh() function to volumes to perform lock reservation
and ensure it is called as part of overall refresh().

Fixes #4605
Fixes #4621

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-02 23:06:00 -05:00
e13e5502e3 libpod: fix case for executable file not found errors
do not change the runtime error to be lowercase, but use a case
insensitive regex matching.  In this way the original error from the
OCI runtime is reported back.

regression introduced by bc485bce47f55135d6ead80537bc145edb779ae9

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-12-02 18:03:33 +01:00
e4275b3453 Merge pull request #4493 from mheon/add_removing_state
Add ContainerStateRemoving
2019-12-02 16:31:11 +01:00
39c705e940 Merge pull request #4558 from rhatdan/reset
Add podman system reset command
2019-11-29 15:05:03 +01:00
7f53178a7d Merge pull request #4576 from giuseppe/oci-errors-only-match
oci: print only matching part for the errors
2019-11-29 12:22:58 +01:00
79bf5010ed Add podman system reset command
This command will destroy all data created via podman.
It will remove containers, images, volumes, pods.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-11-29 05:34:52 -05:00
5e43c7cde1 Disable checkpointing of containers started with --rm
Trying to checkpoint a container started with --rm works, but it makes
no sense as the container, including the checkpoint, will be deleted
after writing the checkpoint. This commit inhibits checkpointing
containers started with '--rm' unless '--export' is used. If the
checkpoint is exported it can easily be restored from the exported
checkpoint, even if '--rm' is used. To restore a container from a
checkpoint it is even necessary to manually run 'podman rm' if the
container is not started with '--rm'.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-11-28 20:25:45 +01:00
bc485bce47 oci: print only matching part for the errors
when parsing the OCI error, be sure to discard any other output that
is not matched.  The full output is still printed with
--log-level=debug.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-28 09:51:58 +01:00
2178875fa7 Merge pull request #4568 from openSUSE/history
Add support for image name history
2019-11-27 15:31:22 +01:00
63e46cc85c Add support for image name history
We leverage the containers/storage image history tracking feature to
show the previously used image names when running:
`podman images --history`

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-11-27 13:42:06 +01:00
01ae532a89 Allow --ip and --mac to be set when joining a CNI net
These only conflict when joining more than one network. We can
still set a single CNI network and set a static IP and/or static
MAC.

Fixes #4500

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-11-26 09:56:14 -05:00
ef240f4cd0 Merge pull request #4512 from kunalkushwaha/prune-filter
image prune command fixed as per docker image prune.
2019-11-22 21:56:12 +01:00
22e7d7d86f Merge pull request #4525 from rst0git/uns-restore-fix
container-restore: Fix restore with user namespace
2019-11-22 16:07:26 +01:00
5082496cc0 filter added to image pruge command.
filter option accepts two filters.
- label
- until
label supports "label=value" or "label=key=value" format
until supports all golang compatible time/duration formats.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
2019-11-22 17:36:27 +09:00
0352bbc6e9 config: use EventsLogger=file without systemd
if systemd is not available, use the file events logger backend.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-11-21 12:02:04 +01:00
6c405b5fbc Error on netns not exist only when ctr is running
If the container is running and we need to get its netns and
can't, that is a serious bug deserving of errors.

If it's not running, that's not really a big deal. Log an error
and continue.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-11-19 15:38:03 -05:00
25cc43c376 Add ContainerStateRemoving
When Libpod removes a container, there is the possibility that
removal will not fully succeed. The most notable problems are
storage issues, where the container cannot be removed from
c/storage.

When this occurs, we were faced with a choice. We can keep the
container in the state, appearing in `podman ps` and available for
other API operations, but likely unable to do any of them as it's
been partially removed. Or we can remove it very early and clean
up after it's already gone. We have, until now, used the second
approach.

The problem that arises is intermittent problems removing
storage. We end up removing a container, failing to remove its
storage, and ending up with a container permanently stuck in
c/storage that we can't remove with the normal Podman CLI, can't
use the name of, and generally can't interact with. A notable
cause is when Podman is hit by a SIGKILL midway through removal,
which can consistently cause `podman rm` to fail to remove
storage.

We now add a new state for containers that are in the process of
being removed, ContainerStateRemoving. We set this at the
beginning of the removal process. It notifies Podman that the
container cannot be used anymore, but preserves it in the DB
until it is fully removed. This will allow Remove to be run on
these containers again, which should successfully remove storage
if it fails.

Fixes #3906

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-11-19 15:38:03 -05:00
741b90c2b9 Merge pull request #4502 from vrothberg/fix-3359
history: rewrite mappings
2019-11-18 15:10:09 +01:00
368d2ecfb6 container-restore: Fix restore with user namespace
When restoring a container with user namespace, the user namespace is
created by the OCI runtime, and the network namespace is created after
the user namespace to ensure correct ownership.

In this case PostConfigureNetNS will be set and the value of
c.state.NetNS would be nil. Hence, the following error occurs:

    $ sudo podman run --name cr \
	   --uidmap 0:1000:500 \
	   -d docker.io/library/alpine \
	   /bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'

    $ sudo podman container checkpoint cr
    $ sudo podman container restore cr
    ...
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x13a5e3c]

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2019-11-17 00:34:02 +00:00
fa415f07a1 Also delete winsz fifo
In conmon 2.0.3, we add another fifo to handle window resizing. This needs to be cleaned up for commands like restore, where the same path is used.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-11-15 12:44:15 -05:00
bf62f9a5cf history: rewrite mappings
Rewrite the backend for displaying the history of an image to simplify
the code and be closer to docker's behaviour.  Instead of driving
index-based heuristics, create a reverse mapping from top-layers to the
corresponding image IDs and lookup the layers on-demand.  Also use the
uncompressed layer size to be closer to Docker's behaviour.

Note that intermediate images from local builds are not considered for
the ID lookups anymore.

Fixes: #3359
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-11-12 17:29:30 -05:00
8d928d525f codespell: spelling corrections
Signed-off-by: Dmitry Smirnov <onlyjob@member.fsf.org>
2019-11-13 08:15:00 +11:00
d919961f62 Merge pull request #4451 from giuseppe/set-mac
podman: add support for specifying MAC
2019-11-07 20:26:14 +01:00
24efb5e4eb Merge pull request #4470 from vrothberg/fix-4463
libpod/config: default: use `crun` on Cgroups v2
2019-11-07 16:26:22 +01:00