diff --git a/CHANGELOG.md b/CHANGELOG.md index 91501553..6aa3001c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Changelog for NeoFS Node ### Fixed - Description of command `netmap nodeinfo` (#1821) +- Proper status for object.Delete if session token is missing (#1697) ### Removed - Remove WIF and NEP2 support in `neofs-cli`'s --wallet flag (#1128) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 278c157e..f1614090 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -338,11 +338,11 @@ func initObjectService(c *cfg) { cfg: c, }), + deletesvc.WithKeyStorage(keyStorage), ) sDeleteV2 := deletesvcV2.NewService( deletesvcV2.WithInternalService(sDelete), - deletesvcV2.WithKeyStorage(keyStorage), ) // build service pipeline diff --git a/pkg/services/object/delete/delete.go b/pkg/services/object/delete/delete.go index 56aa74e7..b50e261c 100644 --- a/pkg/services/object/delete/delete.go +++ b/pkg/services/object/delete/delete.go @@ -3,11 +3,24 @@ package deletesvc import ( "context" + "github.com/nspcc-dev/neofs-node/pkg/services/object/util" "go.uber.org/zap" ) // Delete serves requests to remote the objects. func (s *Service) Delete(ctx context.Context, prm Prm) error { + // If session token is not found we will fail during tombstone PUT. + // Here we fail immediately to ensure no unnecessary network communication is done. + if tok := prm.common.SessionToken(); tok != nil { + _, err := s.keyStorage.GetKey(&util.SessionInfo{ + ID: tok.ID(), + Owner: tok.Issuer(), + }) + if err != nil { + return err + } + } + exec := &execCtx{ svc: s, ctx: ctx, diff --git a/pkg/services/object/delete/service.go b/pkg/services/object/delete/service.go index a56ad7dc..a66f16dd 100644 --- a/pkg/services/object/delete/service.go +++ b/pkg/services/object/delete/service.go @@ -5,6 +5,7 @@ import ( getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get" putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put" searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search" + "github.com/nspcc-dev/neofs-node/pkg/services/object/util" "github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-sdk-go/object" oid "github.com/nspcc-dev/neofs-sdk-go/object/id" @@ -55,6 +56,8 @@ type cfg struct { } netInfo NetworkInfo + + keyStorage *util.KeyStorage } func defaultCfg() *cfg { @@ -112,3 +115,10 @@ func WithNetworkInfo(netInfo NetworkInfo) Option { c.netInfo = netInfo } } + +// WithKeyStorage returns option to set local private key storage. +func WithKeyStorage(ks *util.KeyStorage) Option { + return func(c *cfg) { + c.keyStorage = ks + } +} diff --git a/pkg/services/object/delete/v2/service.go b/pkg/services/object/delete/v2/service.go index 9e7a3cee..7b450b8a 100644 --- a/pkg/services/object/delete/v2/service.go +++ b/pkg/services/object/delete/v2/service.go @@ -5,7 +5,6 @@ import ( objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete" - objutil "github.com/nspcc-dev/neofs-node/pkg/services/object/util" ) // Service implements Delete operation of Object service v2. @@ -18,8 +17,6 @@ type Option func(*cfg) type cfg struct { svc *deletesvc.Service - - keyStorage *objutil.KeyStorage } // NewService constructs Service instance from provided options. @@ -60,10 +57,3 @@ func WithInternalService(v *deletesvc.Service) Option { c.svc = v } } - -// WithKeyStorage returns option to set local private key storage. -func WithKeyStorage(ks *objutil.KeyStorage) Option { - return func(c *cfg) { - c.keyStorage = ks - } -}