Skip to content

Commit c4fc4bc

Browse files
refactor: enhance clarity in Options struct and improve upload logic comments
1 parent f02d50b commit c4fc4bc

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

pkg/check/storageradius/storageradius.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type Options struct {
3030
PushersIdleWait time.Duration // max wait for backlog to settle
3131
DiluteDepth uint64 // depth to dilute to (32 is max)
3232
DiluteWait time.Duration // timeout for radius decrease
33-
UploadWavePause time.Duration // pause between upload waves
33+
UploadWavePause time.Duration // pause between upload dispatches, so the watcher can catch up
3434
UploadTimeout time.Duration // timeout per upload request
3535
PostageAmount int64
3636
PostageLabel string
@@ -375,15 +375,17 @@ func (c *Check) pipelineAlreadyFull(ctx context.Context, batches []nodeBatch, pl
375375
if err != nil {
376376
continue
377377
}
378-
// A radius already above zero means bee has reacted; nothing to add.
379-
if status.StorageRadius > 0 {
380-
return int(status.ReserveSize), true
381-
}
382378

383379
inPipeline := int(status.ReserveSize)
384380
if debugStore, err := batch.node.API().DebugStore.GetDebugStore(ctx); err == nil {
385381
inPipeline += debugStore.Upload.PendingUpload
386382
}
383+
384+
// A radius already above 0 means bee has reached the goal
385+
if status.StorageRadius > 0 {
386+
return inPipeline, true
387+
}
388+
387389
chunks = max(chunks, inPipeline)
388390
}
389391

@@ -416,8 +418,7 @@ func (c *Check) upload(ctx context.Context, batches []nodeBatch, plan uploadPlan
416418

417419
for i := range totalUploads {
418420
if i > 0 && i%len(batches) == 0 {
419-
// Pause between waves so the watcher can poll and detect when to stop.
420-
// Without this, uploads finish before the watcher sees them.
421+
// Pause between waves so the watcher's independent poll loop gets a chance to observe pipeline growth and call stopUploading before the next wave fires off. Without this, a fast cluster can spin up all uploads within a single PollInterval and the watcher never sees them.
421422
select {
422423
case <-enough:
423424
case <-groupCtx.Done():
@@ -483,14 +484,15 @@ func (c *Check) radiusUnchangedError(chunksBefore, chunksAfter, uploadedChunks i
483484
}
484485

485486
// reservesIsAtCapacity checks if all nodes have reserves at 95% or higher.
487+
// An unreachable node counts as not at capacity, since we can't confirm it.
486488
func (c *Check) reservesIsAtCapacity(ctx context.Context, nodes orchestration.ClientList, options Options) bool {
487489
full := options.ReserveCapacity * 95 / 100
488490
sawNode := false
489491

490492
for _, node := range nodes {
491493
status, err := node.Status(ctx)
492494
if err != nil {
493-
continue
495+
return false
494496
}
495497
sawNode = true
496498
if int(status.ReserveSize) < full {

0 commit comments

Comments
 (0)