diff options
Diffstat (limited to 'libpod/sql_state.go')
-rw-r--r-- | libpod/sql_state.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/libpod/sql_state.go b/libpod/sql_state.go index cf759d836..abf48543f 100644 --- a/libpod/sql_state.go +++ b/libpod/sql_state.go @@ -14,7 +14,7 @@ import ( // DBSchema is the current DB schema version // Increments every time a change is made to the database's tables -const DBSchema = 11 +const DBSchema = 12 // SQLState is a state implementation backed by a persistent SQLite3 database type SQLState struct { @@ -102,7 +102,8 @@ func (s *SQLState) Refresh() (err error) { Pid=?, NetNSPath=?, IPAddress=?, - SubnetMask=?;` + SubnetMask=?, + ExecSessions=?;` if !s.valid { return ErrDBClosed @@ -132,7 +133,8 @@ func (s *SQLState) Refresh() (err error) { 0, "", "", - "") + "", + "{}") if err != nil { return errors.Wrapf(err, "error refreshing database state") } @@ -269,7 +271,8 @@ func (s *SQLState) UpdateContainer(ctr *Container) error { Pid, NetNSPath, IPAddress, - SubnetMask + SubnetMask, + ExecSessions FROM containerState WHERE ID=?;` var ( @@ -285,6 +288,7 @@ func (s *SQLState) UpdateContainer(ctr *Container) error { netNSPath string ipAddress string subnetMask string + execSessions string ) if !s.valid { @@ -308,7 +312,8 @@ func (s *SQLState) UpdateContainer(ctr *Container) error { &pid, &netNSPath, &ipAddress, - &subnetMask) + &subnetMask, + &execSessions) if err != nil { // The container may not exist in the database if err == sql.ErrNoRows { @@ -333,6 +338,11 @@ func (s *SQLState) UpdateContainer(ctr *Container) error { newState.IPAddress = ipAddress newState.SubnetMask = subnetMask + newState.ExecSessions = make(map[string]int) + if err := json.Unmarshal([]byte(execSessions), &newState.ExecSessions); err != nil { + return errors.Wrapf(err, "error parsing container %s exec sessions", ctr.ID()) + } + if newState.Mountpoint != "" { newState.Mounted = true } @@ -395,13 +405,19 @@ func (s *SQLState) SaveContainer(ctr *Container) (err error) { Pid=?, NetNSPath=?, IPAddress=?, - SubnetMask=? + SubnetMask=?, + ExecSessions=? WHERE Id=?;` if !ctr.valid { return ErrCtrRemoved } + execSessionsJSON, err := json.Marshal(ctr.state.ExecSessions) + if err != nil { + return errors.Wrapf(err, "error marshalling container %s exec sessions", ctr.ID()) + } + netNSPath := "" if ctr.state.NetNS != nil { netNSPath = ctr.state.NetNS.Path() @@ -439,6 +455,7 @@ func (s *SQLState) SaveContainer(ctr *Container) (err error) { netNSPath, ctr.state.IPAddress, ctr.state.SubnetMask, + execSessionsJSON, ctr.ID()) if err != nil { return errors.Wrapf(err, "error updating container %s state in database", ctr.ID()) |