Windows: Retry workaround for RS1/RS2 compute system enumeration
(cherry picked from commit 7761c69e239171c6b388d53d03619eacc49338a0)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -31,6 +31,7 @@ import ( |
| 31 | 31 |
"github.com/docker/docker/pkg/ioutils" |
| 32 | 32 |
"github.com/docker/docker/pkg/longpath" |
| 33 | 33 |
"github.com/docker/docker/pkg/reexec" |
| 34 |
+ "github.com/docker/docker/pkg/system" |
|
| 34 | 35 |
units "github.com/docker/go-units" |
| 35 | 36 |
"golang.org/x/sys/windows" |
| 36 | 37 |
) |
| ... | ... |
@@ -265,19 +266,35 @@ func (d *Driver) Remove(id string) error {
|
| 265 | 265 |
// it is a transient error. Retry until it succeeds. |
| 266 | 266 |
var computeSystems []hcsshim.ContainerProperties |
| 267 | 267 |
retryCount := 0 |
| 268 |
+ osv := system.GetOSVersion() |
|
| 268 | 269 |
for {
|
| 269 |
- // Get and terminate any template VMs that are currently using the layer |
|
| 270 |
+ // Get and terminate any template VMs that are currently using the layer. |
|
| 271 |
+ // Note: It is unfortunate that we end up in the graphdrivers Remove() call |
|
| 272 |
+ // for both containers and images, but the logic for template VMs is only |
|
| 273 |
+ // needed for images - specifically we are looking to see if a base layer |
|
| 274 |
+ // is in use by a template VM as a result of having started a Hyper-V |
|
| 275 |
+ // container at some point. |
|
| 276 |
+ // |
|
| 277 |
+ // We have a retry loop for ErrVmcomputeOperationInvalidState and |
|
| 278 |
+ // ErrVmcomputeOperationAccessIsDenied as there is a race condition |
|
| 279 |
+ // in RS1 and RS2 building during enumeration when a silo is going away |
|
| 280 |
+ // for example under it, in HCS. AccessIsDenied added to fix 30278. |
|
| 281 |
+ // |
|
| 282 |
+ // TODO @jhowardmsft - For RS3, we can remove the retries. Also consider |
|
| 283 |
+ // using platform APIs (if available) to get this more succinctly. Also |
|
| 284 |
+ // consider enlighting the Remove() interface to have context of why |
|
| 285 |
+ // the remove is being called - that could improve efficiency by not |
|
| 286 |
+ // enumerating compute systems during a remove of a container as it's |
|
| 287 |
+ // not required. |
|
| 270 | 288 |
computeSystems, err = hcsshim.GetContainers(hcsshim.ComputeSystemQuery{})
|
| 271 | 289 |
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. |
|
| 290 |
+ if (osv.Build < 15139) && |
|
| 291 |
+ ((err == hcsshim.ErrVmcomputeOperationInvalidState) || (err == hcsshim.ErrVmcomputeOperationAccessIsDenied)) {
|
|
| 292 |
+ if retryCount >= 500 {
|
|
| 277 | 293 |
break |
| 278 | 294 |
} |
| 279 | 295 |
retryCount++ |
| 280 |
- time.Sleep(2 * time.Second) |
|
| 296 |
+ time.Sleep(10 * time.Millisecond) |
|
| 281 | 297 |
continue |
| 282 | 298 |
} |
| 283 | 299 |
return err |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
# the following lines are in sorted order, FYI |
| 2 | 2 |
github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62 |
| 3 |
-github.com/Microsoft/hcsshim v0.5.9 |
|
| 3 |
+github.com/Microsoft/hcsshim v0.5.12 |
|
| 4 | 4 |
github.com/Microsoft/go-winio v0.3.8 |
| 5 | 5 |
github.com/Sirupsen/logrus v0.11.0 |
| 6 | 6 |
github.com/davecgh/go-spew 6d212800a42e8ab5c146b8ace3490ee17e5225f9 |
| ... | ... |
@@ -50,6 +50,10 @@ var ( |
| 50 | 50 |
|
| 51 | 51 |
// ErrProcNotFound is an error encountered when the the process cannot be found |
| 52 | 52 |
ErrProcNotFound = syscall.Errno(0x7f) |
| 53 |
+ |
|
| 54 |
+ // ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2 |
|
| 55 |
+ // builds when the underlying silo might be in the process of terminating. HCS was fixed in RS3. |
|
| 56 |
+ ErrVmcomputeOperationAccessIsDenied = syscall.Errno(0x5) |
|
| 53 | 57 |
) |
| 54 | 58 |
|
| 55 | 59 |
// ProcessError is an error encountered in HCS during an operation on a Process object |
| ... | ... |
@@ -41,30 +41,32 @@ type HvRuntime struct {
|
| 41 | 41 |
// ContainerConfig is used as both the input of CreateContainer |
| 42 | 42 |
// and to convert the parameters to JSON for passing onto the HCS |
| 43 | 43 |
type ContainerConfig struct {
|
| 44 |
- SystemType string // HCS requires this to be hard-coded to "Container" |
|
| 45 |
- Name string // Name of the container. We use the docker ID. |
|
| 46 |
- Owner string // The management platform that created this container |
|
| 47 |
- IsDummy bool // Used for development purposes. |
|
| 48 |
- VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
|
|
| 49 |
- IgnoreFlushesDuringBoot bool // Optimization hint for container startup in Windows |
|
| 50 |
- LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID |
|
| 51 |
- Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID |
|
| 52 |
- Credentials string `json:",omitempty"` // Credentials information |
|
| 53 |
- ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container. |
|
| 54 |
- ProcessorWeight uint64 `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default. |
|
| 55 |
- ProcessorMaximum int64 `json:",omitempty"` // CPU maximum usage percent 1..100 |
|
| 56 |
- StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS |
|
| 57 |
- StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second |
|
| 58 |
- StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller |
|
| 59 |
- MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes |
|
| 60 |
- HostName string // Hostname |
|
| 61 |
- MappedDirectories []MappedDir // List of mapped directories (volumes/mounts) |
|
| 62 |
- SandboxPath string `json:",omitempty"` // Location of unmounted sandbox. Used by Hyper-V containers only. Format %root%\windowsfilter |
|
| 63 |
- HvPartition bool // True if it a Hyper-V Container |
|
| 64 |
- EndpointList []string // List of networking endpoints to be attached to container |
|
| 65 |
- HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM |
|
| 66 |
- Servicing bool // True if this container is for servicing |
|
| 67 |
- AllowUnqualifiedDNSQuery bool // True to allow unqualified DNS name resolution |
|
| 44 |
+ SystemType string // HCS requires this to be hard-coded to "Container" |
|
| 45 |
+ Name string // Name of the container. We use the docker ID. |
|
| 46 |
+ Owner string // The management platform that created this container |
|
| 47 |
+ IsDummy bool // Used for development purposes. |
|
| 48 |
+ VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
|
|
| 49 |
+ IgnoreFlushesDuringBoot bool // Optimization hint for container startup in Windows |
|
| 50 |
+ LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID |
|
| 51 |
+ Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID |
|
| 52 |
+ Credentials string `json:",omitempty"` // Credentials information |
|
| 53 |
+ ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container. |
|
| 54 |
+ ProcessorWeight uint64 `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default. |
|
| 55 |
+ ProcessorMaximum int64 `json:",omitempty"` // CPU maximum usage percent 1..100 |
|
| 56 |
+ StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS |
|
| 57 |
+ StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second |
|
| 58 |
+ StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller |
|
| 59 |
+ MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes |
|
| 60 |
+ HostName string // Hostname |
|
| 61 |
+ MappedDirectories []MappedDir // List of mapped directories (volumes/mounts) |
|
| 62 |
+ SandboxPath string `json:",omitempty"` // Location of unmounted sandbox. Used by Hyper-V containers only. Format %root%\windowsfilter |
|
| 63 |
+ HvPartition bool // True if it a Hyper-V Container |
|
| 64 |
+ EndpointList []string // List of networking endpoints to be attached to container |
|
| 65 |
+ NetworkSharedContainerName string `json:",omitempty"` // Name (ID) of the container that we will share the network stack with. |
|
| 66 |
+ HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM |
|
| 67 |
+ Servicing bool // True if this container is for servicing |
|
| 68 |
+ AllowUnqualifiedDNSQuery bool // True to allow unqualified DNS name resolution |
|
| 69 |
+ DNSSearchList string `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution |
|
| 68 | 70 |
} |
| 69 | 71 |
|
| 70 | 72 |
type ComputeSystemQuery struct {
|