frostfs-node/pkg/local_object_storage/engine/exists.go
Dmitrii Stepanov d62c6e4ce6 [#242] node: Add tracing spans
Add tracing spans for PUT requests.
Add tracing spans for DELETE requests.
Add tracing spans for SELECT requests.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-04-14 10:25:53 +00:00

57 lines
1.2 KiB
Go

package engine
import (
"context"
"errors"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
)
func (e *StorageEngine) exists(ctx context.Context, addr oid.Address) (bool, error) {
var shPrm shard.ExistsPrm
shPrm.SetAddress(addr)
alreadyRemoved := false
exists := false
e.iterateOverSortedShards(addr, func(_ int, sh hashedShard) (stop bool) {
res, err := sh.Exists(ctx, shPrm)
if err != nil {
if shard.IsErrRemoved(err) {
alreadyRemoved = true
return true
}
var siErr *objectSDK.SplitInfoError
if errors.As(err, &siErr) {
return true
}
if shard.IsErrObjectExpired(err) {
return true
}
if !shard.IsErrNotFound(err) {
e.reportShardError(sh, "could not check existence of object in shard", err)
}
return false
}
if !exists {
exists = res.Exists()
}
return false
})
if alreadyRemoved {
var errRemoved apistatus.ObjectAlreadyRemoved
return false, errRemoved
}
return exists, nil
}