Signed-off-by: Darren Stahl <darst@microsoft.com>
Darren Stahl authored on 2016/11/11 07:07:11... | ... |
@@ -17,6 +17,7 @@ import ( |
17 | 17 |
"strings" |
18 | 18 |
"sync" |
19 | 19 |
"syscall" |
20 |
+ "time" |
|
20 | 21 |
"unsafe" |
21 | 22 |
|
22 | 23 |
"github.com/Microsoft/go-winio" |
... | ... |
@@ -260,10 +261,29 @@ func (d *Driver) Remove(id string) error { |
260 | 260 |
return err |
261 | 261 |
} |
262 | 262 |
|
263 |
- // Get and terminate any template VMs that are currently using the layer |
|
264 |
- computeSystems, err := hcsshim.GetContainers(hcsshim.ComputeSystemQuery{}) |
|
265 |
- if err != nil { |
|
266 |
- return err |
|
263 |
+ // This retry loop is due to a bug in Windows (Internal bug #9432268) |
|
264 |
+ // if GetContainers fails with ErrVmcomputeOperationInvalidState |
|
265 |
+ // it is a transient error. Retry until it succeeds. |
|
266 |
+ var computeSystems []hcsshim.ContainerProperties |
|
267 |
+ retryCount := 0 |
|
268 |
+ for { |
|
269 |
+ // Get and terminate any template VMs that are currently using the layer |
|
270 |
+ computeSystems, err = hcsshim.GetContainers(hcsshim.ComputeSystemQuery{}) |
|
271 |
+ if err != nil { |
|
272 |
+ if err == hcsshim.ErrVmcomputeOperationInvalidState { |
|
273 |
+ if retryCount >= 5 { |
|
274 |
+ // If we are unable to get the list of containers |
|
275 |
+ // go ahead and attempt to delete the layer anyway |
|
276 |
+ // as it will most likely work. |
|
277 |
+ break |
|
278 |
+ } |
|
279 |
+ retryCount++ |
|
280 |
+ time.Sleep(2 * time.Second) |
|
281 |
+ continue |
|
282 |
+ } |
|
283 |
+ return err |
|
284 |
+ } |
|
285 |
+ break |
|
267 | 286 |
} |
268 | 287 |
|
269 | 288 |
for _, computeSystem := range computeSystems { |