From 57dcd5a53cacf48fa0b26165719c0d85a48531cd Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Thu, 24 Aug 2023 15:35:19 +0300 Subject: [PATCH] [#574] policer: Check if the container was really removed Signed-off-by: Airat Arifullin --- cmd/frostfs-node/cache.go | 3 +-- cmd/frostfs-node/container.go | 2 -- internal/logs/logs.go | 1 + pkg/core/container/util.go | 4 ++-- pkg/morph/client/container/deletion_info.go | 4 ---- pkg/services/policer/check.go | 13 +++++++++++-- pkg/services/tree/sync.go | 2 +- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cmd/frostfs-node/cache.go b/cmd/frostfs-node/cache.go index f8266e562..6a5d5d182 100644 --- a/cmd/frostfs-node/cache.go +++ b/cmd/frostfs-node/cache.go @@ -165,8 +165,7 @@ func newCachedContainerStorage(v container.Source, ttl time.Duration) ttlContain func (s ttlContainerStorage) handleRemoval(cnr cid.ID) { s.containerCache.set(cnr, nil, new(apistatus.ContainerNotFound)) - // The removal causes the cache miss and thus deletion info (that contains - // ownerID and epoch) for the container will be updated from sidechain. + // The removal invalidates possibly stored error response. s.delInfoCache.remove(cnr) } diff --git a/cmd/frostfs-node/container.go b/cmd/frostfs-node/container.go index 8c2ae54b3..5d88ff9ea 100644 --- a/cmd/frostfs-node/container.go +++ b/cmd/frostfs-node/container.go @@ -28,7 +28,6 @@ import ( containerMorph "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/container/morph" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" apiClient "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" - apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" containerSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" @@ -133,7 +132,6 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c if err == nil { cachedContainerLister.update(cnr.Value.Owner(), ev.ID, true) cachedContainerStorage.containerCache.set(ev.ID, cnr, nil) - cachedContainerStorage.delInfoCache.set(ev.ID, nil, new(apistatus.ContainerNotFound)) } else { // unlike removal, we expect successful receive of the container // after successful creation, so logging can be useful diff --git a/internal/logs/logs.go b/internal/logs/logs.go index 3f0a3f56e..b1db77280 100644 --- a/internal/logs/logs.go +++ b/internal/logs/logs.go @@ -42,6 +42,7 @@ const ( NotificatorNotificatorStartProcessingObjectNotifications = "notificator: start processing object notifications" NotificatorNotificatorProcessingObjectNotification = "notificator: processing object notification" PolicerCouldNotGetContainer = "could not get container" + PolicerCouldNotConfirmContainerRemoval = "could not confirm container removal" PolicerCouldNotInhumeObjectWithMissingContainer = "could not inhume object with missing container" PolicerCouldNotBuildPlacementVectorForObject = "could not build placement vector for object" PolicerRedundantLocalObjectCopyDetected = "redundant local object copy detected" diff --git a/pkg/core/container/util.go b/pkg/core/container/util.go index 58ceb03ba..98919284e 100644 --- a/pkg/core/container/util.go +++ b/pkg/core/container/util.go @@ -7,9 +7,9 @@ import ( cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" ) -// EverExisted checks whether the container ever existed or +// WasRemoved checks whether the container ever existed or // it just has not been created yet at the current epoch. -func EverExisted(s Source, cid cid.ID) (bool, error) { +func WasRemoved(s Source, cid cid.ID) (bool, error) { _, err := s.DeletionInfo(cid) if err == nil { return true, nil diff --git a/pkg/morph/client/container/deletion_info.go b/pkg/morph/client/container/deletion_info.go index b34ec32db..40eb267d6 100644 --- a/pkg/morph/client/container/deletion_info.go +++ b/pkg/morph/client/container/deletion_info.go @@ -20,10 +20,6 @@ type deletionInfo interface { DeletionInfo(cid []byte) (*containercore.DelInfo, error) } -func AsContainerSpecInfoProvider(w *Client) containercore.Source { - return (*containerSource)(w) -} - func DeletionInfo(c deletionInfo, cnr cid.ID) (*containercore.DelInfo, error) { binCnr := make([]byte, sha256.Size) cnr.Encode(binCnr) diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index 800ddb006..bc82b144d 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -5,6 +5,7 @@ import ( "errors" "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" + containercore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container" objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/replicator" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" @@ -27,12 +28,20 @@ func (p *Policer) processObject(ctx context.Context, addrWithType objectcore.Add zap.String("error", err.Error()), ) if client.IsErrContainerNotFound(err) { - err := p.buryFn(ctx, addrWithType.Address) + existed, err := containercore.WasRemoved(p.cnrSrc, idCnr) if err != nil { - p.log.Error(logs.PolicerCouldNotInhumeObjectWithMissingContainer, + p.log.Error(logs.PolicerCouldNotConfirmContainerRemoval, zap.Stringer("cid", idCnr), zap.Stringer("oid", idObj), zap.String("error", err.Error())) + } else if existed { + err := p.buryFn(ctx, addrWithType.Address) + if err != nil { + p.log.Error(logs.PolicerCouldNotInhumeObjectWithMissingContainer, + zap.Stringer("cid", idCnr), + zap.Stringer("oid", idObj), + zap.String("error", err.Error())) + } } } diff --git a/pkg/services/tree/sync.go b/pkg/services/tree/sync.go index c681bb078..9cff8b351 100644 --- a/pkg/services/tree/sync.go +++ b/pkg/services/tree/sync.go @@ -454,7 +454,7 @@ func (s *Service) removeContainers(ctx context.Context, newContainers map[cid.ID continue } - existed, err := containerCore.EverExisted(s.cnrSource, cnr) + existed, err := containerCore.WasRemoved(s.cnrSource, cnr) if err != nil { s.log.Error(logs.TreeCouldNotCheckIfContainerExisted, zap.Stringer("cid", cnr),