Merge pull request #5328 from kevpar/win-ci-cleanup

Fix error case in Windows layer cleanup
This commit is contained in:
Michael Crosby 2021-06-03 11:15:39 -04:00 committed by GitHub
commit ada96ec192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -311,9 +311,10 @@ func cleanupWCOWLayer(layerPath string) error {
HomeDir: filepath.Dir(layerPath),
}
// ERROR_DEV_NOT_EXIST is returned if the layer is not currently prepared.
// ERROR_DEV_NOT_EXIST is returned if the layer is not currently prepared or activated.
// ERROR_FLT_INSTANCE_NOT_FOUND is returned if the layer is currently activated but not prepared.
if err := hcsshim.UnprepareLayer(info, filepath.Base(layerPath)); err != nil {
if hcserror, ok := err.(*hcsshim.HcsError); !ok || hcserror.Err != windows.ERROR_DEV_NOT_EXIST {
if hcserror, ok := err.(*hcsshim.HcsError); !ok || (hcserror.Err != windows.ERROR_DEV_NOT_EXIST && hcserror.Err != syscall.Errno(windows.ERROR_FLT_INSTANCE_NOT_FOUND)) {
return errors.Wrapf(err, "failed to unprepare %s", layerPath)
}
}