Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

lib/internal/backend/repository: check if closer is nil before closing#162

Merged
iaguis merged 1 commit intoappc:masterfrom
cgonyeo:master
May 26, 2016
Merged

lib/internal/backend/repository: check if closer is nil before closing#162
iaguis merged 1 commit intoappc:masterfrom
cgonyeo:master

Conversation

@cgonyeo
Copy link
Copy Markdown
Member

@cgonyeo cgonyeo commented May 25, 2016

If any layers being fetched encountered an error, that won't be caught
by the main goroutine until after it's attempted to close all of the
HTTP bodies, but if there was an error the body could be nil. The bodies
should be closed before checking for errors, as there may be some valid
connections, but each body should only be closed if it's not nil.

This commit adds that nil check.

Fixes (at least when I run the test locally) https://semaphoreci.com/coreos/rkt/branches/pull-request-2691/builds/3

cc @iaguis

If any layers being fetched encountered an error, that won't be caught
by the main goroutine until after it's attempted to close all of the
HTTP bodies, but if there was an error the body could be nil. The bodies
should be closed before checking for errors, as there may be some valid
connections, but each body should only be closed if it's not nil.

This commit adds that nil check.
@iaguis iaguis added this to the v0.10.1 milestone May 25, 2016
@@ -125,7 +125,9 @@ func (rb *RepositoryBackend) buildACIV2(layerIDs []string, dockerURL *types.Pars
return nil, nil, err
}
for _, closer := range closers {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i) closers can just be []io.Closer
ii) why not only append to closers if getLayerV2 returns a nil err?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For ii, it's because I was to be very explicit that layerFiles must be the same length as layerIDs (which is clear in layerFiles := make([]*os.File, len(layerIDs))), and closers is just following the same pattern.

@jonboulle
Copy link
Copy Markdown
Contributor

looks okay but I'll leave it to @iaguis

@iaguis
Copy link
Copy Markdown
Member

iaguis commented May 26, 2016

LGTM

@iaguis iaguis merged commit 9f0b02b into appc:master May 26, 2016
@jonboulle jonboulle mentioned this pull request May 26, 2016
@iaguis iaguis modified the milestones: v0.11.0, v0.10.1 May 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants