diff --git a/go.mod b/go.mod index bc34744949..33a8429bbd 100644 --- a/go.mod +++ b/go.mod @@ -62,7 +62,7 @@ require ( github.com/spf13/cobra v1.10.1 github.com/spf13/pflag v1.0.10 github.com/stretchr/testify v1.11.1 - github.com/vbauerster/mpb/v8 v8.11.1 + github.com/vbauerster/mpb/v8 v8.11.2 github.com/vishvananda/netlink v1.3.1 go.podman.io/common v0.66.0 go.podman.io/image/v5 v5.38.0 diff --git a/go.sum b/go.sum index 70763b6da0..69bfb3f72b 100644 --- a/go.sum +++ b/go.sum @@ -420,8 +420,8 @@ github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY= github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vbatts/tar-split v0.12.1 h1:CqKoORW7BUWBe7UL/iqTVvkTBOF8UvOMKOIZykxnnbo= github.com/vbatts/tar-split v0.12.1/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= -github.com/vbauerster/mpb/v8 v8.11.1 h1:mQ7P4hSAydB2f93XzWb3jlHMvaHoNwGPaDz3aJXCEGA= -github.com/vbauerster/mpb/v8 v8.11.1/go.mod h1:WlKnGgq39HAZhrOLc74w3YnKgmjTiRDDKGXshXwUTro= +github.com/vbauerster/mpb/v8 v8.11.2 h1:OqLoHznUVU7SKS/WV+1dB5/hm20YLheYupiHhL5+M1Y= +github.com/vbauerster/mpb/v8 v8.11.2/go.mod h1:mEB/M353al1a7wMUNtiymmPsEkGlJgeJmtlbY5adCJ8= github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0= github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= diff --git a/vendor/github.com/vbauerster/mpb/v8/bar.go b/vendor/github.com/vbauerster/mpb/v8/bar.go index b1e3b7f537..27f9ce7a5e 100644 --- a/vendor/github.com/vbauerster/mpb/v8/bar.go +++ b/vendor/github.com/vbauerster/mpb/v8/bar.go @@ -5,7 +5,6 @@ import ( "context" "io" "strings" - "sync" "time" "github.com/acarl005/stripansi" @@ -266,21 +265,14 @@ func (b *Bar) EwmaIncrBy(n int, iterDur time.Duration) { func (b *Bar) EwmaIncrInt64(n int64, iterDur time.Duration) { select { case b.operateState <- func(s *bState) { - var wg sync.WaitGroup - wg.Add(len(s.ewmaDecorators)) for _, d := range s.ewmaDecorators { - // d := d // NOTE: uncomment for Go < 1.22, see /doc/faq#closures_and_goroutines - go func() { - defer wg.Done() - d.EwmaUpdate(n, iterDur) - }() + d.EwmaUpdate(n, iterDur) } s.current += n if s.triggerComplete && s.current >= s.total { s.current = s.total s.triggerCompletion(b) } - wg.Wait() }: case <-b.ctx.Done(): } @@ -295,21 +287,14 @@ func (b *Bar) EwmaSetCurrent(current int64, iterDur time.Duration) { select { case b.operateState <- func(s *bState) { n := current - s.current - var wg sync.WaitGroup - wg.Add(len(s.ewmaDecorators)) for _, d := range s.ewmaDecorators { - // d := d // NOTE: uncomment for Go < 1.22, see /doc/faq#closures_and_goroutines - go func() { - defer wg.Done() - d.EwmaUpdate(n, iterDur) - }() + d.EwmaUpdate(n, iterDur) } s.current = current if s.triggerComplete && s.current >= s.total { s.current = s.total s.triggerCompletion(b) } - wg.Wait() }: case <-b.ctx.Done(): } diff --git a/vendor/github.com/vbauerster/mpb/v8/container_option.go b/vendor/github.com/vbauerster/mpb/v8/container_option.go index 83c719c134..cf3a48eb34 100644 --- a/vendor/github.com/vbauerster/mpb/v8/container_option.go +++ b/vendor/github.com/vbauerster/mpb/v8/container_option.go @@ -1,6 +1,7 @@ package mpb import ( + "cmp" "io" "sync" "time" @@ -32,9 +33,7 @@ func WithWidth(width int) ContainerOption { // WithQueueLen sets buffer size of heap manager channel. Ideally it must be // kept at MAX value, where MAX is number of bars to be rendered at the same -// time. If len < MAX then backpressure to the scheduler will be increased as -// MAX-len extra goroutines will be launched at each render cycle. -// Default queue len is 128. +// time. Default queue len is 128. func WithQueueLen(len int) ContainerOption { return func(s *pState) { s.hmQueueLen = len @@ -78,21 +77,15 @@ func WithShutdownNotifier(ch chan<- interface{}) ContainerOption { // is not a terminal then auto refresh is disabled unless WithAutoRefresh // option is set. func WithOutput(w io.Writer) ContainerOption { - if w == nil { - w = io.Discard - } return func(s *pState) { - s.output = w + s.output = cmp.Or(w, io.Discard) } } // WithDebugOutput sets debug output. func WithDebugOutput(w io.Writer) ContainerOption { - if w == nil { - w = io.Discard - } return func(s *pState) { - s.debugOut = w + s.debugOut = cmp.Or(w, io.Discard) } } diff --git a/vendor/github.com/vbauerster/mpb/v8/decor/decorator.go b/vendor/github.com/vbauerster/mpb/v8/decor/decorator.go index d3ee18bf9e..47458616c5 100644 --- a/vendor/github.com/vbauerster/mpb/v8/decor/decorator.go +++ b/vendor/github.com/vbauerster/mpb/v8/decor/decorator.go @@ -165,7 +165,7 @@ func (wc *WC) Init() WC { wc.fill = runewidth.FillLeft } if (wc.C & DSyncWidth) != 0 { - // it's deliberate choice to override wsync on each Init() call, + // it's deliberate choice to override wc.sync on each Init() call, // this way globals like WCSyncSpace can be reused wc.sync = &Sync{make(chan int, 1), make(chan int, 1)} } diff --git a/vendor/github.com/vbauerster/mpb/v8/heap_manager.go b/vendor/github.com/vbauerster/mpb/v8/heap_manager.go index ff8cb04232..a022b742e9 100644 --- a/vendor/github.com/vbauerster/mpb/v8/heap_manager.go +++ b/vendor/github.com/vbauerster/mpb/v8/heap_manager.go @@ -17,7 +17,6 @@ const ( h_iter h_fix h_state - h_end ) type heapRequest struct { @@ -38,13 +37,23 @@ type fixData struct { lazy bool } -func (m heapManager) run() { +func (m heapManager) run(shutdownNotifier chan<- interface{}) { var bHeap barHeap - var pMatrix map[int][]*decor.Sync - var aMatrix map[int][]*decor.Sync + done := make(chan struct{}) + defer func() { + close(done) + if shutdownNotifier != nil { + select { + case shutdownNotifier <- []*Bar(bHeap): + case <-time.After(time.Second): + } + } + }() var sync bool var prevLen int + var pMatrix map[int][]*decor.Sync + var aMatrix map[int][]*decor.Sync for req := range m { switch req.cmd { @@ -63,8 +72,8 @@ func (m heapManager) run() { } sync, prevLen = false, bHeap.Len() } - syncWidth(pMatrix) - syncWidth(aMatrix) + syncWidth(pMatrix, done) + syncWidth(aMatrix, done) case h_push: data := req.data.(pushData) heap.Push(&bHeap, data.bar) @@ -92,17 +101,6 @@ func (m heapManager) run() { case h_state: ch := req.data.(chan<- bool) ch <- sync || prevLen != bHeap.Len() - case h_end: - ch := req.data.(chan<- interface{}) - if ch != nil { - go func() { - select { - case ch <- []*Bar(bHeap): - case <-time.After(time.Second): - } - }() - } - return } } } @@ -113,14 +111,7 @@ func (m heapManager) sync() { func (m heapManager) push(b *Bar, sync bool) { data := pushData{b, sync} - req := heapRequest{cmd: h_push, data: data} - select { - case m <- req: - default: - go func() { - m <- req - }() - } + m <- heapRequest{cmd: h_push, data: data} } func (m heapManager) iter(req ...iterRequest) { @@ -136,22 +127,22 @@ func (m heapManager) state(ch chan<- bool) { m <- heapRequest{cmd: h_state, data: ch} } -func (m heapManager) end(ch chan<- interface{}) { - m <- heapRequest{cmd: h_end, data: ch} -} - -func syncWidth(matrix map[int][]*decor.Sync) { +func syncWidth(matrix map[int][]*decor.Sync, done <-chan struct{}) { for _, column := range matrix { - go maxWidthDistributor(column) + go maxWidthDistributor(column, done) } } -func maxWidthDistributor(column []*decor.Sync) { +func maxWidthDistributor(column []*decor.Sync, done <-chan struct{}) { var maxWidth int for _, s := range column { - w := <-s.Tx - if w > maxWidth { - maxWidth = w + select { + case w := <-s.Tx: + if w > maxWidth { + maxWidth = w + } + case <-done: + return } } for _, s := range column { diff --git a/vendor/github.com/vbauerster/mpb/v8/progress.go b/vendor/github.com/vbauerster/mpb/v8/progress.go index 1aa4ff7190..94c699b379 100644 --- a/vendor/github.com/vbauerster/mpb/v8/progress.go +++ b/vendor/github.com/vbauerster/mpb/v8/progress.go @@ -2,6 +2,7 @@ package mpb import ( "bytes" + "cmp" "context" "fmt" "io" @@ -110,8 +111,8 @@ func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress { } p.pwg.Add(1) + go s.hm.run(s.shutdownNotifier) go p.serve(s, cw) - go s.hm.run() return p } @@ -243,7 +244,10 @@ func (p *Progress) Shutdown() { } func (p *Progress) serve(s *pState, cw *cwriter.Writer) { - defer p.pwg.Done() + defer func() { + close(s.hm) + p.pwg.Done() + }() var err error var w *cwriter.Writer renderReq := s.renderReq @@ -297,7 +301,6 @@ func (p *Progress) serve(s *pState, cw *cwriter.Writer) { s.hm.state(update) } } - s.hm.end(s.shutdownNotifier) return } } @@ -334,7 +337,7 @@ func (s *pState) manualRefreshListener(done chan struct{}) { } func (s *pState) render(cw *cwriter.Writer) (err error) { - req := make(iterRequest, 1) + req := make(iterRequest, 2) s.hm.sync() s.hm.iter(req, req) @@ -345,11 +348,7 @@ func (s *pState) render(cw *cwriter.Writer) (err error) { return err } } else { - if s.reqWidth > 0 { - width = s.reqWidth - } else { - width = 80 - } + width = cmp.Or(s.reqWidth, 80) height = width } diff --git a/vendor/modules.txt b/vendor/modules.txt index 921b7f4775..749874eae1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -701,7 +701,7 @@ github.com/ulikunitz/xz/lzma github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/storage -# github.com/vbauerster/mpb/v8 v8.11.1 +# github.com/vbauerster/mpb/v8 v8.11.2 ## explicit; go 1.24.0 github.com/vbauerster/mpb/v8 github.com/vbauerster/mpb/v8/cwriter