summaryrefslogtreecommitdiff
path: root/libpod/sql_state_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-21 13:44:22 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-11-21 20:09:09 +0000
commit8e76ebcf6e8925d5fa6a8c9ab517d665b44c7b63 (patch)
treecd9c15e37a00927ccd8c31b3cde40f46fe82b736 /libpod/sql_state_internal.go
parent7b736e333315e6f533b9677712a0c2e037cc293b (diff)
downloadpodman-8e76ebcf6e8925d5fa6a8c9ab517d665b44c7b63.tar.gz
podman-8e76ebcf6e8925d5fa6a8c9ab517d665b44c7b63.tar.bz2
podman-8e76ebcf6e8925d5fa6a8c9ab517d665b44c7b63.zip
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
Diffstat (limited to 'libpod/sql_state_internal.go')
-rw-r--r--libpod/sql_state_internal.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/libpod/sql_state_internal.go b/libpod/sql_state_internal.go
index 698b0433c..b6816e008 100644
--- a/libpod/sql_state_internal.go
+++ b/libpod/sql_state_internal.go
@@ -61,7 +61,10 @@ func prepareDB(db *sql.DB) (err error) {
StartedTime TEXT NUT NULL,
FinishedTime TEXT NOT NULL,
ExitCode INTEGER NOT NULL,
+ OomKilled INTEGER NOT NULL,
+ Pid INTEGER NOT NULL,
CHECK (State>0),
+ CHECK (OomKilled IN (0, 1)),
FOREIGN KEY (Id) REFERENCES containers(Id) DEFERRABLE INITIALLY DEFERRED
);
`
@@ -149,6 +152,8 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string) (*Contai
startedTimeString string
finishedTimeString string
exitCode int32
+ oomKilled int
+ pid int
)
err := row.Scan(
@@ -169,7 +174,9 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string) (*Contai
&mountpoint,
&startedTimeString,
&finishedTimeString,
- &exitCode)
+ &exitCode,
+ &oomKilled,
+ &pid)
if err != nil {
if err == sql.ErrNoRows {
return nil, ErrNoSuchCtr
@@ -197,6 +204,8 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string) (*Contai
ctr.state.RunDir = runDir
ctr.state.Mountpoint = mountpoint
ctr.state.ExitCode = exitCode
+ ctr.state.OOMKilled = boolFromSQL(oomKilled)
+ ctr.state.PID = pid
// TODO should we store this in the database separately instead?
if ctr.state.Mountpoint != "" {