Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wait for push and fix logs #375

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 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,7 @@ 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.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 +124,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 +135,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)
var nodes []orchestration.Node
for _, node := range cluster.Nodes() {
nodes = append(nodes, node)
Expand All @@ -137,7 +145,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