Skip to content

Commit

Permalink
add retry for pullsync check (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandot authored Aug 14, 2020
1 parent 4a5cb7d commit e9bf479
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions pkg/check/pullsync/pullsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,24 @@ func Check(c bee.Cluster, o Options) (err error) {
return errPullSync
}

time.Sleep(5 * time.Second)
fmt.Printf("Chunk should be on %d nodes. %d within depth, %d outside\n", len(replicatingNodes), nnRep, peerPoBinRep)
for _, n := range replicatingNodes {
ni := findIndex(overlays, n)

synced, err := c.Nodes[ni].HasChunk(ctx, chunk.Address())
if err != nil {
return fmt.Errorf("node %d: %w", ni, err)
}
if !synced {
return fmt.Errorf("Upload node %d. Chunk %d not found on node. Upload node: %s Chunk: %s Pivot: %s", i, j, overlays[i].String(), chunk.Address().String(), n)
t := 1
for {
time.Sleep(2 * time.Duration(t) * time.Second)
synced, err := c.Nodes[ni].HasChunk(ctx, chunk.Address())
if err != nil {
return fmt.Errorf("node %d: %w", ni, err)
}
if synced {
break
}
t++
fmt.Printf("Upload node %d. Chunk %d not found on node. Upload node: %s Chunk: %s Pivot: %s\n", i, j, overlays[i].String(), chunk.Address().String(), n)
if t > 3 {
return fmt.Errorf("Upload node %d. Chunk %d not found on node. Upload node: %s Chunk: %s Pivot: %s", i, j, overlays[i].String(), chunk.Address().String(), n)
}
}
}

Expand Down

0 comments on commit e9bf479

Please sign in to comment.