forked from TrueCloudLab/frostfs-node
[#648] objsvc/delete: Handle errors in Go style
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
d2084ece41
commit
f8ba60aa0c
4 changed files with 62 additions and 181 deletions
|
@ -2,37 +2,29 @@ package deletesvc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func (exec *execCtx) executeLocal(ctx context.Context) {
|
||||
func (exec *execCtx) executeLocal(ctx context.Context) error {
|
||||
exec.log.Debug(logs.DeleteFormingTombstoneStructure)
|
||||
|
||||
ok := exec.formTombstone(ctx)
|
||||
if !ok {
|
||||
return
|
||||
if err := exec.formTombstone(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
exec.log.Debug(logs.DeleteTombstoneStructureSuccessfullyFormedSaving)
|
||||
|
||||
exec.saveTombstone(ctx)
|
||||
return exec.saveTombstone(ctx)
|
||||
}
|
||||
|
||||
func (exec *execCtx) formTombstone(ctx context.Context) (ok bool) {
|
||||
func (exec *execCtx) formTombstone(ctx context.Context) error {
|
||||
tsLifetime, err := exec.svc.netInfo.TombstoneLifetime()
|
||||
if err != nil {
|
||||
exec.status = statusUndefined
|
||||
exec.err = err
|
||||
|
||||
exec.log.Debug(logs.DeleteCouldNotReadTombstoneLifetimeConfig,
|
||||
zap.String("error", err.Error()),
|
||||
)
|
||||
|
||||
return false
|
||||
return fmt.Errorf("fetch tombstone lifetime: %w", err)
|
||||
}
|
||||
|
||||
exec.tombstone = objectSDK.NewTombstone()
|
||||
|
@ -43,26 +35,19 @@ func (exec *execCtx) formTombstone(ctx context.Context) (ok bool) {
|
|||
|
||||
exec.log.Debug(logs.DeleteFormingSplitInfo)
|
||||
|
||||
ok = exec.formSplitInfo(ctx)
|
||||
if !ok {
|
||||
return
|
||||
if err := exec.formSplitInfo(ctx); err != nil {
|
||||
return fmt.Errorf("form split info: %w", err)
|
||||
}
|
||||
|
||||
exec.log.Debug(logs.DeleteSplitInfoSuccessfullyFormedCollectingMembers)
|
||||
|
||||
exec.tombstone.SetSplitID(exec.splitInfo.SplitID())
|
||||
|
||||
ok = exec.collectMembers(ctx)
|
||||
if !ok {
|
||||
return
|
||||
if err := exec.collectMembers(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
exec.log.Debug(logs.DeleteMembersSuccessfullyCollected)
|
||||
|
||||
ok = exec.initTombstoneObject()
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
return true
|
||||
return exec.initTombstoneObject()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue