mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Add network namespaces to SQL state
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #109 Approved by: mheon
This commit is contained in:
@ -200,6 +200,7 @@ func prepareDB(db *sql.DB) (err error) {
|
||||
ExitCode INTEGER NOT NULL,
|
||||
OomKilled INTEGER NOT NULL,
|
||||
Pid INTEGER NOT NULL,
|
||||
NetNSPath TEXT NOT NULL,
|
||||
CHECK (State>0),
|
||||
CHECK (OomKilled IN (0, 1)),
|
||||
FOREIGN KEY (Id) REFERENCES containers(Id) DEFERRABLE INITIALLY DEFERRED
|
||||
@ -296,6 +297,7 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string, lockDir
|
||||
exitCode int32
|
||||
oomKilled int
|
||||
pid int
|
||||
netNSPath string
|
||||
)
|
||||
|
||||
err := row.Scan(
|
||||
@ -323,7 +325,8 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string, lockDir
|
||||
&finishedTimeString,
|
||||
&exitCode,
|
||||
&oomKilled,
|
||||
&pid)
|
||||
&pid,
|
||||
&netNSPath)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, ErrNoSuchCtr
|
||||
@ -394,6 +397,15 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string, lockDir
|
||||
}
|
||||
ctr.state.FinishedTime = finishedTime
|
||||
|
||||
// Join the network namespace, if there is one
|
||||
if netNSPath != "" {
|
||||
netNS, err := joinNetNS(netNSPath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error joining network namespace for container %s", id)
|
||||
}
|
||||
ctr.state.NetNS = netNS
|
||||
}
|
||||
|
||||
ctr.valid = true
|
||||
ctr.runtime = runtime
|
||||
|
||||
|
Reference in New Issue
Block a user