Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Jan 11, 2026

No description provided.

@dobrac dobrac added the improvement Improvement for current functionality label Jan 11, 2026
return fmt.Errorf("failed to create sandbox proxy: %w", err)
}
go func() {
err := sandboxProxy.Start(parentCtx)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goroutine at line 144 uses parentCtx instead of ctx for starting sandboxProxy. This means sandboxProxy.Start() ignores the 10-minute operation timeout and could run indefinitely even if the optimization fails or times out. Consider using ctx instead for proper timeout propagation.

noop.NewMeterProvider(),
)
go func() {
err := tcpFirewall.Start(ctx)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tcpFirewall.Start() goroutine uses ctx (the timeout context) but tcpFirewall.Close() in the defer uses parentCtx. This creates inconsistency - if the timeout fires and cancels ctx, the Start goroutine will stop, but the Close() will use a different context. Consider using the same context for both operations.

return fmt.Errorf("could not create device pool: %w", err)
}
go func() {
devicePool.Populate(ctx)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The devicePool.Populate() and networkPool.Populate() goroutines use ctx (timeout context). If the optimization completes or times out before these pools finish populating, the goroutines will be canceled but may still be running during cleanup. This could cause resource leaks or race conditions. Consider waiting for these goroutines to complete or using an errgroup to manage them properly.

)

// Create build context
uploadErrGroup := &errgroup.Group{}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The uploadErrGroup created at line 245 is never waited on with .Wait(). If any upload operations are scheduled via this errgroup during optimization, their errors will be silently ignored and goroutines may be leaked when the function returns. Either add a defer with uploadErrGroup.Wait() or document that no uploads are expected during optimization.

@dobrac dobrac force-pushed the feat/memory-prefetching branch from f342294 to 68db802 Compare January 12, 2026 11:51
@dobrac dobrac force-pushed the feat/add-command-for-existing-builds-optimization branch from 99db1f3 to bde27e0 Compare January 12, 2026 12:38
Base automatically changed from feat/memory-prefetching to main January 12, 2026 15:55
@dobrac dobrac force-pushed the feat/add-command-for-existing-builds-optimization branch from bde27e0 to a01add7 Compare January 12, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants