[#1178] shard: Check metabase existence before read shard ID
All checks were successful
DCO action / DCO (pull_request) Successful in 6m15s
Build / Build Components (1.22) (pull_request) Successful in 11m1s
Build / Build Components (1.21) (pull_request) Successful in 11m6s
Tests and linters / Staticcheck (pull_request) Successful in 16m15s
Tests and linters / gopls check (pull_request) Successful in 16m11s
Tests and linters / Lint (pull_request) Successful in 17m34s
Vulncheck / Vulncheck (pull_request) Successful in 7m47s
Pre-commit hooks / Pre-commit (pull_request) Successful in 21m25s
Tests and linters / Tests (1.21) (pull_request) Successful in 21m22s
Tests and linters / Tests with -race (pull_request) Successful in 21m51s
Tests and linters / Tests (1.22) (pull_request) Successful in 2m46s

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2024-06-17 09:47:53 +03:00
parent b9d6c9d10c
commit 76cf7a051b

View file

@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"os"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/metaerr"
metamode "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
@ -25,6 +26,10 @@ func (db *DB) GetShardID(mode metamode.Mode) ([]byte, error) {
defer db.modeMtx.Unlock()
db.mode = mode
if _, err := os.Stat(db.info.Path); errors.Is(err, os.ErrNotExist) {
return nil, nil
}
if err := db.openDB(mode); err != nil {
return nil, fmt.Errorf("failed to open metabase: %w", err)
}