Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In SQLite state, use defaults for empty-string checks #24775

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions libpod/sqlite_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,30 @@ func (s *SQLiteState) ValidateDBConfig(runtime *Runtime) (defErr error) {
return fmt.Errorf("retrieving DB config: %w", err)
}

// Sometimes, for as-yet unclear reasons, the database value ends up set
// to the empty string. If it does, this evaluation is always going to
// fail, and libpod will be unusable.
// At this point, the check is effectively meaningless - we don't
// actually know the settings we should be checking against. The best
// thing we can do (and what BoltDB did in this case) is to compare
// against the default, on the assumption that is what was in use.
// TODO: We can't remove this code without breaking existing SQLite DBs
// that already have incorrect values in the database, but we should
// investigate why this is happening and try and prevent the creation of
// new databases with these garbage checks.
if graphRoot == "" {
logrus.Debugf("Database uses empty-string graph root, substituting default %q", storeOpts.GraphRoot)
graphRoot = storeOpts.GraphRoot
}
if runRoot == "" {
logrus.Debugf("Database uses empty-string run root, substituting default %q", storeOpts.RunRoot)
runRoot = storeOpts.RunRoot
}
if graphDriver == "" {
logrus.Debugf("Database uses empty-string graph driver, substituting default %q", storeOpts.GraphDriverName)
graphDriver = storeOpts.GraphDriverName
}

checkField := func(fieldName, dbVal, ourVal string, isPath bool) error {
if isPath {
// Tolerate symlinks when possible - most relevant for OStree systems
Expand Down
Loading