[#1226] blobovniczatree: Delete fix db extensions in Init()
Some checks failed
DCO action / DCO (pull_request) Successful in 14m27s
Vulncheck / Vulncheck (pull_request) Successful in 16m45s
Build / Build Components (1.21) (pull_request) Successful in 18m53s
Build / Build Components (1.22) (pull_request) Successful in 20m30s
Tests and linters / gopls check (pull_request) Successful in 25m12s
Tests and linters / Tests (1.21) (pull_request) Failing after 27m52s
Tests and linters / Tests with -race (pull_request) Failing after 27m46s
Tests and linters / Tests (1.22) (pull_request) Failing after 28m13s
Tests and linters / Lint (pull_request) Successful in 30m25s
Tests and linters / Staticcheck (pull_request) Successful in 30m23s
Pre-commit hooks / Pre-commit (pull_request) Successful in 31m27s
Some checks failed
DCO action / DCO (pull_request) Successful in 14m27s
Vulncheck / Vulncheck (pull_request) Successful in 16m45s
Build / Build Components (1.21) (pull_request) Successful in 18m53s
Build / Build Components (1.22) (pull_request) Successful in 20m30s
Tests and linters / gopls check (pull_request) Successful in 25m12s
Tests and linters / Tests (1.21) (pull_request) Failing after 27m52s
Tests and linters / Tests with -race (pull_request) Failing after 27m46s
Tests and linters / Tests (1.22) (pull_request) Failing after 28m13s
Tests and linters / Lint (pull_request) Successful in 30m25s
Tests and linters / Staticcheck (pull_request) Successful in 30m23s
Pre-commit hooks / Pre-commit (pull_request) Successful in 31m27s
Since several releases have been released, this code is not relevant. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
78b1d9b18d
commit
62cbb72a5e
3 changed files with 0 additions and 116 deletions
|
@ -480,12 +480,6 @@ const (
|
||||||
BlobstoreRebuildStarted = "blobstore rebuild started"
|
BlobstoreRebuildStarted = "blobstore rebuild started"
|
||||||
BlobstoreRebuildCompletedSuccessfully = "blobstore rebuild completed successfully"
|
BlobstoreRebuildCompletedSuccessfully = "blobstore rebuild completed successfully"
|
||||||
BlobstoreRebuildStopped = "blobstore rebuild stopped"
|
BlobstoreRebuildStopped = "blobstore rebuild stopped"
|
||||||
BlobovniczaTreeFixingFileExtensions = "fixing blobovnicza tree file extensions..."
|
|
||||||
BlobovniczaTreeFixingFileExtensionsCompletedSuccessfully = "fixing blobovnicza tree file extensions completed successfully"
|
|
||||||
BlobovniczaTreeFixingFileExtensionsFailed = "failed to fix blobovnicza tree file extensions"
|
|
||||||
BlobovniczaTreeFixingFileExtensionForFile = "fixing blobovnicza file extension..."
|
|
||||||
BlobovniczaTreeFixingFileExtensionCompletedSuccessfully = "fixing blobovnicza file extension completed successfully"
|
|
||||||
BlobovniczaTreeFixingFileExtensionFailed = "failed to fix blobovnicza file extension"
|
|
||||||
BlobstorRebuildFailedToRebuildStorages = "failed to rebuild storages"
|
BlobstorRebuildFailedToRebuildStorages = "failed to rebuild storages"
|
||||||
BlobstorRebuildRebuildStoragesCompleted = "storages rebuild completed"
|
BlobstorRebuildRebuildStoragesCompleted = "storages rebuild completed"
|
||||||
BlobovniczaTreeCollectingDBToRebuild = "collecting blobovniczas to rebuild..."
|
BlobovniczaTreeCollectingDBToRebuild = "collecting blobovniczas to rebuild..."
|
||||||
|
|
|
@ -2,10 +2,6 @@ package blobovniczatree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||||
|
@ -14,8 +10,6 @@ import (
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errFailedToChangeExtensionReadOnly = errors.New("failed to change blobovnicza extension: read only mode")
|
|
||||||
|
|
||||||
// Open opens blobovnicza tree.
|
// Open opens blobovnicza tree.
|
||||||
func (b *Blobovniczas) Open(mode mode.ComponentMode) error {
|
func (b *Blobovniczas) Open(mode mode.ComponentMode) error {
|
||||||
b.readOnly = mode.ReadOnly()
|
b.readOnly = mode.ReadOnly()
|
||||||
|
@ -31,13 +25,6 @@ func (b *Blobovniczas) Open(mode mode.ComponentMode) error {
|
||||||
func (b *Blobovniczas) Init() error {
|
func (b *Blobovniczas) Init() error {
|
||||||
b.log.Debug(logs.BlobovniczatreeInitializingBlobovniczas)
|
b.log.Debug(logs.BlobovniczatreeInitializingBlobovniczas)
|
||||||
|
|
||||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensions)
|
|
||||||
if err := b.addDBExtensionToDBs(b.rootPath, 0); err != nil {
|
|
||||||
b.log.Error(logs.BlobovniczaTreeFixingFileExtensionsFailed, zap.Error(err))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensionsCompletedSuccessfully)
|
|
||||||
|
|
||||||
if b.readOnly {
|
if b.readOnly {
|
||||||
b.log.Debug(logs.BlobovniczatreeReadonlyModeSkipBlobovniczasInitialization)
|
b.log.Debug(logs.BlobovniczatreeReadonlyModeSkipBlobovniczasInitialization)
|
||||||
return nil
|
return nil
|
||||||
|
@ -111,37 +98,3 @@ func (b *Blobovniczas) getBlobovnicza(p string) *sharedDB {
|
||||||
func (b *Blobovniczas) getBlobovniczaWithoutCaching(p string) *sharedDB {
|
func (b *Blobovniczas) getBlobovniczaWithoutCaching(p string) *sharedDB {
|
||||||
return b.commondbManager.GetByPath(p)
|
return b.commondbManager.GetByPath(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Blobovniczas) addDBExtensionToDBs(path string, depth uint64) error {
|
|
||||||
entries, err := os.ReadDir(path)
|
|
||||||
if os.IsNotExist(err) && depth == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, entry := range entries {
|
|
||||||
if entry.IsDir() {
|
|
||||||
if err := b.addDBExtensionToDBs(filepath.Join(path, entry.Name()), depth+1); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.HasSuffix(entry.Name(), dbExtension) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if b.readOnly {
|
|
||||||
return errFailedToChangeExtensionReadOnly
|
|
||||||
}
|
|
||||||
|
|
||||||
sourcePath := filepath.Join(path, entry.Name())
|
|
||||||
targetPath := filepath.Join(path, entry.Name()+dbExtension)
|
|
||||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensionForFile, zap.String("source", sourcePath), zap.String("target", targetPath))
|
|
||||||
if err := os.Rename(sourcePath, targetPath); err != nil {
|
|
||||||
b.log.Error(logs.BlobovniczaTreeFixingFileExtensionFailed, zap.String("source", sourcePath), zap.String("target", targetPath), zap.Error(err))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
b.log.Debug(logs.BlobovniczaTreeFixingFileExtensionCompletedSuccessfully, zap.String("source", sourcePath), zap.String("target", targetPath))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,78 +2,15 @@ package blobovniczatree
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
objectCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobovnicza"
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/internal/blobstortest"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/internal/blobstortest"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDBExtensionFix(t *testing.T) {
|
|
||||||
root := t.TempDir()
|
|
||||||
createTestTree(t, 0, 2, 3, root)
|
|
||||||
t.Run("adds suffix if not exists", func(t *testing.T) {
|
|
||||||
openAndCloseTestTree(t, 2, 3, root)
|
|
||||||
validateTestTree(t, root)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("not adds second suffix if exists", func(t *testing.T) {
|
|
||||||
openAndCloseTestTree(t, 2, 3, root)
|
|
||||||
validateTestTree(t, root)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func createTestTree(t *testing.T, currentDepth, depth, width uint64, path string) {
|
|
||||||
if currentDepth == depth {
|
|
||||||
var w uint64
|
|
||||||
for ; w < width; w++ {
|
|
||||||
dbPath := filepath.Join(path, u64ToHexString(w))
|
|
||||||
b := blobovnicza.New(blobovnicza.WithPath(dbPath))
|
|
||||||
require.NoError(t, b.Open())
|
|
||||||
require.NoError(t, b.Init())
|
|
||||||
require.NoError(t, b.Close())
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var w uint64
|
|
||||||
for ; w < width; w++ {
|
|
||||||
createTestTree(t, currentDepth+1, depth, width, filepath.Join(path, u64ToHexString(w)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func openAndCloseTestTree(t *testing.T, depth, width uint64, path string) {
|
|
||||||
blz := NewBlobovniczaTree(
|
|
||||||
context.Background(),
|
|
||||||
WithBlobovniczaShallowDepth(depth),
|
|
||||||
WithBlobovniczaShallowWidth(width),
|
|
||||||
WithRootPath(path),
|
|
||||||
)
|
|
||||||
require.NoError(t, blz.Open(mode.ComponentReadWrite))
|
|
||||||
require.NoError(t, blz.Init())
|
|
||||||
require.NoError(t, blz.Close())
|
|
||||||
}
|
|
||||||
|
|
||||||
func validateTestTree(t *testing.T, path string) {
|
|
||||||
entries, err := os.ReadDir(path)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
for _, entry := range entries {
|
|
||||||
if entry.IsDir() {
|
|
||||||
validateTestTree(t, filepath.Join(path, entry.Name()))
|
|
||||||
} else {
|
|
||||||
require.True(t, strings.HasSuffix(entry.Name(), dbExtension))
|
|
||||||
require.False(t, strings.HasSuffix(strings.TrimSuffix(entry.Name(), dbExtension), dbExtension))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestObjectsAvailableAfterDepthAndWidthEdit(t *testing.T) {
|
func TestObjectsAvailableAfterDepthAndWidthEdit(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue