All checks were successful
Vulncheck / Vulncheck (pull_request) Successful in 4m54s
DCO action / DCO (pull_request) Successful in 5m6s
Build / Build Components (1.21) (pull_request) Successful in 5m25s
Build / Build Components (1.22) (pull_request) Successful in 5m33s
Tests and linters / gopls check (pull_request) Successful in 5m50s
Tests and linters / Staticcheck (pull_request) Successful in 6m59s
Tests and linters / Lint (pull_request) Successful in 8m26s
Pre-commit hooks / Pre-commit (pull_request) Successful in 9m38s
Tests and linters / Tests with -race (pull_request) Successful in 10m49s
Tests and linters / Tests (1.21) (pull_request) Successful in 11m7s
Tests and linters / Tests (1.22) (pull_request) Successful in 11m37s
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package engine
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
)
|
|
|
|
// exists return in the first value true if object exists.
|
|
// Second return value marks is parent object locked.
|
|
func (e *StorageEngine) exists(ctx context.Context, shPrm shard.ExistsPrm) (bool, bool, error) {
|
|
alreadyRemoved := false
|
|
exists := false
|
|
locked := false
|
|
|
|
e.iterateOverSortedShards(shPrm.Address, func(_ int, sh hashedShard) (stop bool) {
|
|
res, err := sh.Exists(ctx, shPrm)
|
|
if err != nil {
|
|
if client.IsErrObjectAlreadyRemoved(err) {
|
|
alreadyRemoved = true
|
|
|
|
return true
|
|
}
|
|
|
|
var siErr *objectSDK.SplitInfoError
|
|
if errors.As(err, &siErr) {
|
|
return true
|
|
}
|
|
|
|
if shard.IsErrObjectExpired(err) {
|
|
return true
|
|
}
|
|
|
|
if !client.IsErrObjectNotFound(err) {
|
|
e.reportShardError(sh, "could not check existence of object in shard", err)
|
|
}
|
|
return false
|
|
}
|
|
|
|
if !exists {
|
|
exists = res.Exists()
|
|
}
|
|
if !locked {
|
|
locked = res.Locked()
|
|
}
|
|
|
|
return false
|
|
})
|
|
|
|
if alreadyRemoved {
|
|
return false, false, new(apistatus.ObjectAlreadyRemoved)
|
|
}
|
|
|
|
return exists, locked, nil
|
|
}
|