forked from TrueCloudLab/frostfs-node
[#574] policer: Check if the container was really removed
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
554ff2c06b
commit
4ea0df77d0
7 changed files with 16 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue