Dmitrii Stepanov
692749dba1
Some checks failed
DCO action / DCO (pull_request) Failing after 1m30s
Tests and linters / Run gofumpt (pull_request) Successful in 1m26s
Vulncheck / Vulncheck (pull_request) Successful in 2m11s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m25s
Build / Build Components (pull_request) Successful in 2m29s
Tests and linters / Lint (pull_request) Failing after 2m26s
Tests and linters / gopls check (pull_request) Successful in 2m43s
Tests and linters / Staticcheck (pull_request) Successful in 2m56s
Tests and linters / Tests (pull_request) Successful in 4m22s
Tests and linters / Tests with -race (pull_request) Successful in 5m58s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package replicator
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
|
containerCore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
tracingPkg "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/tracing"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-observability/tracing"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/trace"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var errObjectNotDefined = errors.New("object is not defined")
|
|
|
|
func (p *Replicator) HandleLocalPutTask(ctx context.Context, task Task) {
|
|
p.metrics.IncInFlightRequest()
|
|
defer p.metrics.DecInFlightRequest()
|
|
defer func() {
|
|
p.log.Debug(ctx, logs.ReplicatorFinishWork, zap.String("type", "pull"))
|
|
}()
|
|
|
|
ctx, span := tracing.StartSpanFromContext(ctx, "Replicator.HandleLocalPutTask",
|
|
trace.WithAttributes(
|
|
attribute.Stringer("address", task.Addr),
|
|
attribute.Int("nodes_count", len(task.Nodes)),
|
|
))
|
|
defer span.End()
|
|
|
|
if task.Obj == nil {
|
|
p.log.Error(ctx, logs.ReplicatorCouldNotPutObjectToLocalStorage,
|
|
zap.Stringer("object", task.Addr),
|
|
zap.Error(errObjectNotDefined),
|
|
zap.String("trace_id", tracingPkg.GetTraceID(ctx)))
|
|
return
|
|
}
|
|
|
|
err := engine.Put(ctx, p.localStorage, task.Obj, containerCore.IsIndexedContainer(task.Container))
|
|
if err != nil {
|
|
p.log.Error(ctx, logs.ReplicatorCouldNotPutObjectToLocalStorage,
|
|
zap.Stringer("object", task.Addr),
|
|
zap.Error(err),
|
|
zap.String("trace_id", tracingPkg.GetTraceID(ctx)))
|
|
}
|
|
}
|