Skip to content

Commit

Permalink
Merge pull request #20810 from Luap99/sqlite-validate
Browse files Browse the repository at this point in the history
sqlite: fix issue in ValidateDBConfig()
  • Loading branch information
openshift-merge-bot[bot] committed Nov 28, 2023
2 parents 545daed + d7b970a commit 9627d30
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libpod/sqlite_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,6 @@ func (s *SQLiteState) ValidateDBConfig(runtime *Runtime) (defErr error) {
return fmt.Errorf("retrieving DB config: %w", err)
}

if err := tx.Commit(); err != nil {
return fmt.Errorf("committing database validation row: %w", err)
}

checkField := func(fieldName, dbVal, ourVal string) error {
if dbVal != ourVal {
return fmt.Errorf("database %s %q does not match our %s %q: %w", fieldName, dbVal, fieldName, ourVal, define.ErrDBBadConfig)
Expand Down Expand Up @@ -407,6 +403,12 @@ func (s *SQLiteState) ValidateDBConfig(runtime *Runtime) (defErr error) {
return err
}

if err := tx.Commit(); err != nil {
return fmt.Errorf("committing database validation row: %w", err)
}
// Do not return any error after the commit call because the defer will
// try to roll back the transaction which results in an logged error.

return nil
}

Expand Down

0 comments on commit 9627d30

Please sign in to comment.