frostfs-node/pkg/services/object/get/container.go
Dmitrii Stepanov d4493a6d08
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 2m16s
DCO action / DCO (pull_request) Successful in 2m32s
Tests and linters / Staticcheck (pull_request) Successful in 3m37s
Vulncheck / Vulncheck (pull_request) Successful in 3m44s
Build / Build Components (pull_request) Successful in 3m58s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m56s
Tests and linters / gopls check (pull_request) Successful in 4m26s
Tests and linters / Lint (pull_request) Successful in 5m8s
Tests and linters / Tests (pull_request) Successful in 5m48s
Tests and linters / Tests with -race (pull_request) Successful in 6m22s
[#1390] getSvc: Fix Head EC1.1
If local EC chunk found, but remote node is off, then `HEAD --raw` request
returns object not found.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2024-09-23 15:12:06 +03:00

99 lines
1.9 KiB
Go

package getsvc
import (
"context"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
"go.uber.org/zap"
)
func (r *request) executeOnContainer(ctx context.Context) {
if r.isLocal() {
r.log.Debug(logs.GetReturnResultDirectly)
return
}
lookupDepth := r.netmapLookupDepth()
r.log.Debug(logs.TryingToExecuteInContainer,
zap.Uint64("netmap lookup depth", lookupDepth),
)
// initialize epoch number
ok := r.initEpoch()
if !ok {
return
}
localStatus := r.status
for {
if r.processCurrentEpoch(ctx, localStatus) {
break
}
// check the maximum depth has been reached
if lookupDepth == 0 {
break
}
lookupDepth--
// go to the previous epoch
r.curProcEpoch--
}
}
func (r *request) processCurrentEpoch(ctx context.Context, localStatus int) bool {
r.log.Debug(logs.ProcessEpoch,
zap.Uint64("number", r.curProcEpoch),
)
traverser, ok := r.generateTraverser(r.address())
if !ok {
return true
}
ctx, cancel := context.WithCancel(ctx)
defer cancel()
if localStatus == statusEC { // possible only for raw == true and local == false
r.status = statusEC
} else {
r.status = statusUndefined
}
for {
addrs := traverser.Next()
if len(addrs) == 0 {
r.log.Debug(logs.NoMoreNodesAbortPlacementIteration)
return false
}
for i := range addrs {
select {
case <-ctx.Done():
r.log.Debug(logs.InterruptPlacementIterationByContext,
zap.Error(ctx.Err()),
)
return true
default:
}
// TODO: #1142 consider parallel execution
// TODO: #1142 consider optimization: if status == SPLIT we can continue until
// we reach the best result - split info with linking object ID.
var info client.NodeInfo
client.NodeInfoFromNetmapElement(&info, addrs[i])
if r.processNode(ctx, info) {
r.log.Debug(logs.GetCompletingTheOperation)
return true
}
}
}
}