mirror of
https://github.com/containers/podman.git
synced 2025-08-06 03:19:52 +08:00
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
This commit is contained in:
@ -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 != "" {
|
||||
|
Reference in New Issue
Block a user