1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix failure to get containers when deleting a layer

Signed-off-by: Darren Stahl <darst@microsoft.com>
This commit is contained in:
Darren Stahl 2016-11-10 14:07:11 -08:00
parent d0e1949d22
commit d4095a5902

View file

@ -17,6 +17,7 @@ import (
"strings" "strings"
"sync" "sync"
"syscall" "syscall"
"time"
"unsafe" "unsafe"
"github.com/Microsoft/go-winio" "github.com/Microsoft/go-winio"
@ -260,11 +261,30 @@ func (d *Driver) Remove(id string) error {
return err return err
} }
// This retry loop is due to a bug in Windows (Internal bug #9432268)
// if GetContainers fails with ErrVmcomputeOperationInvalidState
// it is a transient error. Retry until it succeeds.
var computeSystems []hcsshim.ContainerProperties
retryCount := 0
for {
// Get and terminate any template VMs that are currently using the layer // Get and terminate any template VMs that are currently using the layer
computeSystems, err := hcsshim.GetContainers(hcsshim.ComputeSystemQuery{}) computeSystems, err = hcsshim.GetContainers(hcsshim.ComputeSystemQuery{})
if err != nil { if err != nil {
if err == hcsshim.ErrVmcomputeOperationInvalidState {
if retryCount >= 5 {
// If we are unable to get the list of containers
// go ahead and attempt to delete the layer anyway
// as it will most likely work.
break
}
retryCount++
time.Sleep(2 * time.Second)
continue
}
return err return err
} }
break
}
for _, computeSystem := range computeSystems { for _, computeSystem := range computeSystems {
if strings.Contains(computeSystem.RuntimeImagePath, id) && computeSystem.IsRuntimeTemplate { if strings.Contains(computeSystem.RuntimeImagePath, id) && computeSystem.IsRuntimeTemplate {