Skip to content

Commit

Permalink
fix: wait for push and fix logs (#375)
Browse files Browse the repository at this point in the history
* fix: wait for push and fix logs

* fix: .

* fix: .
  • Loading branch information
acha-bill authored Dec 19, 2023
1 parent a5f871d commit 30c4e49
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/check/datadurability/datadurability.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, o interf
if !ok {
return fmt.Errorf("invalid options type")
}
if opts.Ref == "" {
return fmt.Errorf("reference is required")
}

ref, err := swarm.ParseHexAddress(opts.Ref)
if err != nil {
return fmt.Errorf("parse hex ref %s: %w", opts.Ref, err)
Expand Down Expand Up @@ -107,7 +111,6 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, o interf
return
}
dur := time.Since(chunkStart)
c.logger.Infof("download successful. %s (%d of %d) chunk=%s node=%s dur=%v", percentage(i, len(chunkRefs)), i, len(chunkRefs), ref, node.Name(), dur)
c.metrics.ChunkDownloadDuration.Observe(dur.Seconds())
c.metrics.FileSize.Add(float64(len(d)))
}(i, ref, node)
Expand All @@ -120,6 +123,9 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, o interf
dur := time.Since(fileStart)
c.logger.Infof("done. dur=%v", dur)
c.metrics.FileDownloadDuration.Observe(dur.Seconds())
// wait for metrics to be pushed
c.logger.Infof("waiting 1 minute for metrics to be pushed")
time.Sleep(1 * time.Minute)
return nil
}

Expand All @@ -128,6 +134,7 @@ func percentage(a, b int) string {
}

func fetchFile(ctx context.Context, logger logging.Logger, ref swarm.Address, cluster orchestration.Cluster, maxAttempts int) ([]byte, error) {
logger.Infof("fetching file. ref=%s", ref.String())
var nodes []orchestration.Node
for _, node := range cluster.Nodes() {
nodes = append(nodes, node)
Expand All @@ -137,7 +144,7 @@ func fetchFile(ctx context.Context, logger logging.Logger, ref swarm.Address, cl
node := nodes[i%len(nodes)]
d, err := node.Client().DownloadFileBytes(ctx, ref, nil)
if err != nil {
logger.Infof("node: %s failed to fetch file: %v", node.Name(), err)
logger.Errorf("node: %s failed to fetch file: %v", node.Name(), err)
continue
}
return d, nil
Expand Down

0 comments on commit 30c4e49

Please sign in to comment.