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

(Alternative to 1140): Record layers as incomplete before trying to create them #1148

Merged
merged 6 commits into from May 2, 2022

Commits on Apr 22, 2022

  1. Remove a redundant check

    err must be nil at that point.
    
    This also un-indents the success case, so that
    it proceeds as a straight-line code.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 22, 2022
    Copy the full SHA
    f8454e8 View commit details
    Browse the repository at this point in the history
  2. Always save an "incomplete" layer record first

    For now, this only causes two redundant saves for
    non-tarball layers, which is not useful; but it will allow
    us to build infrastructure for saving the incomplete record
    much earlier.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 22, 2022
    Copy the full SHA
    99789d1 View commit details
    Browse the repository at this point in the history
  3. Always use layerStore.Delete when recovering from failures

    ... so that we also remove the layer from layerStore.layers
    and the like.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 22, 2022
    Copy the full SHA
    e25b3d4 View commit details
    Browse the repository at this point in the history
  4. Don't use named return values in layerStore.Put

    We will need want to refer to "layer" in a defer
    block, in order to delete that layer. That doesn't work
    with "layer" being a named return value, because a
    (return nil, -1, ...) sets "layer" to nil.
    
    So, turn "layer" into a local variable, and use an unnamed
    return value. And beause all return values must be named,
    or unnamed, consistently, turn "size" and "err" also into
    local variables.
    
    Then decrease the scope of the "size" and "err" local variables
    to simplify understanding the code a bit.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 22, 2022
    Copy the full SHA
    ce3c7ff View commit details
    Browse the repository at this point in the history
  5. Consolidate the error handling cleanup into a defer

    ... so that we don't repeat it all over the place.
    
    Introduce a pretty ugly cleanupFailureContext variable
    for that purpose; still, it's better than copy&pasting everything.
    
    This will be even more useful soon.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 22, 2022
    Copy the full SHA
    c7ae082 View commit details
    Browse the repository at this point in the history
  6. Create a persistent record of an incomplete layer before creating it

    ... so that it can be also automatically cleaned up.
    
    Signed-off-by: Miloslav Trmač <mitr@redhat.com>
    mtrmac committed Apr 22, 2022
    Copy the full SHA
    70cd76b View commit details
    Browse the repository at this point in the history