Commit graph

152 commits

Author SHA1 Message Date
Matthew Heon b01ddc7b09 Pass newly-added --log-level flag to Conmon
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #1232
Approved by: rhatdan
2018-08-08 19:23:41 +00:00
Giuseppe Scrivano cfcd928476 network: add support for rootless network with slirp4netns
slirp4netns is required to setup the network namespace:

https://github.com/rootless-containers/slirp4netns

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1156
Approved by: rhatdan
2018-07-31 13:39:29 +00:00
Giuseppe Scrivano 9ae7b1a5b1 oci: keep exposed ports busy and leak the fd into conmon
Bind all the specified TCP and UDP ports so that another process
cannot reuse them.  The fd of the listener is then leaked into conmon
so that the socket is kept busy until the container exits.

Closes: https://github.com/projectatomic/libpod/issues/210

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1100
Approved by: mheon
2018-07-19 13:21:50 +00:00
Matthew Heon 028374b99e Record whether the container has exited
Use this to supplement exit codes returned from containers, to
make sure we know when exit codes are invalid (as the container
has not yet exited)

Signed-off-by: Matthew Heon <mheon@redhat.com>
2018-07-13 14:28:41 -04:00
Giuseppe Scrivano 340becf542
rootless: propagate errors from GetRootlessRuntimeDir()
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2018-07-11 09:38:04 +02:00
W. Trevor King b2344b83ed pkg/ctime: Factor libpod/finished* into a separate package
This removes some boilerplate from the libpod package, so we can focus
on container stuff there.  And it gives us a tidy sub-package for
focusing on ctime extraction, so we can focus on unit testing and
portability of the extraction utility there.

For the unsupported implementation, I'm falling back to Go's ModTime
[1].  That's obviously not the creation time, but it's likely to be
closer than the uninitialized Time structure from cc6f0e85 (more
changes to compile darwin, 2018-07-04, #1047).  Especially for our use
case in libpod/oci, where we're looking at write-once exit files.

The test is more complicated than I initially expected, because on
Linux filesystem timestamps come from a truncated clock without
interpolation [2] (and network filesystems can be completely decoupled
[3]).  So even for local disks, creation times can be up to a jiffie
earlier than 'before'.  This test ensures at least monotonicity by
creating two files and ensuring the reported creation time for the
second is greater than or equal to the reported creation time for the
first.  It also checks that both creation times are within the window
from one second earlier than 'before' through 'after'.  That should be
enough of a window for local disks, even if the kernel for those
systems has an abnormally large jiffie.  It might be ok on network
filesystems, although it will not be very resilient to network clock
lagging behind the local system clock.

[1]: https://golang.org/pkg/os/#FileInfo
[2]: https://groups.google.com/d/msg/linux.kernel/mdeXx2TBYZA/_4eJEuJoAQAJ
     Subject: Re: Apparent backward time travel in timestamps on file creation
     Date: Thu, 30 Mar 2017 20:20:02 +0200
     Message-ID: <tqMPU-1Sb-21@gated-at.bofh.it>
[3]: https://groups.google.com/d/msg/linux.kernel/mdeXx2TBYZA/cTKj4OBuAQAJ
     Subject: Re: Apparent backward time travel in timestamps on file creation
     Date: Thu, 30 Mar 2017 22:10:01 +0200
     Message-ID: <tqOyl-36A-1@gated-at.bofh.it>

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1050
Approved by: mheon
2018-07-06 17:54:32 +00:00
baude cc6f0e85f9 more changes to compile darwin
this should represent the last major changes to get darwin to **compile**.  again,
the purpose here is to get darwin to compile so that we can eventually implement a
ci task that would protect against regressions for darwin compilation.

i have left the manual darwin compilation largely static still and in fact now only
interject (manually) two build tags to assist with the build.  trevor king has great
ideas on how to make this better and i will defer final implementation of those
to him.

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

Closes: #1047
Approved by: rhatdan
2018-07-05 16:05:12 +00:00
Giuseppe Scrivano 77758a6c9f rootless: set XDG_RUNTIME_DIR also for state and exec
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1048
Approved by: mheon
2018-07-05 13:30:15 +00:00
baude b96be3af1b changes to allow for darwin compilation
Signed-off-by: baude <bbaude@redhat.com>

Closes: #1015
Approved by: baude
2018-06-29 20:44:09 +00:00
Daniel J Walsh 7fc1a329bd Add podman container cleanup to CLI
When we run containers in detach mode, nothing cleans up the network stack or
the mount points.  This patch will tell conmon to execute the cleanup code when
the container exits.

It can also be called to attempt to cleanup previously running containers.

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

Closes: #942
Approved by: mheon
2018-06-29 15:25:21 +00:00
Daniel J Walsh c9eddd22eb conmon no longer writes to syslog
If the caller sets up the app to be in logrus.DebugLevel,
then we will add the --syslog flag to conmon to get all of the
messages.

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

Closes: #1014
Approved by: TomSweeneyRedHat
2018-06-29 08:22:27 +00:00
Giuseppe Scrivano 4415bad6fe oci: set XDG_RUNTIME_DIR to the runtime from GetRootlessRuntimeDir()
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #936
Approved by: rhatdan
2018-06-27 14:07:17 +00:00
Giuseppe Scrivano 399c3a5e4b oci: do not set the cgroup path in Rootless mode
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Giuseppe Scrivano ca03627a80 oci: pass XDG_RUNTIME_DIR down to the OCI runtime
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #871
Approved by: mheon
2018-06-15 14:53:18 +00:00
Daniel J Walsh dedc7cc329 Remove SELinux transition rule after conmon is started.
We have an issue where iptables command is being executed by podman
and attempted to run with a different label. This fix changes podman
to only change the label on the conmon command and then set the
SELinux interface back to the default.

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

Closes: #906
Approved by: giuseppe
2018-06-06 18:23:37 +00:00
Daniel J Walsh d6b8f62dd6 Catch does not exist error
There was a new line at the end of does not exist
which was causing this to fail.

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

Closes: #863
Approved by: baude
2018-05-31 19:28:00 +00:00
Daniel J Walsh 7c6034e161 We need to change the SELinux label of the conmon process to s0
If SELinux is enabled, we are leaking in pipes into the container
owned by conmon.  The container processes are not allowed to use
these pipes, if the calling process is fully ranged.  By changing
the level of the conmon process to s0, this allows container processes
to use the pipes.

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

Closes: #854
Approved by: mheon
2018-05-31 13:51:11 +00:00
Matthew Heon 20bceb787d Use container cleanup() functions when removing
Instead of manually calling the individual functions that cleanup
uses to tear down a container's resources, just call the cleanup
function to make sure that cleanup only needs to happen in one
place.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #790
Approved by: rhatdan
2018-05-17 18:55:59 +00:00
Matthew Heon b70f6cc04a Place Conmon and Container in separate CGroups
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #507
Approved by: baude
2018-05-11 14:43:57 +00:00
Matthew Heon 853c5c41f1 Add --cgroup-manager flag to Podman binary
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #507
Approved by: baude
2018-05-11 14:43:57 +00:00
Matthew Heon df83d361e4 Major fixes to systemd cgroup handling
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #507
Approved by: baude
2018-05-11 14:43:57 +00:00
Daniel J Walsh bb0e7540dc Should not error out if container no longer exists in oci
This prevents you from cleaning up the container database, if
some how runc and friends db gets screwed up.

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

Closes: #725
Approved by: mheon
2018-05-04 20:09:17 +00:00
Giuseppe Scrivano 522a7197a8 podman, userNS: configure an intermediate mount namespace
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #690
Approved by: mheon
2018-05-04 17:15:55 +00:00
Matthew Heon eb0d5dfff1 Prevent a potential race when stopping containers
If sending a signal fails, check if the container is alive. If it
is not, it probably stopped on its own before we could send the
signal, so don't error out.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #591
Approved by: rhatdan
2018-04-04 01:09:23 +00:00
Giuseppe Scrivano f936b745b6 podman: new option --conmon-pidfile=
so that it is possible to use systemd to automatically restart the
container:

[Service]
Type=forking
PIDFile=/run/awesome-service.pid
ExecStart=/usr/bin/podman run --conmon-pidfile=/run/awesome-service.pid --name awesome -d IMAGE /usr/bin/do-something
ExecStopPost=/usr/bin/podman rm awesome
Restart=always

Closes: https://github.com/projectatomic/libpod/issues/534

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #549
Approved by: rhatdan
2018-03-29 01:34:41 +00:00
Matthew Heon 29d650a379 Include error in error message
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #438
Approved by: rhatdan
2018-03-02 16:34:20 +00:00
Matthew Heon 3639859622 Instead of erroring on exit file not being found, warn
Erroring can cause us to get into an state where a container
which has no exit file cannot be shown in PS, cannot be removed,
etc.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #438
Approved by: rhatdan
2018-03-02 16:34:20 +00:00
Matthew Heon c5dc7f81fc Replace usage of runc with runtime
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
Matthew Heon fa5f99effa Convert exec session tracking to use a dedicated struct
This will behave better if we need to add anything to it at a
later date - we can add fields to the struct without breaking
existing BoltDB databases.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
Matthew Heon f02a9cd975 Handle removing containers with active exec sessions
For containers without --force set, an error will be returned

For containers with --force, all pids in the container will be
stopped, first with SIGTERM and then with SIGKILL after a timeout
(this mimics the behavior of stopping a container).

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
Matthew Heon 8b87a17f56 Add tracking for exec session IDs
Exec sessions now have an ID generated and assigned to their PID
and stored in the database state. This allows us to track what
exec sessions are currently active.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:51 +00:00
Matthew Heon 345bfafee2 Rework exec to enable splitting to retrieve exec PID
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #412
Approved by: baude
2018-03-01 21:17:50 +00:00
Matthew Heon 8eb5cf7489 Ensure we don't repeatedly poll disk for exit codes
Change logic for refreshing our state using runc to only poll
for conmon exit files when we first transition to the Stopped
state. After that, we should already have the exit code stored in
the database, so we don't need to look it up again.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #363
Approved by: TomSweeneyRedHat
2018-02-20 14:54:13 +00:00
Matthew Heon e47c2e390a
Merge pull request #293 from rhatdan/sd_notify
Need to add LISTEN_PID environment variable to conmon command
2018-02-07 18:59:50 -05:00
Matthew Heon d20c1a9911 Change stop signal default to SIGTERM
Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #299
Approved by: rhatdan
2018-02-06 19:03:57 +00:00
Daniel J Walsh d1c0c42a08 Need to add LISTEN_PID environment variable to conmon command
Without this field then conmon will not pass the proper data down to
the OCI Runtime.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-02-05 16:35:43 -05:00
Daniel J Walsh 989f5e3062 Pass NOTIFY_SOCKET and LISTEN_FDS env to OCI RUntime if set
In order to have sd_notify from systemd to work in containers
we need to pass down the NOTIFY_SOCKET environment variable to
the container.

LISTEN_FDS, tells the application inside of the container to use
socket activation and grab the FDS that are leaked into the container.

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

Closes: #271
Approved by: umohnani8
2018-02-05 15:39:40 +00:00
Daniel J Walsh 095aaaa639 Allow users to specify logpath
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #135
Approved by: mheon
2018-02-03 19:49:14 +00:00
baude a03e040f0b libpod/oci.go: Perf issue
Matt Heon and I found that a defer statement was costing podman
run dearly.  We dont think the defer function was working (nor
needed) and was timing out as well.  Removing this defer statement
decreased podman runtime by 1.5s or more.

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

Closes: #253
Approved by: baude
2018-01-23 14:20:41 +00:00
Daniel J Walsh 1f49f555af Plumb through the --stop-timeout signal handling
podman run/create have the ability to set the stop timeout flag.
We need to stop it in the database.

Also Allowing negative time for stop timeout makes no sense, so switching
to timeout of uint, allows user to specify huge timeout values.

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

Closes: #158
Approved by: TomSweeneyRedHat
2017-12-20 18:10:43 +00:00
Daniel J Walsh 915410aaff
Merge pull request #111 from mheon/crio_1206
Carry CRI-O #1206 to fix a potential runtime issue
2017-12-11 10:44:57 -06:00
baude e8a32e3722 kpod exec
Initial wiring of kpod exec. We wont support the following options
for exec:

* detach -- unsure of use case
* detach-keys -- not supported by runc
* interactive -- all terminals will be interactive

Not adding exec tests as we need to think about how to support a
test that requires console access but our CI tests have no console.

Signed-off-by: baude <bbaude@redhat.com>
2017-12-11 08:24:30 -06:00
Matthew Heon 00df767a99 Carry CRI-O #1206 to fix a potential runtime issue
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2017-12-07 14:44:21 -05:00
Daniel J Walsh adf8809521 Add NetMode, UTSMode and IPCMode
Allow kpod create/run to create contianers in different network namespaces, uts namespaces and
IPC Namespaces.

This patch just handles the simple join the host, or another containers namespaces.

Lots more work needed to full integrate  --net

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

Closes: #64
Approved by: mheon
2017-12-02 15:32:56 +00:00
Matthew Heon 13e833a388 Change location of created runc specs to make them survive reboot
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #78
Approved by: rhatdan
2017-11-29 18:43:56 +00:00
Matthew Heon 831e2c30d4 Add ability to kill and stop containers
Also migrates kpod kill and kpod stop to libpod to use the new code

Fixes force removing containers, and actually deletes containers in runc when
removing them

Start is now capable of starting even when the container is unmounted

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #68
Approved by: rhatdan
2017-11-29 12:15:15 +00:00
umohnani8 b1a3b03068 Update kpod pause and unpause to use new container state
Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #66
Approved by: mheon
2017-11-24 15:53:17 +00:00
Matthew Heon 152882bf19 Add ability to retrieve container's log path to API
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #56
Approved by: rhatdan
2017-11-21 20:09:09 +00:00
Matthew Heon 8e76ebcf6e Add ability to update container status from runc
Wire this in to all state-bound container operations to ensure
syncronization of container state.

Also exposes PID of running containers via API.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #56
Approved by: rhatdan
2017-11-21 20:09:09 +00:00
baude d2eda1a864 Enhancements to papr tests
The PR contains several enhancements to our CI testing.

- enable lint testing on Fedora
- add Centos Atomic as test platform
- integration tests on run on the OS natively (uncontainerized)
- builds are done in containers
- inclusion of Vagrant file for local testing

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

Closes: #18
Approved by: mheon
2017-11-17 02:07:18 +00:00
Matthew Heon c13f61798a Prune Server package. Convert to new github location.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2017-11-01 13:22:04 -04:00
Matthew Heon a031b83a09 Initial checkin from CRI-O repo
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2017-11-01 11:24:59 -04:00