sqlite: AddContainerExitCode: allow to replace

Allow to replace existing exit codes.  A container may be started and
stopped multiple times etc.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-02-23 11:30:46 +01:00
parent 1b1cdfa357
commit 565bb56454

View File

@ -855,7 +855,7 @@ func (s *SQLiteState) AddContainerExitCode(id string, exitCode int32) (defErr er
}
}()
if _, err := tx.Exec("INSERT INTO ContainerExitCode VALUES (?, ?, ?);", id, time.Now().Unix(), exitCode); err != nil {
if _, err := tx.Exec("INSERT OR REPLACE INTO ContainerExitCode VALUES (?, ?, ?);", id, time.Now().Unix(), exitCode); err != nil {
return fmt.Errorf("adding container %s exit code %d: %w", id, exitCode, err)
}