Commit graph

51 commits

Author SHA1 Message Date
Matthew Heon d4b2f11601 Convert pods to SHM locks
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2019-01-04 09:51:09 -05:00
baude 690c52a113 Allow users to expose ports from the pod to the host
we need to allow users to expose ports to the host for the purposes
of networking, like a webserver.  the port exposure must be done at
the time the pod is created.

strictly speaking, the port exposure occurs on the infra container.

Signed-off-by: baude <bbaude@redhat.com>
2018-11-20 09:49:34 -06:00
Matthew Heon 714dbbda9e Swap from FFJSON to easyjson
FFJSON has serialization differences versus stock Go - namely, it
does not respect the MarshalText() and UnmarshalText() methods,
particularly on []byte, which causes incompatability with
pre-FFJSON containers which contained DNS servers.

EasyJSON does not have these issues, and might even be slightly
faster.

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

Closes: #1322
Approved by: mheon
2018-08-24 19:19:43 +00:00
haircommander 0e6266858a Fixing network ns segfault
As well as small style corrections, update pod_top_test to use CreatePod, and move handling of adding a container to the pod's namespace from container_internal_linux to libpod/option.

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1187
Approved by: mheon
2018-08-23 18:16:28 +00:00
haircommander 2a7449362f Change pause container to infra container
Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1187
Approved by: mheon
2018-08-23 18:16:28 +00:00
haircommander 697b46430a Support pause containers in varlink
Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1187
Approved by: mheon
2018-08-23 18:16:28 +00:00
haircommander d5e690914d Added option to share kernel namespaces in libpod and podman
A pause container is added to the pod if the user opts in. The default pause image and command can be overridden. Pause containers are ignored in ps unless the -a option is present. Pod inspect and pod ps show shared namespaces and pause container. A pause container can't be removed with podman rm, and a pod can be removed if it only has a pause container.

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1187
Approved by: mheon
2018-08-23 18:16:28 +00:00
haircommander 63dd200e7e Changed GetContainerStats to return ErrCtrStateInvalid
This results in some functionality changes:

If a ErrCtrStateInvalid is returned to GetPodStats, the container is ommitted from the stats.
As such, if an empty slice of Container stats are returned to GetPodStats in varlink, an error will occur.
GetContainerStats will return the ErrCtrStateInvalid as well.
Finally, if ErrCtrStateInvalid is returned to the podman stats call, the container will be ommitted from the stats.

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1319
Approved by: baude
2018-08-23 15:58:08 +00:00
baude bf741b3ea3 podman pod stats
add the ability to monitor container statistics in a pod.

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

Closes: #1265
Approved by: rhatdan
2018-08-17 07:55:36 +00:00
Matthew Heon 3ef9279cec Ensure pod inspect is locked and validity-checked
Also, don't return the internal podState struct - instead return
a public inspect struct.

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

Closes: #1258
Approved by: rhatdan
2018-08-11 18:13:06 +00:00
Matthew Heon ccbaa15de1 Split pod.go into 3 files
This removes anything but structs and simple accessors from
pod.go itself, which is a target file for FFJSON generation. This
should reduce the amount of times FFJSON needs to run.

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

Closes: #1247
Approved by: rhatdan
2018-08-10 18:14:31 +00:00
baude 06fafe4cd0 add podman pod inspect
first pass of podman pod inspect

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

Closes: #1236
Approved by: rhatdan
2018-08-09 11:06:32 +00:00
Matthew Heon 1a439f9fcb Ensure container and pod refresh picks up a State
refresh() is the only major command we had that did not perform a
sync before running, and thus was not guaranteed to pick up a
good copy of the state. Fix this by updating the state before a
refresh().

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

Closes: #1186
Approved by: rhatdan
2018-07-31 14:19:50 +00:00
Matthew Heon f4120f9662 Add additional comments on accessing state in API
The new state changes are potentially confusing to people writing
API functions on containers or pods. Add comments to the structs
on how to safely use them.

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

Closes: #1186
Approved by: rhatdan
2018-07-31 14:19:50 +00:00
haircommander f258e43c7c Add pod pause/unpause
Added Pause() and Unpause() to libpod/pod.go

Added man pages, tests and completions

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1126
Approved by: rhatdan
2018-07-27 14:20:08 +00:00
haircommander 8ce0e0b246 Added pod restart
With tests, man page and completions.

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1152
Approved by: rhatdan
2018-07-25 17:54:27 +00:00
haircommander 7789284cbe Added pod.Restart() functionality to libpod.
Moved contents of RestartWithTimeout to restartWithTimeout in container_internal to be able to call restart without locking in function.
Refactored startNode to be able to either start or restart a node.
Built pod Restart() with new startNode with refresh true.

Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1152
Approved by: rhatdan
2018-07-25 17:54:27 +00:00
Matthew Heon 2445787336 Add container and pod namespaces to configs
Libpod namespaces are a way to logically separate groups of pods
and containers within the state.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
2018-07-24 16:12:31 -04:00
haircommander a2dde5a50d Added created time to pod state
Signed-off-by: haircommander <pehunt@redhat.com>

Closes: #1079
Approved by: rhatdan
2018-07-12 22:13:52 +00:00
Matthew Heon c3602075ec Make CGroups cleanup optional on whether they exist
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #981
Approved by: baude
2018-06-22 19:26:46 +00:00
haircommander 0699b39793 Added a defer to an Unlock that immediately followed a Lock
Signed-off-by: haircommander <pehunt@redhat.com>
2018-06-05 16:07:35 -04:00
Matthew Heon 7e1ea9d26d Add per-pod CGroups
Pods can now create their own (cgroupfs) cgroups which containers
in them can (optionally) use.

This presently only works with CGroupFS, systemd cgroups are
still WIP

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

Closes: #784
Approved by: rhatdan
2018-05-17 23:10:12 +00:00
Matthew Heon 018d2c6b1d Add pod state
Add a mutable state to pods, and database backend sutable for
modifying and updating said state.

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

Closes: #784
Approved by: rhatdan
2018-05-17 23:10:12 +00:00
umohnani8 27107fdac1 Vendor in latest containers/image and contaners/storage
Made necessary changes to functions to include contex.Context wherever needed

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #640
Approved by: baude
2018-04-19 14:08:47 +00:00
Matthew Heon 49f9397217 Do not lock all containers during pod kill
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #600
Approved by: rhatdan
2018-04-12 03:48:40 +00:00
Matthew Heon 8b67fbb3f2 Make pod stop lock one container at a time
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #600
Approved by: rhatdan
2018-04-12 03:48:40 +00:00
Matthew Heon 542f8fe98d Do not lock all containers during pod start
This solves a nasty locking issue with getting the path of
namespaces for dependencies

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

Closes: #600
Approved by: rhatdan
2018-04-12 03:48:40 +00:00
Matthew Heon 98b19aeb0c Refactor dependency checks from init() into public API
Instead of checking during init(), which could result in major
locking issues when used with pods, make our dependency checks in
the public API instead. This avoids doing them when we start pods
(where, because of the dependency graph, we can reasonably say
all dependencies are up before we start a container).

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

Closes: #577
Approved by: rhatdan
2018-04-03 14:57:16 +00:00
Matthew Heon 4ea493d5a1 Only start containers that are not running in pod start
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #557
Approved by: rhatdan
2018-03-29 02:18:45 +00:00
Matthew Heon 73e13cf688 Change pod Start() to use container dependency graph
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #557
Approved by: rhatdan
2018-03-29 02:18:45 +00:00
Daniel J Walsh c54816dfc3 Check for duplicate names when generating new container and pod names.
This fixes the situation where we fail to create a container when a name already exists.

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

Closes: #517
Approved by: baude
2018-03-29 01:55:20 +00:00
Matthew Heon 55f2f58145 Add StartAndAttach() API endpoint for containers
This solves our prior problems with attach races by ensuring the
order is correct.

Also contains substantial cleanups to the attach code.

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

Closes: #482
Approved by: baude
2018-03-15 17:45:11 +00:00
Matthew Heon 02a26c2934 Implement container restarting
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #482
Approved by: baude
2018-03-15 17:45:11 +00:00
Matthew Heon edbfb53354 Remove extra pod Start code
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #478
Approved by: rhatdan
2018-03-13 13:54:45 +00:00
Matthew Heon 40d302be8f Modify pod API to move Init() into Start()
Separate Init() and Start() does not make sense on the pod side,
where we may have to start containers in order to initialize
others due to dependency orders.

Also adjusts internal containers API for more code sharing.

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

Closes: #478
Approved by: rhatdan
2018-03-13 13:54:45 +00:00
Matthew Heon 7a7a6c2d79 Remove unnecessary booleans
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #361
Approved by: rhatdan
2018-02-22 14:49:36 +00:00
Matthew Heon cef3979203 Fix gofmt
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #361
Approved by: rhatdan
2018-02-22 14:49:36 +00:00
Matthew Heon 8ce7c5bdd1 Make operations on pod containers as a group independent
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #361
Approved by: rhatdan
2018-02-22 14:49:36 +00:00
Matthew Heon 7c51fa05a2 Fix gofmt
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #361
Approved by: rhatdan
2018-02-22 14:49:36 +00:00
Matthew Heon 0838c2b984 Add ability to start containers in a pod
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #361
Approved by: rhatdan
2018-02-22 14:49:36 +00:00
Matthew Heon 86930c829e Add kill and stop for pods
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #361
Approved by: rhatdan
2018-02-22 14:49:36 +00:00
Matthew Heon 0b4c8fc2bb Add pod status command
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #361
Approved by: rhatdan
2018-02-22 14:49:36 +00:00
Matthew Heon f2041b51f3 Add FFJSON encoding/decoding for our container structs
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #323
Approved by: mheon
2018-02-16 16:46:09 +00:00
Matthew Heon 4f225b47c9 Refactor Pod to use a Config struct
This allows us to JSON it and stuff it in the DB - previously,
all pod fields were private, so JSON couldn't encode them. This
allows us to keep all pod fields private by having a substruct
with public fields.

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

Closes: #184
Approved by: baude
2018-02-12 14:28:07 +00:00
Matthew Heon aa85ae212e Add pod functions to BoltDB state
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #184
Approved by: baude
2018-02-12 14:28:07 +00:00
Matthew Heon cb28a1d284 Fix bugs identified by unit tests
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #268
Approved by: rhatdan
2018-02-09 15:01:34 +00:00
Matthew Heon 4ecebf20b4 Rework state tests to avoid boilerplate. Begin adding pod tests.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #268
Approved by: rhatdan
2018-02-09 15:01:34 +00:00
Matthew Heon 6214be07c2 Tear out pod containers map. Instead rely on state
This ensures that there is only one canonical place where
containers in a pod are stored, in the state itself.

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

Closes: #268
Approved by: rhatdan
2018-02-09 15:01:34 +00:00
Matthew Heon bf0d359047 Remove lock existence checks when creating pods/containers
Given that we don't have a good way of cleaning up locks, these
could potential cause issues if we ever reuse a container or pod
ID

Also changes locks dir to use tmpfs, as we can't directly clean
up locks

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

Closes: #138
Approved by: rhatdan
2017-12-14 18:18:16 +00:00
Matthew Heon 6d29768864 Update pods to use file locks
Also includes misc other fixes - adding labels, fixing pod names

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

Closes: #138
Approved by: rhatdan
2017-12-14 18:18:16 +00:00