Merge pull request #52125 from yujuhong/fix-file-sync

Automatic merge from submit-queue (batch tested with PRs 52339, 52343, 52125, 52360, 52301)

dockershim: check if f.Sync() returns an error and surface it

```release-note
dockershim: check the error when syncing the checkpoint.
```
This commit is contained in:
Kubernetes Submit Queue 2017-09-12 21:45:56 -07:00 committed by GitHub
commit c6a9b1e198

View File

@ -76,7 +76,10 @@ func writeFileAndSync(filename string, data []byte, perm os.FileMode) error {
if err == nil && n < len(data) {
err = io.ErrShortWrite
}
f.Sync()
if err == nil {
// Only sync if the Write completed successfully.
err = f.Sync()
}
if err1 := f.Close(); err == nil {
err = err1
}