diff --git a/cmd/neofs-node/cache.go b/cmd/neofs-node/cache.go index 9061744a..3ac4e9f4 100644 --- a/cmd/neofs-node/cache.go +++ b/cmd/neofs-node/cache.go @@ -10,6 +10,7 @@ import ( cntClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/eacl" putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put" + apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" netmapSDK "github.com/nspcc-dev/neofs-sdk-go/netmap" "github.com/nspcc-dev/neofs-sdk-go/user" @@ -147,6 +148,10 @@ func newCachedContainerStorage(v container.Source) *ttlContainerStorage { return (*ttlContainerStorage)(lruCnrCache) } +func (s *ttlContainerStorage) handleRemoval(cnr cid.ID) { + (*ttlNetCache)(s).set(cnr.EncodeToString(), nil, apistatus.ContainerNotFound{}) +} + // Get returns container value from the cache. If value is missing in the cache // or expired, then it returns value from side chain and updates the cache. func (s *ttlContainerStorage) Get(cnr cid.ID) (*container.Container, error) { diff --git a/cmd/neofs-node/container.go b/cmd/neofs-node/container.go index 454fb8ed..b6462978 100644 --- a/cmd/neofs-node/container.go +++ b/cmd/neofs-node/container.go @@ -69,12 +69,6 @@ func initContainerService(c *cfg) { ) }) - subscribeToContainerRemoval(c, func(e event.Event) { - c.log.Debug("container removal event's receipt", - zap.Stringer("id", e.(containerEvent.DeleteSuccess).ID), - ) - }) - if c.cfgMorph.disableCache { c.cfgObject.eaclSource = eACLFetcher cnrRdr.eacl = eACLFetcher @@ -87,6 +81,16 @@ func initContainerService(c *cfg) { cachedEACLStorage := newCachedEACLStorage(eACLFetcher) cachedContainerLister := newCachedContainerLister(wrap) + subscribeToContainerRemoval(c, func(e event.Event) { + ev := e.(containerEvent.DeleteSuccess) + + cachedContainerStorage.handleRemoval(ev.ID) + + c.log.Debug("container removal event's receipt", + zap.Stringer("id", ev.ID), + ) + }) + c.cfgObject.eaclSource = cachedEACLStorage c.cfgObject.cnrSource = cachedContainerStorage