All checks were successful
DCO action / DCO (pull_request) Successful in 39s
Tests and linters / Run gofumpt (pull_request) Successful in 38s
Vulncheck / Vulncheck (pull_request) Successful in 52s
Tests and linters / Staticcheck (pull_request) Successful in 2m4s
Build / Build Components (pull_request) Successful in 2m21s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m23s
Tests and linters / Tests with -race (pull_request) Successful in 4m8s
Tests and linters / Lint (pull_request) Successful in 5m47s
Tests and linters / Tests (pull_request) Successful in 6m31s
Tests and linters / gopls check (pull_request) Successful in 2m37s
Tests and linters / Run gofumpt (push) Successful in 32s
Vulncheck / Vulncheck (push) Successful in 58s
Pre-commit hooks / Pre-commit (push) Successful in 1m23s
Build / Build Components (push) Successful in 1m43s
Tests and linters / Staticcheck (push) Successful in 2m24s
Tests and linters / Lint (push) Successful in 3m43s
OCI image / Build container images (push) Successful in 4m34s
Tests and linters / Tests (push) Successful in 4m37s
Tests and linters / Tests with -race (push) Successful in 5m21s
Tests and linters / gopls check (push) Successful in 5m29s
`trace_id` is taken from context. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
45 lines
1.3 KiB
Go
45 lines
1.3 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"
|
|
"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))
|
|
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))
|
|
}
|
|
}
|