[#574] policer: Check if the container was really removed

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
feature/121-client/object_read
Airat Arifullin 2023-08-24 15:35:19 +03:00 committed by Evgenii Stratonikov
parent 554ff2c06b
commit 4ea0df77d0
7 changed files with 16 additions and 13 deletions

View File

@ -165,8 +165,7 @@ func newCachedContainerStorage(v container.Source, ttl time.Duration) ttlContain
func (s ttlContainerStorage) handleRemoval(cnr cid.ID) { func (s ttlContainerStorage) handleRemoval(cnr cid.ID) {
s.containerCache.set(cnr, nil, new(apistatus.ContainerNotFound)) s.containerCache.set(cnr, nil, new(apistatus.ContainerNotFound))
// The removal causes the cache miss and thus deletion info (that contains // The removal invalidates possibly stored error response.
// ownerID and epoch) for the container will be updated from sidechain.
s.delInfoCache.remove(cnr) s.delInfoCache.remove(cnr)
} }

View File

@ -28,7 +28,6 @@ import (
containerMorph "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/container/morph" containerMorph "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/container/morph"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
apiClient "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" 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" containerSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
@ -133,7 +132,6 @@ func configureEACLAndContainerSources(c *cfg, client *cntClient.Client, cnrSrc c
if err == nil { if err == nil {
cachedContainerLister.update(cnr.Value.Owner(), ev.ID, true) cachedContainerLister.update(cnr.Value.Owner(), ev.ID, true)
cachedContainerStorage.containerCache.set(ev.ID, cnr, nil) cachedContainerStorage.containerCache.set(ev.ID, cnr, nil)
cachedContainerStorage.delInfoCache.set(ev.ID, nil, new(apistatus.ContainerNotFound))
} else { } else {
// unlike removal, we expect successful receive of the container // unlike removal, we expect successful receive of the container
// after successful creation, so logging can be useful // after successful creation, so logging can be useful

View File

@ -42,6 +42,7 @@ const (
NotificatorNotificatorStartProcessingObjectNotifications = "notificator: start processing object notifications" NotificatorNotificatorStartProcessingObjectNotifications = "notificator: start processing object notifications"
NotificatorNotificatorProcessingObjectNotification = "notificator: processing object notification" NotificatorNotificatorProcessingObjectNotification = "notificator: processing object notification"
PolicerCouldNotGetContainer = "could not get container" PolicerCouldNotGetContainer = "could not get container"
PolicerCouldNotConfirmContainerRemoval = "could not confirm container removal"
PolicerCouldNotInhumeObjectWithMissingContainer = "could not inhume object with missing container" PolicerCouldNotInhumeObjectWithMissingContainer = "could not inhume object with missing container"
PolicerCouldNotBuildPlacementVectorForObject = "could not build placement vector for object" PolicerCouldNotBuildPlacementVectorForObject = "could not build placement vector for object"
PolicerRedundantLocalObjectCopyDetected = "redundant local object copy detected" PolicerRedundantLocalObjectCopyDetected = "redundant local object copy detected"

View File

@ -7,9 +7,9 @@ import (
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id" 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. // 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) _, err := s.DeletionInfo(cid)
if err == nil { if err == nil {
return true, nil return true, nil

View File

@ -20,10 +20,6 @@ type deletionInfo interface {
DeletionInfo(cid []byte) (*containercore.DelInfo, error) 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) { func DeletionInfo(c deletionInfo, cnr cid.ID) (*containercore.DelInfo, error) {
binCnr := make([]byte, sha256.Size) binCnr := make([]byte, sha256.Size)
cnr.Encode(binCnr) cnr.Encode(binCnr)

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "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" objectcore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/replicator" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/replicator"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" "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()), zap.String("error", err.Error()),
) )
if client.IsErrContainerNotFound(err) { if client.IsErrContainerNotFound(err) {
err := p.buryFn(ctx, addrWithType.Address) existed, err := containercore.WasRemoved(p.cnrSrc, idCnr)
if err != nil { if err != nil {
p.log.Error(logs.PolicerCouldNotInhumeObjectWithMissingContainer, p.log.Error(logs.PolicerCouldNotConfirmContainerRemoval,
zap.Stringer("cid", idCnr), zap.Stringer("cid", idCnr),
zap.Stringer("oid", idObj), zap.Stringer("oid", idObj),
zap.String("error", err.Error())) 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()))
}
} }
} }

View File

@ -454,7 +454,7 @@ func (s *Service) removeContainers(ctx context.Context, newContainers map[cid.ID
continue continue
} }
existed, err := containerCore.EverExisted(s.cnrSource, cnr) existed, err := containerCore.WasRemoved(s.cnrSource, cnr)
if err != nil { if err != nil {
s.log.Error(logs.TreeCouldNotCheckIfContainerExisted, s.log.Error(logs.TreeCouldNotCheckIfContainerExisted,
zap.Stringer("cid", cnr), zap.Stringer("cid", cnr),