All checks were successful
DCO action / DCO (pull_request) Successful in 2m27s
Vulncheck / Vulncheck (pull_request) Successful in 2m7s
Build / Build Components (1.20) (pull_request) Successful in 2m44s
Tests and linters / Staticcheck (pull_request) Successful in 3m18s
Tests and linters / Tests (1.21) (pull_request) Successful in 5m0s
Tests and linters / Tests with -race (pull_request) Successful in 5m40s
Build / Build Components (1.21) (pull_request) Successful in 12m49s
Tests and linters / Lint (pull_request) Successful in 12m57s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m8s
Use special flag to select storages by storage ID. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package blobstor
|
|
|
|
import (
|
|
"context"
|
|
"encoding/hex"
|
|
"time"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/util/logicerr"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/trace"
|
|
)
|
|
|
|
func (b *BlobStor) Delete(ctx context.Context, prm common.DeletePrm) (common.DeleteRes, error) {
|
|
var (
|
|
startedAt = time.Now()
|
|
success = false
|
|
)
|
|
defer func() {
|
|
b.metrics.Delete(time.Since(startedAt), success, prm.StorageID != nil)
|
|
}()
|
|
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "BlobStor.Delete",
|
|
trace.WithAttributes(
|
|
attribute.String("address", prm.Address.EncodeToString()),
|
|
attribute.String("storage_id", hex.EncodeToString(prm.StorageID)),
|
|
))
|
|
defer span.End()
|
|
|
|
b.modeMtx.RLock()
|
|
defer b.modeMtx.RUnlock()
|
|
|
|
for _, storage := range b.selectStorages(prm.StorageID) {
|
|
res, err := storage.Delete(ctx, prm)
|
|
if err == nil || !client.IsErrObjectNotFound(err) {
|
|
if err == nil {
|
|
success = true
|
|
logOp(b.log, deleteOp, prm.Address, storage.Type(), prm.StorageID)
|
|
}
|
|
return res, err
|
|
}
|
|
}
|
|
|
|
return common.DeleteRes{}, logicerr.Wrap(new(apistatus.ObjectNotFound))
|
|
}
|