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

Improve progress bars, and update mpb #1530

Merged
merged 11 commits into from Apr 27, 2022
Merged

Commits on Apr 26, 2022

  1. Improve the documentation of the objects in copy/progress_reader.go a…

    … tiny bit
    
    Should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 26, 2022
    Copy the full SHA
    4ba5575 View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2022

  1. Move progress-bar-specific utilities from copy.go to new progress_bar…

    …s.go
    
    Let's try to make copy.go shorter, and consolidate progress bar code to
    new copy/progress_bars.go.
    
    First, move the code from copy.go.
    
    Only moves unchanged code, should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    66100ac View commit details
    Browse the repository at this point in the history
  2. Move blobChunkAccessorProxy to copy/progress_bars.go

    Second part: Move blobChunkAccessorProxy to the newly established
    progress_bars.go.
    
    Only moves unchanged code, should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    9c46add View commit details
    Browse the repository at this point in the history
  3. Rename progress_reader* to progress_channel*

    ... to cleanly differentiate the code related to chan<- types.ProgressProperties
    from the code related to progress bars.
    
    Only moves unchanged code, should not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    c8c17e2 View commit details
    Browse the repository at this point in the history
  4. Remove a redundant bar.SetTotal

    The same srcInfo.size was passed to createProgressBar, so this
    does nothing at best if size is known; if it is unknown,
    it seems to effectively also be a no-op with a recent version of mpb
    (it sets the total value to 0, the current progress at the time,
    but it doesn't enable auto-complete, so it doesn't make a difference).
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    5a56b1e View commit details
    Browse the repository at this point in the history
  5. Add more operations within the scope of progress bars

    Already draw the progress bar before opening the source's layer
    or config blob, so that the users can have a visual indication
    of something related to that blob happening if it takes too long.
    
    (For the .ConfigBlob() call, this might not make a difference,
    because in _some_ cases we trigger reading the config via
    .OCIConfig in checkImageDestinationForCurrentRuntime(), and the
    config blob is cached, but it might make a difference in the other
    cases, and it doesn't hurt in this one.)
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    69dde2e View commit details
    Browse the repository at this point in the history
  6. Track the original source blob's size in the progress bar

    In particular, if the source is compressed, track the full size
    of the original compressed blob in the progress bar, even if the decompressed
    version has a different size (e.g. because the encryption adds a header or a MAC).
    
    This original size is easy to determine and eaiser to explain to users; so let's do
    the simple thing.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    83bc18a View commit details
    Browse the repository at this point in the history
  7. Wrap a *mpb.Bar in a *progressBar

    This will allow us to add more state and methods to the bar
    object, without copy&pasting.
    
    For now, this just wraps one pointer in another, and should
    not change behavior.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    c444bc3 View commit details
    Browse the repository at this point in the history
  8. Add progressBar.mark100PercentComplete, and use it on all progress bars

    This correctly handles both the "size known" and the "size unknown" cases,
    and because we now record the originally-configured progress bar size
    in the progressBar struct, the caller doesn't need to track it.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    f090300 View commit details
    Browse the repository at this point in the history
  9. Don't call bar.SetRefill with negative numbers

    If srcInfo.Size == -1, the progress bar is not showing the
    refill value anyway (customPartialBlobDecorFunc is only
    used if size is known), so don't bother calling this function
    with nonsense data, if anything, at least to emphasize that this
    condition is, in principle, possible.
    
    Should not affect behavior, hopefully.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    2837c2a View commit details
    Browse the repository at this point in the history
  10. Update to github.com/vbauerster/mpb/v7 v7.4.1

    ... so that we test all of this with the new semantics.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 27, 2022
    Copy the full SHA
    3a9550c View commit details
    Browse the repository at this point in the history