Skip to content

Commit

Permalink
storage: better error for missing min version file
Browse files Browse the repository at this point in the history
We require the min version filename to open a store. If it doesn't
exist, we assume the store doesn't exist which can lead to a confusing
message if just the min version file is missing. This commit makes
this message more useful.

Informs #97337

Release note: none
Epic: none
  • Loading branch information
RaduBerinde committed Feb 21, 2023
1 parent 2036af6 commit 577da11
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/storage/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,14 @@ func NewPebble(ctx context.Context, cfg PebbleConfig) (p *Pebble, err error) {
}
opts.ErrorIfNotExists = true
} else {
if opts.ErrorIfNotExists {
return nil, errors.Errorf("pebble: database %q does not exist", cfg.StorageConfig.Dir)
if opts.ErrorIfNotExists || opts.ReadOnly {
// Make sure the message is not confusing if the store does exist but
// there is no min version file.
filename := unencryptedFS.PathJoin(cfg.Dir, MinVersionFilename)
return nil, errors.Errorf(
"pebble: database %q does not exist (missing required file %q)",
cfg.StorageConfig.Dir, filename,
)
}
// If there is no min version file, there should be no store. If there is
// one, it's either 1) a store from a very old version (which we don't want
Expand Down

0 comments on commit 577da11

Please sign in to comment.