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
This commit is contained in:
Matthew Heon
2018-02-27 22:52:28 -05:00
committed by Atomic Bot
parent 83d7ae6506
commit fa5f99effa
8 changed files with 440 additions and 49 deletions

View File

@ -307,9 +307,13 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
// We have the PID, add it to state
if c.state.ExecSessions == nil {
c.state.ExecSessions = make(map[string]int)
c.state.ExecSessions = make(map[string]*ExecSession)
}
c.state.ExecSessions[sessionID] = int(pid)
session := new(ExecSession)
session.ID = sessionID
session.Command = cmd
session.PID = int(pid)
c.state.ExecSessions[sessionID] = session
if err := c.save(); err != nil {
// Now we have a PID but we can't save it in the DB
// TODO handle this better