2024-04-22 06:43:42 +00:00
|
|
|
package getsvc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
2024-07-15 15:03:43 +00:00
|
|
|
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
2024-04-22 06:43:42 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (r *request) assembleEC(ctx context.Context) {
|
2024-07-23 14:46:02 +00:00
|
|
|
if r.isRaw() {
|
2024-10-21 07:22:54 +00:00
|
|
|
r.log.Debug(ctx, logs.GetCanNotAssembleTheObject)
|
2024-04-22 06:43:42 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Any access tokens are not expected to be used in the assembly process:
|
|
|
|
// - there is no requirement to specify child objects in session/bearer
|
|
|
|
// token for `GET`/`GETRANGE`/`RANGEHASH` requests in the API protocol,
|
|
|
|
// and, therefore, their missing in the original request should not be
|
|
|
|
// considered as error; on the other hand, without session for every child
|
|
|
|
// object, it is impossible to attach bearer token in the new generated
|
|
|
|
// requests correctly because the token has not been issued for that node's
|
|
|
|
// key;
|
|
|
|
// - the assembly process is expected to be handled on a container node
|
|
|
|
// only since the requests forwarding mechanism presentation; such the
|
|
|
|
// node should have enough rights for getting any child object by design.
|
|
|
|
r.prm.common.ForgetTokens()
|
|
|
|
|
|
|
|
// Do not use forwarding during assembly stage.
|
|
|
|
// Request forwarding closure inherited in produced
|
|
|
|
// `execCtx` so it should be disabled there.
|
|
|
|
r.disableForwarding()
|
|
|
|
|
2024-10-21 07:22:54 +00:00
|
|
|
r.log.Debug(ctx, logs.GetTryingToAssembleTheECObject)
|
2024-04-22 06:43:42 +00:00
|
|
|
|
2024-07-15 15:03:43 +00:00
|
|
|
// initialize epoch number
|
|
|
|
ok := r.initEpoch()
|
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-07 11:23:23 +00:00
|
|
|
r.prm.common = r.prm.common.WithLocalOnly(false)
|
2024-09-23 06:10:03 +00:00
|
|
|
assembler := newAssemblerEC(r.address(), r.infoEC, r.ctxRange(), r, r.localStorage, r.log, r.headOnly(), r.traverserGenerator, r.curProcEpoch)
|
2024-04-22 06:43:42 +00:00
|
|
|
|
2024-10-21 07:22:54 +00:00
|
|
|
r.log.Debug(ctx, logs.GetAssemblingECObject,
|
2024-04-22 06:43:42 +00:00
|
|
|
zap.Uint64("range_offset", r.ctxRange().GetOffset()),
|
|
|
|
zap.Uint64("range_length", r.ctxRange().GetLength()),
|
|
|
|
)
|
2024-10-21 07:22:54 +00:00
|
|
|
defer r.log.Debug(ctx, logs.GetAssemblingECObjectCompleted,
|
2024-04-22 06:43:42 +00:00
|
|
|
zap.Uint64("range_offset", r.ctxRange().GetOffset()),
|
|
|
|
zap.Uint64("range_length", r.ctxRange().GetLength()),
|
|
|
|
)
|
|
|
|
|
2024-07-15 15:03:43 +00:00
|
|
|
obj, err := assembler.Assemble(ctx, r.prm.objWriter)
|
|
|
|
if err != nil && !errors.As(err, new(*objectSDK.ECInfoError)) {
|
2024-10-21 07:22:54 +00:00
|
|
|
r.log.Warn(ctx, logs.GetFailedToAssembleECObject,
|
2024-04-22 06:43:42 +00:00
|
|
|
zap.Error(err),
|
|
|
|
zap.Uint64("range_offset", r.ctxRange().GetOffset()),
|
|
|
|
zap.Uint64("range_length", r.ctxRange().GetLength()),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
var errRemoved *apistatus.ObjectAlreadyRemoved
|
|
|
|
var errOutOfRange *apistatus.ObjectOutOfRange
|
2024-07-15 15:03:43 +00:00
|
|
|
var errECInfo *objectSDK.ECInfoError
|
2024-04-22 06:43:42 +00:00
|
|
|
|
|
|
|
switch {
|
|
|
|
default:
|
|
|
|
r.status = statusUndefined
|
|
|
|
r.err = err
|
|
|
|
case err == nil:
|
|
|
|
r.status = statusOK
|
|
|
|
r.err = nil
|
|
|
|
r.collectedObject = obj
|
|
|
|
case errors.As(err, &errRemoved):
|
|
|
|
r.status = statusINHUMED
|
|
|
|
r.err = errRemoved
|
|
|
|
case errors.As(err, &errOutOfRange):
|
|
|
|
r.status = statusOutOfRange
|
|
|
|
r.err = errOutOfRange
|
2024-07-15 15:03:43 +00:00
|
|
|
case errors.As(err, &errECInfo):
|
|
|
|
r.status = statusEC
|
|
|
|
r.err = err
|
2024-04-22 06:43:42 +00:00
|
|
|
}
|
|
|
|
}
|