sqlite: exit code: allow -1

The value of -1 is used when we do not _yet_ know the exit code of the
container.  Otherwise, the DB checks would error.  There's probably a
smarter than allowing -1 but for now, that will do the trick and let the
tests progress.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-02-23 10:16:30 +01:00
parent e74f7bcaf3
commit 7c11f7e174
2 changed files with 3 additions and 3 deletions

View File

@ -856,7 +856,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 INTO ContainerExitCode VALUES (?, ?, ?);", id, time.Now().Unix(), exitCode); err != nil {
return fmt.Errorf("adding container %s exit code: %w", id, err) return fmt.Errorf("adding container %s exit code %d: %w", id, exitCode, err)
} }
if err := tx.Commit(); err != nil { if err := tx.Commit(); err != nil {

View File

@ -86,7 +86,7 @@ func sqliteInitTables(conn *sql.DB) (defErr error) {
ExitCode INTEGER, ExitCode INTEGER,
JSON TEXT NOT NULL, JSON TEXT NOT NULL,
FOREIGN KEY (ID) REFERENCES ContainerConfig(ID) DEFERRABLE INITIALLY DEFERRED, FOREIGN KEY (ID) REFERENCES ContainerConfig(ID) DEFERRABLE INITIALLY DEFERRED,
CHECK (ExitCode BETWEEN 0 AND 255) CHECK (ExitCode BETWEEN -1 AND 255)
);` );`
const containerExecSession = ` const containerExecSession = `
@ -120,7 +120,7 @@ func sqliteInitTables(conn *sql.DB) (defErr error) {
ID TEXT PRIMARY KEY NOT NULL, ID TEXT PRIMARY KEY NOT NULL,
Timestamp INTEGER NOT NULL, Timestamp INTEGER NOT NULL,
ExitCode INTEGER NOT NULL, ExitCode INTEGER NOT NULL,
CHECK (ExitCode BETWEEN 0 AND 255) CHECK (ExitCode BETWEEN -1 AND 255)
);` );`
const podConfig = ` const podConfig = `