build(deps): bump github.com/Microsoft/hcsshim from 0.8.20 to 0.9.6
Bumps [github.com/Microsoft/hcsshim](https://github.com/Microsoft/hcsshim) from 0.8.20 to 0.9.6. - [Release notes](https://github.com/Microsoft/hcsshim/releases) - [Commits](https://github.com/Microsoft/hcsshim/compare/v0.8.20...v0.9.6) --- updated-dependencies: - dependency-name: github.com/Microsoft/hcsshim dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
committed by
Matthieu MOREL
parent
020b8db6ab
commit
90ed30a55a
61
vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport.go
generated
vendored
61
vendor/github.com/Microsoft/hcsshim/hcn/hcnsupport.go
generated
vendored
@@ -1,9 +1,21 @@
|
||||
package hcn
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"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.
|
||||
type SupportedFeatures struct {
|
||||
Acl AclFeatures `json:"ACL"`
|
||||
@@ -20,6 +32,8 @@ type SupportedFeatures struct {
|
||||
L4Proxy bool `json:"L4Proxy"` // network policy that applies VFP rules to all endpoints on the network to redirect traffic
|
||||
L4WfpProxy bool `json:"L4WfpProxy"` // endpoint policy that applies WFP filters to redirect traffic to/from that endpoint
|
||||
TierAcl bool `json:"TierAcl"`
|
||||
NetworkACL bool `json:"NetworkACL"`
|
||||
NestedIpSet bool `json:"NestedIpSet"`
|
||||
}
|
||||
|
||||
// AclFeatures are the supported ACL possibilities.
|
||||
@@ -36,17 +50,41 @@ type ApiSupport struct {
|
||||
V2 bool `json:"V2"`
|
||||
}
|
||||
|
||||
// GetSupportedFeatures returns the features supported by the Service.
|
||||
func GetSupportedFeatures() SupportedFeatures {
|
||||
var features SupportedFeatures
|
||||
// GetCachedSupportedFeatures returns the features supported by the Service and an error if the query failed. If this has been called
|
||||
// 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
|
||||
// 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 {
|
||||
// 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
|
||||
}
|
||||
|
||||
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{
|
||||
AclAddressLists: isFeatureSupported(globals.Version, HNSVersion1803),
|
||||
AclNoHostRulePriority: isFeatureSupported(globals.Version, HNSVersion1803),
|
||||
@@ -71,8 +109,15 @@ func GetSupportedFeatures() SupportedFeatures {
|
||||
features.L4Proxy = isFeatureSupported(globals.Version, L4ProxyPolicyVersion)
|
||||
features.L4WfpProxy = isFeatureSupported(globals.Version, L4WfpProxyPolicyVersion)
|
||||
features.TierAcl = isFeatureSupported(globals.Version, TierAclPolicyVersion)
|
||||
features.NetworkACL = isFeatureSupported(globals.Version, NetworkACLPolicyVersion)
|
||||
features.NestedIpSet = isFeatureSupported(globals.Version, NestedIpSetVersion)
|
||||
|
||||
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 {
|
||||
@@ -87,19 +132,15 @@ func isFeatureSupported(currentVersion Version, versionsSupported VersionRanges)
|
||||
|
||||
func isFeatureInRange(currentVersion Version, versionRange VersionRange) bool {
|
||||
if currentVersion.Major < versionRange.MinVersion.Major {
|
||||
logrus.Infof("currentVersion.Major < versionRange.MinVersion.Major: %v, %v", currentVersion.Major, versionRange.MinVersion.Major)
|
||||
return false
|
||||
}
|
||||
if currentVersion.Major > versionRange.MaxVersion.Major {
|
||||
logrus.Infof("currentVersion.Major > versionRange.MaxVersion.Major: %v, %v", currentVersion.Major, versionRange.MaxVersion.Major)
|
||||
return false
|
||||
}
|
||||
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
|
||||
}
|
||||
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 true
|
||||
|
||||
Reference in New Issue
Block a user