Merge pull request #5929 from dcantah/update-hcsshim-0.8.21

go.mod: Update hcsshim to v0.8.21
This commit is contained in:
Phil Estes 2021-09-03 08:45:41 -04:00 committed by GitHub
commit 61a46e9fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 151 additions and 40 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.16
require ( require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8 github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8
github.com/Microsoft/go-winio v0.5.0 github.com/Microsoft/go-winio v0.5.0
github.com/Microsoft/hcsshim v0.8.18 github.com/Microsoft/hcsshim v0.8.21
github.com/containerd/aufs v1.0.0 github.com/containerd/aufs v1.0.0
github.com/containerd/btrfs v1.0.0 github.com/containerd/btrfs v1.0.0
github.com/containerd/cgroups v1.0.1 github.com/containerd/cgroups v1.0.1

4
go.sum
View File

@ -45,8 +45,8 @@ github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXG
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600= github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600=
github.com/Microsoft/hcsshim v0.8.18 h1:cYnKADiM1869gvBpos3YCteeT6sZLB48lB5dmMMs8Tg= github.com/Microsoft/hcsshim v0.8.21 h1:btRfUDThBE5IKcvI8O8jOiIkujUsAMBSRsYDYmEi6oM=
github.com/Microsoft/hcsshim v0.8.18/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=

View File

@ -3,7 +3,7 @@ module github.com/containerd/containerd/integration/client
go 1.15 go 1.15
require ( require (
github.com/Microsoft/hcsshim v0.8.18 github.com/Microsoft/hcsshim v0.8.21
github.com/Microsoft/hcsshim/test v0.0.0-20210408205431-da33ecd607e1 github.com/Microsoft/hcsshim/test v0.0.0-20210408205431-da33ecd607e1
github.com/containerd/cgroups v1.0.1 github.com/containerd/cgroups v1.0.1
// the actual version of containerd is replaced with the code at the root of this repository // the actual version of containerd is replaced with the code at the root of this repository

View File

@ -44,8 +44,8 @@ github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpz
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg= github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00= github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00=
github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600= github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600=
github.com/Microsoft/hcsshim v0.8.18 h1:cYnKADiM1869gvBpos3YCteeT6sZLB48lB5dmMMs8Tg= github.com/Microsoft/hcsshim v0.8.21 h1:btRfUDThBE5IKcvI8O8jOiIkujUsAMBSRsYDYmEi6oM=
github.com/Microsoft/hcsshim v0.8.18/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
github.com/Microsoft/hcsshim/test v0.0.0-20210408205431-da33ecd607e1 h1:pVKfKyPkXna29XlGjxSr9J0A7vNucOUHZ/2ClcTWalw= github.com/Microsoft/hcsshim/test v0.0.0-20210408205431-da33ecd607e1 h1:pVKfKyPkXna29XlGjxSr9J0A7vNucOUHZ/2ClcTWalw=
github.com/Microsoft/hcsshim/test v0.0.0-20210408205431-da33ecd607e1/go.mod h1:Cmvnhlie15Ha2UYrJs9EhgSx76Bq9RV2FgfEiT78GhI= github.com/Microsoft/hcsshim/test v0.0.0-20210408205431-da33ecd607e1/go.mod h1:Cmvnhlie15Ha2UYrJs9EhgSx76Bq9RV2FgfEiT78GhI=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=

View File

@ -59,7 +59,7 @@ var (
// ErrVmcomputeOperationInvalidState is an error encountered when the compute system is not in a valid state for the requested operation // ErrVmcomputeOperationInvalidState is an error encountered when the compute system is not in a valid state for the requested operation
ErrVmcomputeOperationInvalidState = hcs.ErrVmcomputeOperationInvalidState ErrVmcomputeOperationInvalidState = hcs.ErrVmcomputeOperationInvalidState
// ErrProcNotFound is an error encountered when the the process cannot be found // ErrProcNotFound is an error encountered when a procedure look up fails.
ErrProcNotFound = hcs.ErrProcNotFound ErrProcNotFound = hcs.ErrProcNotFound
// ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2 // ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2
@ -159,7 +159,7 @@ func (e *ProcessError) Error() string {
// IsNotExist checks if an error is caused by the Container or Process not existing. // IsNotExist checks if an error is caused by the Container or Process not existing.
// Note: Currently, ErrElementNotFound can mean that a Process has either // Note: Currently, ErrElementNotFound can mean that a Process has either
// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist // already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
// will currently return true when the error is ErrElementNotFound or ErrProcNotFound. // will currently return true when the error is ErrElementNotFound.
func IsNotExist(err error) bool { func IsNotExist(err error) bool {
if _, ok := err.(EndpointNotFoundError); ok { if _, ok := err.(EndpointNotFoundError); ok {
return true return true
@ -192,7 +192,7 @@ func IsTimeout(err error) bool {
// a Container or Process being already stopped. // a Container or Process being already stopped.
// Note: Currently, ErrElementNotFound can mean that a Process has either // Note: Currently, ErrElementNotFound can mean that a Process has either
// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist // already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
// will currently return true when the error is ErrElementNotFound or ErrProcNotFound. // will currently return true when the error is ErrElementNotFound.
func IsAlreadyStopped(err error) bool { func IsAlreadyStopped(err error) bool {
return hcs.IsAlreadyStopped(getInnerError(err)) return hcs.IsAlreadyStopped(getInnerError(err))
} }

View File

@ -127,7 +127,10 @@ func platformDoesNotSupportError(featureName string) error {
// V2ApiSupported returns an error if the HCN version does not support the V2 Apis. // V2ApiSupported returns an error if the HCN version does not support the V2 Apis.
func V2ApiSupported() error { func V2ApiSupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.Api.V2 { if supported.Api.V2 {
return nil return nil
} }
@ -143,7 +146,10 @@ func V2SchemaVersion() SchemaVersion {
// RemoteSubnetSupported returns an error if the HCN version does not support Remote Subnet policies. // RemoteSubnetSupported returns an error if the HCN version does not support Remote Subnet policies.
func RemoteSubnetSupported() error { func RemoteSubnetSupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.RemoteSubnet { if supported.RemoteSubnet {
return nil return nil
} }
@ -152,7 +158,10 @@ func RemoteSubnetSupported() error {
// HostRouteSupported returns an error if the HCN version does not support Host Route policies. // HostRouteSupported returns an error if the HCN version does not support Host Route policies.
func HostRouteSupported() error { func HostRouteSupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.HostRoute { if supported.HostRoute {
return nil return nil
} }
@ -161,7 +170,10 @@ func HostRouteSupported() error {
// DSRSupported returns an error if the HCN version does not support Direct Server Return. // DSRSupported returns an error if the HCN version does not support Direct Server Return.
func DSRSupported() error { func DSRSupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.DSR { if supported.DSR {
return nil return nil
} }
@ -170,7 +182,10 @@ func DSRSupported() error {
// Slash32EndpointPrefixesSupported returns an error if the HCN version does not support configuring endpoints with /32 prefixes. // Slash32EndpointPrefixesSupported returns an error if the HCN version does not support configuring endpoints with /32 prefixes.
func Slash32EndpointPrefixesSupported() error { func Slash32EndpointPrefixesSupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.Slash32EndpointPrefixes { if supported.Slash32EndpointPrefixes {
return nil return nil
} }
@ -179,7 +194,10 @@ func Slash32EndpointPrefixesSupported() error {
// AclSupportForProtocol252Supported returns an error if the HCN version does not support HNS ACL Policies to support protocol 252 for VXLAN. // AclSupportForProtocol252Supported returns an error if the HCN version does not support HNS ACL Policies to support protocol 252 for VXLAN.
func AclSupportForProtocol252Supported() error { func AclSupportForProtocol252Supported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.AclSupportForProtocol252 { if supported.AclSupportForProtocol252 {
return nil return nil
} }
@ -188,7 +206,10 @@ func AclSupportForProtocol252Supported() error {
// SessionAffinitySupported returns an error if the HCN version does not support Session Affinity. // SessionAffinitySupported returns an error if the HCN version does not support Session Affinity.
func SessionAffinitySupported() error { func SessionAffinitySupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.SessionAffinity { if supported.SessionAffinity {
return nil return nil
} }
@ -197,7 +218,10 @@ func SessionAffinitySupported() error {
// IPv6DualStackSupported returns an error if the HCN version does not support IPv6DualStack. // IPv6DualStackSupported returns an error if the HCN version does not support IPv6DualStack.
func IPv6DualStackSupported() error { func IPv6DualStackSupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.IPv6DualStack { if supported.IPv6DualStack {
return nil return nil
} }
@ -206,7 +230,10 @@ func IPv6DualStackSupported() error {
//L4proxySupported returns an error if the HCN verison does not support L4Proxy //L4proxySupported returns an error if the HCN verison does not support L4Proxy
func L4proxyPolicySupported() error { func L4proxyPolicySupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.L4Proxy { if supported.L4Proxy {
return nil return nil
} }
@ -215,7 +242,10 @@ func L4proxyPolicySupported() error {
// L4WfpProxySupported returns an error if the HCN verison does not support L4WfpProxy // L4WfpProxySupported returns an error if the HCN verison does not support L4WfpProxy
func L4WfpProxyPolicySupported() error { func L4WfpProxyPolicySupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.L4WfpProxy { if supported.L4WfpProxy {
return nil return nil
} }
@ -224,7 +254,10 @@ func L4WfpProxyPolicySupported() error {
// SetPolicySupported returns an error if the HCN version does not support SetPolicy. // SetPolicySupported returns an error if the HCN version does not support SetPolicy.
func SetPolicySupported() error { func SetPolicySupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.SetPolicy { if supported.SetPolicy {
return nil return nil
} }
@ -233,7 +266,10 @@ func SetPolicySupported() error {
// VxlanPortSupported returns an error if the HCN version does not support configuring the VXLAN TCP port. // VxlanPortSupported returns an error if the HCN version does not support configuring the VXLAN TCP port.
func VxlanPortSupported() error { func VxlanPortSupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.VxlanPort { if supported.VxlanPort {
return nil return nil
} }
@ -242,7 +278,10 @@ func VxlanPortSupported() error {
// TierAclPolicySupported returns an error if the HCN version does not support configuring the TierAcl. // TierAclPolicySupported returns an error if the HCN version does not support configuring the TierAcl.
func TierAclPolicySupported() error { func TierAclPolicySupported() error {
supported := GetSupportedFeatures() supported, err := GetCachedSupportedFeatures()
if err != nil {
return err
}
if supported.TierAcl { if supported.TierAcl {
return nil return nil
} }

View File

@ -1,9 +1,21 @@
package hcn package hcn
import ( import (
"fmt"
"sync"
"github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var (
// featuresOnce handles assigning the supported features and printing the supported info to stdout only once to avoid unnecessary work
// multiple times.
featuresOnce sync.Once
featuresErr error
supportedFeatures SupportedFeatures
)
// SupportedFeatures are the features provided by the Service. // SupportedFeatures are the features provided by the Service.
type SupportedFeatures struct { type SupportedFeatures struct {
Acl AclFeatures `json:"ACL"` Acl AclFeatures `json:"ACL"`
@ -36,17 +48,41 @@ type ApiSupport struct {
V2 bool `json:"V2"` V2 bool `json:"V2"`
} }
// GetSupportedFeatures returns the features supported by the Service. // GetCachedSupportedFeatures returns the features supported by the Service and an error if the query failed. If this has been called
func GetSupportedFeatures() SupportedFeatures { // before it will return the supported features and error received from the first call. This can be used to optimize if many calls to the
var features SupportedFeatures // various hcn.IsXSupported methods need to be made.
func GetCachedSupportedFeatures() (SupportedFeatures, error) {
// Only query the HCN version and features supported once, instead of everytime this is invoked. The logs are useful to
// debug incidents where there's confusion on if a feature is supported on the host machine. The sync.Once helps to avoid redundant
// spam of these anytime a check needs to be made for if an HCN feature is supported. This is a common occurrence in kube-proxy
// for example.
featuresOnce.Do(func() {
supportedFeatures, featuresErr = getSupportedFeatures()
})
globals, err := GetGlobals() return supportedFeatures, featuresErr
}
// GetSupportedFeatures returns the features supported by the Service.
//
// Deprecated: Use GetCachedSupportedFeatures instead.
func GetSupportedFeatures() SupportedFeatures {
features, err := GetCachedSupportedFeatures()
if err != nil { if err != nil {
// Expected on pre-1803 builds, all features will be false/unsupported // Expected on pre-1803 builds, all features will be false/unsupported
logrus.Debugf("Unable to obtain globals: %s", err) logrus.WithError(err).Errorf("unable to obtain supported features")
return features
}
return features return features
} }
func getSupportedFeatures() (SupportedFeatures, error) {
var features SupportedFeatures
globals, err := GetGlobals()
if err != nil {
// It's expected if this fails once, it should always fail. It should fail on pre 1803 builds for example.
return SupportedFeatures{}, errors.Wrap(err, "failed to query HCN version number: this is expected on pre 1803 builds.")
}
features.Acl = AclFeatures{ features.Acl = AclFeatures{
AclAddressLists: isFeatureSupported(globals.Version, HNSVersion1803), AclAddressLists: isFeatureSupported(globals.Version, HNSVersion1803),
AclNoHostRulePriority: isFeatureSupported(globals.Version, HNSVersion1803), AclNoHostRulePriority: isFeatureSupported(globals.Version, HNSVersion1803),
@ -72,7 +108,12 @@ func GetSupportedFeatures() SupportedFeatures {
features.L4WfpProxy = isFeatureSupported(globals.Version, L4WfpProxyPolicyVersion) features.L4WfpProxy = isFeatureSupported(globals.Version, L4WfpProxyPolicyVersion)
features.TierAcl = isFeatureSupported(globals.Version, TierAclPolicyVersion) features.TierAcl = isFeatureSupported(globals.Version, TierAclPolicyVersion)
return features logrus.WithFields(logrus.Fields{
"version": fmt.Sprintf("%+v", globals.Version),
"supportedFeatures": fmt.Sprintf("%+v", features),
}).Info("HCN feature check")
return features, nil
} }
func isFeatureSupported(currentVersion Version, versionsSupported VersionRanges) bool { func isFeatureSupported(currentVersion Version, versionsSupported VersionRanges) bool {
@ -87,19 +128,15 @@ func isFeatureSupported(currentVersion Version, versionsSupported VersionRanges)
func isFeatureInRange(currentVersion Version, versionRange VersionRange) bool { func isFeatureInRange(currentVersion Version, versionRange VersionRange) bool {
if currentVersion.Major < versionRange.MinVersion.Major { if currentVersion.Major < versionRange.MinVersion.Major {
logrus.Infof("currentVersion.Major < versionRange.MinVersion.Major: %v, %v", currentVersion.Major, versionRange.MinVersion.Major)
return false return false
} }
if currentVersion.Major > versionRange.MaxVersion.Major { if currentVersion.Major > versionRange.MaxVersion.Major {
logrus.Infof("currentVersion.Major > versionRange.MaxVersion.Major: %v, %v", currentVersion.Major, versionRange.MaxVersion.Major)
return false return false
} }
if currentVersion.Major == versionRange.MinVersion.Major && currentVersion.Minor < versionRange.MinVersion.Minor { if currentVersion.Major == versionRange.MinVersion.Major && currentVersion.Minor < versionRange.MinVersion.Minor {
logrus.Infof("currentVersion.Minor < versionRange.MinVersion.Major: %v, %v", currentVersion.Minor, versionRange.MinVersion.Minor)
return false return false
} }
if currentVersion.Major == versionRange.MaxVersion.Major && currentVersion.Minor > versionRange.MaxVersion.Minor { if currentVersion.Major == versionRange.MaxVersion.Major && currentVersion.Minor > versionRange.MaxVersion.Minor {
logrus.Infof("currentVersion.Minor > versionRange.MaxVersion.Major: %v, %v", currentVersion.Minor, versionRange.MaxVersion.Minor)
return false return false
} }
return true return true

View File

@ -7,6 +7,9 @@ import (
// HNSEndpoint represents a network endpoint in HNS // HNSEndpoint represents a network endpoint in HNS
type HNSEndpoint = hns.HNSEndpoint type HNSEndpoint = hns.HNSEndpoint
// HNSEndpointStats represent the stats for an networkendpoint in HNS
type HNSEndpointStats = hns.EndpointStats
// Namespace represents a Compartment. // Namespace represents a Compartment.
type Namespace = hns.Namespace type Namespace = hns.Namespace
@ -108,3 +111,8 @@ func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) { func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
return hns.GetHNSEndpointByName(endpointName) return hns.GetHNSEndpointByName(endpointName)
} }
// GetHNSEndpointStats gets the endpoint stats by ID
func GetHNSEndpointStats(endpointName string) (*HNSEndpointStats, error) {
return hns.GetHNSEndpointStats(endpointName)
}

View File

@ -60,7 +60,7 @@ var (
// ErrVmcomputeOperationInvalidState is an error encountered when the compute system is not in a valid state for the requested operation // ErrVmcomputeOperationInvalidState is an error encountered when the compute system is not in a valid state for the requested operation
ErrVmcomputeOperationInvalidState = syscall.Errno(0xc0370105) ErrVmcomputeOperationInvalidState = syscall.Errno(0xc0370105)
// ErrProcNotFound is an error encountered when the the process cannot be found // ErrProcNotFound is an error encountered when a procedure look up fails.
ErrProcNotFound = syscall.Errno(0x7f) ErrProcNotFound = syscall.Errno(0x7f)
// ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2 // ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2
@ -242,12 +242,11 @@ func makeProcessError(process *Process, op string, err error, events []ErrorEven
// IsNotExist checks if an error is caused by the Container or Process not existing. // IsNotExist checks if an error is caused by the Container or Process not existing.
// Note: Currently, ErrElementNotFound can mean that a Process has either // Note: Currently, ErrElementNotFound can mean that a Process has either
// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist // already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
// will currently return true when the error is ErrElementNotFound or ErrProcNotFound. // will currently return true when the error is ErrElementNotFound.
func IsNotExist(err error) bool { func IsNotExist(err error) bool {
err = getInnerError(err) err = getInnerError(err)
return err == ErrComputeSystemDoesNotExist || return err == ErrComputeSystemDoesNotExist ||
err == ErrElementNotFound || err == ErrElementNotFound
err == ErrProcNotFound
} }
// IsAlreadyClosed checks if an error is caused by the Container or Process having been // IsAlreadyClosed checks if an error is caused by the Container or Process having been
@ -278,12 +277,11 @@ func IsTimeout(err error) bool {
// a Container or Process being already stopped. // a Container or Process being already stopped.
// Note: Currently, ErrElementNotFound can mean that a Process has either // Note: Currently, ErrElementNotFound can mean that a Process has either
// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist // already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
// will currently return true when the error is ErrElementNotFound or ErrProcNotFound. // will currently return true when the error is ErrElementNotFound.
func IsAlreadyStopped(err error) bool { func IsAlreadyStopped(err error) bool {
err = getInnerError(err) err = getInnerError(err)
return err == ErrVmcomputeAlreadyStopped || return err == ErrVmcomputeAlreadyStopped ||
err == ErrElementNotFound || err == ErrElementNotFound
err == ErrProcNotFound
} }
// IsNotSupported returns a boolean indicating whether the error is caused by // IsNotSupported returns a boolean indicating whether the error is caused by

View File

@ -30,6 +30,7 @@ type HNSEndpoint struct {
EnableLowMetric bool `json:",omitempty"` EnableLowMetric bool `json:",omitempty"`
Namespace *Namespace `json:",omitempty"` Namespace *Namespace `json:",omitempty"`
EncapOverhead uint16 `json:",omitempty"` EncapOverhead uint16 `json:",omitempty"`
SharedContainers []string `json:",omitempty"`
} }
//SystemType represents the type of the system on which actions are done //SystemType represents the type of the system on which actions are done
@ -57,6 +58,18 @@ type EndpointResquestResponse struct {
Error string Error string
} }
// EndpointStats is the object that has stats for a given endpoint
type EndpointStats struct {
BytesReceived uint64 `json:"BytesReceived"`
BytesSent uint64 `json:"BytesSent"`
DroppedPacketsIncoming uint64 `json:"DroppedPacketsIncoming"`
DroppedPacketsOutgoing uint64 `json:"DroppedPacketsOutgoing"`
EndpointID string `json:"EndpointId"`
InstanceID string `json:"InstanceId"`
PacketsReceived uint64 `json:"PacketsReceived"`
PacketsSent uint64 `json:"PacketsSent"`
}
// HNSEndpointRequest makes a HNS call to modify/query a network endpoint // HNSEndpointRequest makes a HNS call to modify/query a network endpoint
func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) { func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
endpoint := &HNSEndpoint{} endpoint := &HNSEndpoint{}
@ -79,11 +92,27 @@ func HNSListEndpointRequest() ([]HNSEndpoint, error) {
return endpoint, nil return endpoint, nil
} }
// hnsEndpointStatsRequest makes a HNS call to query the stats for a given endpoint ID
func hnsEndpointStatsRequest(id string) (*EndpointStats, error) {
var stats EndpointStats
err := hnsCall("GET", "/endpointstats/"+id, "", &stats)
if err != nil {
return nil, err
}
return &stats, nil
}
// GetHNSEndpointByID get the Endpoint by ID // GetHNSEndpointByID get the Endpoint by ID
func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) { func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
return HNSEndpointRequest("GET", endpointID, "") return HNSEndpointRequest("GET", endpointID, "")
} }
// GetHNSEndpointStats get the stats for a n Endpoint by ID
func GetHNSEndpointStats(endpointID string) (*EndpointStats, error) {
return hnsEndpointStatsRequest(endpointID)
}
// GetHNSEndpointByName gets the endpoint filtered by Name // GetHNSEndpointByName gets the endpoint filtered by Name
func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) { func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
hnsResponse, err := HNSListEndpointRequest() hnsResponse, err := HNSListEndpointRequest()

2
vendor/modules.txt vendored
View File

@ -11,7 +11,7 @@ github.com/Microsoft/go-winio/pkg/fs
github.com/Microsoft/go-winio/pkg/guid github.com/Microsoft/go-winio/pkg/guid
github.com/Microsoft/go-winio/pkg/security github.com/Microsoft/go-winio/pkg/security
github.com/Microsoft/go-winio/vhd github.com/Microsoft/go-winio/vhd
# github.com/Microsoft/hcsshim v0.8.18 # github.com/Microsoft/hcsshim v0.8.21
## explicit ## explicit
github.com/Microsoft/hcsshim github.com/Microsoft/hcsshim
github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options