[#1689] Remove deprecated NodeInfo.IterateNetworkEndpoints()
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m25s
Build / Build Components (push) Successful in 1m48s
Pre-commit hooks / Pre-commit (push) Successful in 1m56s
Tests and linters / Run gofumpt (push) Successful in 3m48s
Tests and linters / Lint (push) Successful in 4m14s
Tests and linters / Staticcheck (push) Successful in 4m10s
Tests and linters / gopls check (push) Successful in 4m23s
Tests and linters / Tests (push) Successful in 4m33s
OCI image / Build container images (push) Successful in 5m3s
Tests and linters / Tests with -race (push) Successful in 5m20s
All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m25s
Build / Build Components (push) Successful in 1m48s
Pre-commit hooks / Pre-commit (push) Successful in 1m56s
Tests and linters / Run gofumpt (push) Successful in 3m48s
Tests and linters / Lint (push) Successful in 4m14s
Tests and linters / Staticcheck (push) Successful in 4m10s
Tests and linters / gopls check (push) Successful in 4m23s
Tests and linters / Tests (push) Successful in 4m33s
OCI image / Build container images (push) Successful in 5m3s
Tests and linters / Tests with -race (push) Successful in 5m20s
Change-Id: Ic78f18aed11fab34ee3147ceea657296b89fe60c Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
56d09a9957
commit
bf06c4fb4b
11 changed files with 83 additions and 82 deletions
|
@ -89,29 +89,13 @@ func (s *Service) ReplicateTreeOp(ctx context.Context, n netmapSDK.NodeInfo, req
|
|||
var lastErr error
|
||||
var lastAddr string
|
||||
|
||||
n.IterateNetworkEndpoints(func(addr string) bool {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "TreeService.HandleReplicationTaskOnEndpoint",
|
||||
trace.WithAttributes(
|
||||
attribute.String("public_key", hex.EncodeToString(n.PublicKey())),
|
||||
attribute.String("address", addr),
|
||||
),
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
for addr := range n.NetworkEndpoints() {
|
||||
lastAddr = addr
|
||||
|
||||
c, err := s.cache.get(ctx, addr)
|
||||
if err != nil {
|
||||
lastErr = fmt.Errorf("can't create client: %w", err)
|
||||
return false
|
||||
lastErr = s.apply(ctx, n, addr, req)
|
||||
if lastErr == nil {
|
||||
break
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, s.replicatorTimeout)
|
||||
_, lastErr = c.Apply(ctx, req)
|
||||
cancel()
|
||||
|
||||
return lastErr == nil
|
||||
})
|
||||
}
|
||||
|
||||
if lastErr != nil {
|
||||
if errors.Is(lastErr, errRecentlyFailed) {
|
||||
|
@ -130,6 +114,26 @@ func (s *Service) ReplicateTreeOp(ctx context.Context, n netmapSDK.NodeInfo, req
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Service) apply(ctx context.Context, n netmapSDK.NodeInfo, addr string, req *ApplyRequest) error {
|
||||
ctx, span := tracing.StartSpanFromContext(ctx, "TreeService.HandleReplicationTaskOnEndpoint",
|
||||
trace.WithAttributes(
|
||||
attribute.String("public_key", hex.EncodeToString(n.PublicKey())),
|
||||
attribute.String("address", addr),
|
||||
),
|
||||
)
|
||||
defer span.End()
|
||||
|
||||
c, err := s.cache.get(ctx, addr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't create client: %w", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, s.replicatorTimeout)
|
||||
_, err = c.Apply(ctx, req)
|
||||
cancel()
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Service) replicateLoop(ctx context.Context) {
|
||||
for range s.replicatorWorkerCount {
|
||||
go s.replicationWorker(ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue