Do not allow to delete or lock EC chunks #1213

Merged
fyrchik merged 4 commits from dstepanov-yadro/frostfs-node:fix/lock_ec_chunk into master 2024-07-01 06:49:41 +00:00
4 changed files with 10 additions and 36 deletions

View file

@ -354,7 +354,7 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
Prepare(cmd, &prmHead) Prepare(cmd, &prmHead)
_, err := internal.HeadObject(cmd.Context(), prmHead) o, err := internal.HeadObject(cmd.Context(), prmHead)
var errSplit *objectSDK.SplitInfoError var errSplit *objectSDK.SplitInfoError
var errEC *objectSDK.ECInfoError var errEC *objectSDK.ECInfoError
@ -364,6 +364,9 @@ func collectObjectRelatives(cmd *cobra.Command, cli *client.Client, cnr cid.ID,
commonCmd.ExitOnErr(cmd, "failed to get raw object header: %w", err) commonCmd.ExitOnErr(cmd, "failed to get raw object header: %w", err)
case err == nil: case err == nil:
common.PrintVerbose(cmd, "Raw header received - object is singular.") common.PrintVerbose(cmd, "Raw header received - object is singular.")
if ech := o.Header().ECHeader(); ech != nil {
commonCmd.ExitOnErr(cmd, "Lock EC chunk failed: %w", errors.ErrUnsupported)
}
return nil return nil
case errors.As(err, &errSplit): case errors.As(err, &errSplit):
common.PrintVerbose(cmd, "Split information received - object is virtual.") common.PrintVerbose(cmd, "Split information received - object is virtual.")

View file

@ -14,7 +14,6 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/netmap"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/acl"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa" frostfsecdsa "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto/ecdsa"
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object" objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
@ -41,30 +40,12 @@ type cfg struct {
verifyTokenIssuer bool verifyTokenIssuer bool
} }
// DeleteHandler is an interface of delete queue processor.
type DeleteHandler interface {
// DeleteObjects places objects to a removal queue.
//
// Returns apistatus.LockNonRegularObject if at least one object
// is locked.
DeleteObjects(oid.Address, ...oid.Address) error
}
// LockSource is a source of lock relations between the objects. // LockSource is a source of lock relations between the objects.
type LockSource interface { type LockSource interface {
// IsLocked must clarify object's lock status. // IsLocked must clarify object's lock status.
IsLocked(ctx context.Context, address oid.Address) (bool, error) IsLocked(ctx context.Context, address oid.Address) (bool, error)
} }
// Locker is an object lock storage interface.
type Locker interface {
// Lock list of objects as locked by locker in the specified container.
//
// Returns apistatus.LockNonRegularObject if at least object in locked
// list is irregular (not type of REGULAR).
Lock(idCnr cid.ID, locker oid.ID, locked []oid.ID) error
}
var errNilObject = errors.New("object is nil") var errNilObject = errors.New("object is nil")
var errNilID = errors.New("missing identifier") var errNilID = errors.New("missing identifier")

View file

@ -151,18 +151,3 @@ func Head(ctx context.Context, storage *StorageEngine, addr oid.Address) (*objec
return res.Header(), nil return res.Header(), nil
} }
// HeadRaw reads object header from local storage by provided address and raw
// flag.
func HeadRaw(ctx context.Context, storage *StorageEngine, addr oid.Address, raw bool) (*objectSDK.Object, error) {
var headPrm HeadPrm
headPrm.WithAddress(addr)
headPrm.WithRaw(raw)
res, err := storage.Head(ctx, headPrm)
if err != nil {
return nil, err
}
return res.Header(), nil
}

View file

@ -17,6 +17,8 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
) )
var errDeleteECChunk = errors.New("invalid operation: delete EC object chunk")
type execCtx struct { type execCtx struct {
svc *Service svc *Service
@ -66,13 +68,16 @@ func (exec *execCtx) newAddress(id oid.ID) oid.Address {
} }
func (exec *execCtx) formExtendedInfo(ctx context.Context) error { func (exec *execCtx) formExtendedInfo(ctx context.Context) error {
_, err := exec.svc.header.head(ctx, exec) obj, err := exec.svc.header.head(ctx, exec)
var errSplitInfo *objectSDK.SplitInfoError var errSplitInfo *objectSDK.SplitInfoError
var errECInfo *objectSDK.ECInfoError var errECInfo *objectSDK.ECInfoError
switch { switch {
case err == nil: case err == nil:
if ech := obj.ECHeader(); ech != nil {
return errDeleteECChunk
}
return nil return nil
case errors.As(err, &errSplitInfo): case errors.As(err, &errSplitInfo):
exec.splitInfo = errSplitInfo.SplitInfo() exec.splitInfo = errSplitInfo.SplitInfo()