Commit graph

109 commits

Author SHA1 Message Date
Peter Hunt 51bdf29f04 Address comments
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-05-28 11:10:57 -04:00
Peter Hunt 02f971131a Implement podman logs with log-driver journald
Add a journald reader that translates the journald entry to a k8s-file formatted line, to be added as a log line

Note: --follow with journald hasn't been implemented. It's going to be a larger undertaking that can wait.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-05-28 11:10:57 -04:00
Peter Hunt f61fa28d39 Added --log-driver and journald logging
Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-05-28 11:10:57 -04:00
Giuseppe Scrivano 3788da9344
libpod: prefer WaitForFile to polling
replace two usage of kwait.ExponentialBackoff in favor of WaitForFile
that uses inotify when possible.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-05-21 10:07:31 +02:00
baude 0b6bb6a3d3 enable podman-remote on windows
build a podman-remote binary for windows that allows users to use the
remote client on windows and interact with podman on linux system.

Signed-off-by: baude <bbaude@redhat.com>
2019-04-30 15:28:39 -05:00
Jhon Honce 09ff62429a Implement podman-remote rm
* refactor command output to use one function
* Add new worker pool parallel operations
* Implement podman-remote umount
* Refactored podman wait to use printCmdOutput()

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2019-04-09 11:55:26 -07:00
Giuseppe Scrivano d8caa2f2fa
oci: drop reference to runc
it can be any OCI runtime.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-29 11:10:34 +01:00
Giuseppe Scrivano ce0ca0d459
rootless: change env prefix
from _LIBPOD to _CONTAINERS.  The same change was done in buildah
unshare.

This is necessary for podman to detect we are running in a rootless
environment and work properly from a "buildah unshare" session.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-28 17:08:20 +01:00
Matthew Heon 101e6f6b74 Add support for SCTP port forwarding
SCTP is already present and enabled in the CNI plugins, so all we
need to do to add support is not error on attempting to bind
ports to reserve them.

I investigated adding this binding for SCTP, but support for SCTP
in Go is honestly a mess - there's no widely-supported library
for doing it that will do what we need.

For now, warn that port reservation for SCTP is not supported and
forward the ports.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2019-03-15 10:51:33 -04:00
Matthew Heon 3b5805d521 Add event on container death
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-03-13 10:18:51 -04:00
Giuseppe Scrivano ffe1ed7058
oci: make explicit the extra files to the exec
In the previous version I forgot to add the fds to preserve into
AdditionalFiles.  It doesn't make a difference as the files were still
preserved, but this seems to be the correct way of making it
explicit.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-07 15:16:28 +01:00
Giuseppe Scrivano 0b34327ad4
exec: support --preserve-fds
Allow to pass additional FDs to the process being executed.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-03-02 11:45:42 +01:00
OpenShift Merge Robot 2747c20867
Merge pull request #2485 from adrianreber/oci-check
Verify that used OCI runtime supports checkpoint
2019-03-01 12:04:29 -08:00
Adrian Reber 43fe2bf064
Verify that used OCI runtime supports checkpoint
To be able to use OCI runtimes which do not implement checkpoint/restore
this adds a check to the checkpoint code path and the checkpoint/restore
tests to see if it knows about the checkpoint subcommand. If the used
OCI runtime does not implement checkpoint/restore the tests are skipped
and the actual 'podman container checkpoint' returns an error.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-03-01 08:08:55 +01:00
Peter Hunt d780e69559 Allow Exec API user to override streams
Allow passing in of AttachStreams to libpod.Exec() for usage in podman healthcheck. An API caller can now specify different streams for stdout, stderr and stdin, or no streams at all.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2019-02-28 14:55:11 -05:00
Giuseppe Scrivano 41967e2601
oci: do not set XDG_RUNTIME_DIR twice
we are doing it few lines above.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-02-11 12:38:09 +01:00
OpenShift Merge Robot 4afdfd5eab
Merge pull request #2187 from rhatdan/selinux
Vendor in latest opencontainers/selinux
2019-01-21 08:49:20 +01:00
OpenShift Merge Robot 74b85098cf
Merge pull request #2142 from giuseppe/expose-ports
rootless: support port redirection from the host
2019-01-20 13:25:37 +01:00
Giuseppe Scrivano f182946bef
rootless: support port redirection from the host
add support for ports redirection from the host.

It needs slirp4netns v0.3.0-alpha.1.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-01-19 20:45:07 +01:00
Daniel J Walsh 8cf929c095
Vendor in latest opencontainers/selinux
This will now verify labels passed in by the user.
Will also prevent users from accidently relabeling their homedir.

podman run -ti -v ~/home/user:Z fedora sh

Is not a good idea.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-01-18 17:08:46 -05:00
Vincent Batts 650cf122e1
libpod: allow multiple oci runtimes
This deprecates the libpod.conf variable of `runtime_path=`, and now has
`runtimes=`, like a map for naming the runtime, preparing for a
`--runtime` flag to `podman run` (i.e. runc, kata, etc.)

Reference: https://github.com/containers/libpod/issues/1750

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2019-01-14 10:03:40 +01:00
Matthew Heon 167d50a9fa Move all libpod/ JSON references over to jsoniter
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-01-10 15:48:09 -05:00
Debarshi Ray 867669374c Add a --workdir option to 'podman exec'
Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2019-01-08 17:42:37 +01:00
Daniel J Walsh 64ac546259
Set Socket label for contianer
This will allow container processes to write to the CRIU socket that gets injected
into the container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-12-12 04:22:44 -08:00
Giuseppe Scrivano 1d2e1eece5
rootless: propagate XDG_RUNTIME_DIR to the OCI runtime
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-30 22:37:09 +01:00
Giuseppe Scrivano fe919e4914
oci: propagate NOTIFY_SOCKET on runtime start
with https://github.com/opencontainers/runc/pull/1807 we moved the
systemd notify initialization from "create" to "start", so that the
OCI runtime doesn't hang while waiting on reading from the notify
socket.  This means we also need to set the correct NOTIFY_SOCKET when
start'ing the container.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-28 16:25:12 +01:00
OpenShift Merge Robot effd63d6d5
Merge pull request #1848 from adrianreber/master
Add tcp-established to checkpoint/restore
2018-11-28 07:00:24 -08:00
OpenShift Merge Robot d346996e15
Merge pull request #1849 from giuseppe/report-rootless-netmode
rootless: add new netmode "slirp4netns"
2018-11-28 06:18:28 -08:00
Giuseppe Scrivano 0365f57371
rootless: fix cleanup
The conmon exit command is running inside of a namespace where the
process is running with uid=0.  When it launches again podman for the
cleanup, podman is not running in rootless mode as the uid=0.

Export some more env variables to tell podman we are in rootless
mode.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-28 10:19:13 +01:00
Giuseppe Scrivano 95f22a2ca0
network: allow slirp4netns mode also for root containers
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-28 09:21:59 +01:00
Adrian Reber 03c88a3deb
Added tcp-established to checkpoint/restore
CRIU can checkpoint and restore processes/containers with established
TCP connections if the correct option is specified. To implement
checkpoint and restore with support for established TCP connections with
Podman this commit adds the necessary options to runc during checkpoint
and also tells conmon during restore to use 'runc restore' with
'--tcp-established'.

For this Podman feature to work a corresponding conmon change is
required.

Example:

$ podman run --tmpfs /tmp --name podman-criu-test -d docker://docker.io/yovfiatbeb/podman-criu-test
$ nc `podman inspect -l | jq -r '.[0].NetworkSettings.IPAddress'` 8080
GET /examples/servlets/servlet/HelloWorldExample
Connection: keep-alive

1
GET /examples/servlets/servlet/HelloWorldExample
Connection: keep-alive

2
$ # Using HTTP keep-alive multiple requests are send to the server in the container
$ # Different terminal:
$ podman container checkpoint -l
criu failed: type NOTIFY errno 0
$ # Looking at the log file would show errors because of established TCP connections
$ podman container checkpoint -l --tcp-established
$ # This works now and after the restore the same connection as above can be used for requests
$ podman container restore -l --tcp-established

The restore would fail without '--tcp-established' as the checkpoint image
contains established TCP connections.

Signed-off-by: Adrian Reber <areber@redhat.com>
2018-11-28 08:00:38 +01:00
Adrian Reber 0592558289
Use also a struct to pass options to Restore()
This is basically the same change as

 ff47a4c2d5 (Use a struct to pass options to Checkpoint())

just for the Restore() function. It is used to pass multiple restore
options to the API and down to conmon which is used to restore
containers. This is for the upcoming changes to support checkpointing
and restoring containers with '--tcp-established'.

Signed-off-by: Adrian Reber <areber@redhat.com>
2018-11-28 08:00:37 +01:00
OpenShift Merge Robot e679e768f1
Merge pull request #1832 from giuseppe/always-make-explicit-tty-to-exec
exec: always make explicit the tty value
2018-11-27 04:08:03 -08:00
Adrian Reber b0572d6229
Added option to keep containers running after checkpointing
CRIU supports to leave processes running after checkpointing:

  -R|--leave-running    leave tasks in running state after checkpoint

runc also support to leave containers running after checkpointing:

   --leave-running      leave the process running after checkpointing

With this commit the support to leave a container running after
checkpointing is brought to Podman:

   --leave-running, -R  leave the container running after writing checkpoint to disk

Now it is possible to checkpoint a container at some point in time
without stopping the container. This can be used to rollback the
container to an early state:

$ podman run --tmpfs /tmp --name podman-criu-test -d docker://docker.io/yovfiatbeb/podman-criu-test
$ curl 10.88.64.253:8080/examples/servlets/servlet/HelloWorldExample
3
$ podman container checkpoint -R -l
$ curl 10.88.64.253:8080/examples/servlets/servlet/HelloWorldExample
4
$ curl 10.88.64.253:8080/examples/servlets/servlet/HelloWorldExample
5
$ podman stop -l
$ podman container restore -l
$ curl 10.88.64.253:8080/examples/servlets/servlet/HelloWorldExample
4

So after checkpointing the container kept running and was stopped after
some time. Restoring this container will restore the state right at the
checkpoint.

Signed-off-by: Adrian Reber <areber@redhat.com>
2018-11-20 17:25:44 +01:00
Giuseppe Scrivano fd01402930
exec: always make explicit the tty value
otherwise runc will take by default the value used for creating the
container.  Setting it explicit overrides its default value and we
won't end up trying to use a terminal when not available.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1625876

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-11-20 17:08:57 +01:00
Šimon Lukašík 223d102ec7 Lint: Do not ignore errors from docker run command when selinux enabled
Redefining err by := operator within block makes this err variable block local.

Addressing lint:
libpod/oci.go:368:3⚠️ ineffectual assignment to err (ineffassign)

Signed-off-by: Šimon Lukašík <slukasik@redhat.com>
2018-11-10 10:52:24 +01:00
Matthew Heon 0f45403c9b Fix misspelling
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-11-07 11:36:01 -05:00
Matthew Heon 3286b0185d Retrieve container PID from conmon
Instead of running a full sync after starting a container to pick
up its PID, grab it from Conmon instead.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-11-07 11:36:01 -05:00
Matthew Heon 94763a47a6 If a container ceases to exist in runc, set exit status
When we scan a container in runc and see that it no longer
exists, we already set ContainerStatusExited to indicate that it
no longer exists in runc. Now, also set an exit code and exit
time, so PS output will make some sense.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-11-07 11:36:01 -05:00
Matthew Heon 140f87c474 EXPERIMENTAL: Do not call out to runc for sync
When syncing container state, we normally call out to runc to see
the container's status. This does have significant performance
implications, though, and we've seen issues with large amounts of
runc processes being spawned.

This patch attempts to use stat calls on the container exit file
created by Conmon instead to sync state. This massively decreases
the cost of calling updateContainer (it has gone from an
almost-unconditional fork/exec of runc to a single stat call that
can be avoided in most states).

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-11-07 11:36:01 -05:00
baude 318e33ce2c read conmon output and convert to json in two steps
when reading the output from conmon using the JSON methods, it appears that
JSON marshalling is higher in pprof than it really is because the pipe is
"waiting" for a response. this gives us a clearer look at the real CPU/time
consumers.

Signed-off-by: baude <bbaude@redhat.com>
2018-10-23 13:21:33 -05:00
Giuseppe Scrivano fc89065a80
oci: cleanup process status
I've seen a runc zombie process hanging around, it is caused by not
cleaning up the "$OCI status" process.  Also adjust another location
that has the same issue.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-10-23 09:32:44 +02:00
Daniel J Walsh 2444ac9926
Move rootless directory handling to the libpod/pkg/util directory
This should allow us to share this code with buildah.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-22 09:43:59 -04:00
OpenShift Merge Robot 094b8b7350
Merge pull request #1570 from giuseppe/fix-gvisor
podman: allow usage of gVisor as OCI runtime
2018-10-04 13:24:57 -07:00
Adrian Reber f7c8fd8a3d
Add support to checkpoint/restore containers
runc uses CRIU to support checkpoint and restore of containers. This
brings an initial checkpoint/restore implementation to podman.

None of the additional runc flags are yet supported and container
migration optimization (pre-copy/post-copy) is also left for the future.

The current status is that it is possible to checkpoint and restore a
container. I am testing on RHEL-7.x and as the combination of RHEL-7 and
CRIU has seccomp troubles I have to create the container without
seccomp.

With the following steps I am able to checkpoint and restore a
container:

 # podman run --security-opt="seccomp=unconfined" -d registry.fedoraproject.org/f27/httpd
 # curl -I 10.22.0.78:8080
 HTTP/1.1 403 Forbidden # <-- this is actually a good answer
 # podman container checkpoint <container>
 # curl -I 10.22.0.78:8080
 curl: (7) Failed connect to 10.22.0.78:8080; No route to host
 # podman container restore <container>
 # curl -I 10.22.0.78:8080
 HTTP/1.1 403 Forbidden

I am using CRIU, runc and conmon from git. All required changes for
checkpoint/restore support in podman have been merged in the
corresponding projects.

To have the same IP address in the restored container as before
checkpointing, CNI is told which IP address to use.

If the saved network configuration cannot be found during restore, the
container is restored with a new IP address.

For CRIU to restore established TCP connections the IP address of the
network namespace used for restore needs to be the same. For TCP
connections in the listening state the IP address can change.

During restore only one network interface with one IP address is handled
correctly. Support to restore containers with more advanced network
configuration will be implemented later.

v2:
 * comment typo
 * print debug messages during cleanup of restore files
 * use createContainer() instead of createOCIContainer()
 * introduce helper CheckpointPath()
 * do not try to restore a container that is paused
 * use existing helper functions for cleanup
 * restructure code flow for better readability
 * do not try to restore if checkpoint/inventory.img is missing
 * git add checkpoint.go restore.go

v3:
 * move checkpoint/restore under 'podman container'

v4:
 * incorporated changes from latest reviews

Signed-off-by: Adrian Reber <areber@redhat.com>
2018-10-03 21:41:39 +02:00
Giuseppe Scrivano c5546729b8
oci: split the stdout and stderr pipes
read the OCI status from stdout, not the combined stdout+stderr
stream.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-10-03 21:39:35 +02:00
Giuseppe Scrivano c21e85e5f4
oci: always set XDG_RUNTIME_DIR
Fix an issue when using gVisor that couldn't start the container since
the XDG_RUNTIME_DIR env variable used for the "create" and "start"
commands is different.  Set the environment variable for each command
so that the OCI runtime gets always the same value.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-10-03 21:39:34 +02:00
OpenShift Merge Robot a3c4ce6717
Merge pull request #1531 from mheon/add_exited_state
Add ContainerStateExited and OCI delete() in cleanup()
2018-10-03 06:06:14 -07:00
Matthew Heon b7c5fa70ab Fix Wait() to allow Exited state as well as Stopped
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-10-02 14:26:19 -04:00
baude 4f825f2e07 Add container runlabel command
Execute the command as described by a container image.  The value of the label is processed
into a command by:

1. Ensuring the first argument of the command is podman.
2. Substituting any variables with those defined by the environment or otherwise.

If no label exists in the container image, nothing is done.

podman container runlabel LABEL IMAGE extra_args
Signed-off-by: baude <bbaude@redhat.com>
2018-09-28 14:14:13 -05:00