2020-12-11 08:04:04 +00:00
|
|
|
package deletesvc
|
|
|
|
|
|
|
|
import (
|
2023-04-04 09:45:59 +00:00
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
|
|
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
2021-02-17 12:30:11 +00:00
|
|
|
"go.uber.org/zap"
|
2020-12-11 08:04:04 +00:00
|
|
|
)
|
|
|
|
|
2023-04-04 09:45:59 +00:00
|
|
|
func (exec *execCtx) executeLocal(ctx context.Context) {
|
2020-12-11 08:04:04 +00:00
|
|
|
exec.log.Debug("forming tombstone structure...")
|
|
|
|
|
2023-04-04 09:45:59 +00:00
|
|
|
ok := exec.formTombstone(ctx)
|
2020-12-11 08:04:04 +00:00
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
exec.log.Debug("tombstone structure successfully formed, saving...")
|
|
|
|
|
2023-04-04 09:45:59 +00:00
|
|
|
exec.saveTombstone(ctx)
|
2020-12-11 08:04:04 +00:00
|
|
|
}
|
|
|
|
|
2023-04-04 09:45:59 +00:00
|
|
|
func (exec *execCtx) formTombstone(ctx context.Context) (ok bool) {
|
2021-02-17 12:30:11 +00:00
|
|
|
tsLifetime, err := exec.svc.netInfo.TombstoneLifetime()
|
|
|
|
if err != nil {
|
|
|
|
exec.status = statusUndefined
|
|
|
|
exec.err = err
|
|
|
|
|
|
|
|
exec.log.Debug("could not read tombstone lifetime config",
|
|
|
|
zap.String("error", err.Error()),
|
|
|
|
)
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-03-03 14:19:05 +00:00
|
|
|
exec.tombstone = object.NewTombstone()
|
2021-02-17 12:30:11 +00:00
|
|
|
exec.tombstone.SetExpirationEpoch(
|
|
|
|
exec.svc.netInfo.CurrentEpoch() + tsLifetime,
|
|
|
|
)
|
2022-05-31 17:00:41 +00:00
|
|
|
exec.addMembers([]oid.ID{exec.address().Object()})
|
2020-12-11 08:04:04 +00:00
|
|
|
|
|
|
|
exec.log.Debug("forming split info...")
|
|
|
|
|
2023-04-04 09:45:59 +00:00
|
|
|
ok = exec.formSplitInfo(ctx)
|
2020-12-11 08:04:04 +00:00
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
exec.log.Debug("split info successfully formed, collecting members...")
|
|
|
|
|
2020-12-11 11:29:31 +00:00
|
|
|
exec.tombstone.SetSplitID(exec.splitInfo.SplitID())
|
|
|
|
|
2023-04-04 09:45:59 +00:00
|
|
|
ok = exec.collectMembers(ctx)
|
2020-12-11 08:04:04 +00:00
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
exec.log.Debug("members successfully collected")
|
|
|
|
|
|
|
|
ok = exec.initTombstoneObject()
|
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|