Skip to content

Commit def3069

Browse files
authored
Merge pull request containerd#2245 from darrenstahlmsft/CloseFail
Make hcsshim layerwriter close a fatal error
2 parents 7996320 + 84f6fce commit def3069

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

archive/tar_windows.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535

3636
"github.com/Microsoft/go-winio"
3737
"github.com/Microsoft/hcsshim"
38-
"github.com/containerd/containerd/log"
3938
"github.com/containerd/containerd/sys"
4039
)
4140

@@ -180,8 +179,12 @@ func applyWindowsLayer(ctx context.Context, root string, tr *tar.Reader, options
180179
return 0, err
181180
}
182181
defer func() {
183-
if err := w.Close(); err != nil {
184-
log.G(ctx).Errorf("failed to close layer writer: %v", err)
182+
if err2 := w.Close(); err2 != nil {
183+
// This error should not be discarded as a failure here
184+
// could result in an invalid layer on disk
185+
if err == nil {
186+
err = err2
187+
}
185188
}
186189
}()
187190

0 commit comments

Comments
 (0)