diff --git a/hcn/hcn.go b/hcn/hcn.go index df3a59a78c..b6ecd75981 100644 --- a/hcn/hcn.go +++ b/hcn/hcn.go @@ -264,6 +264,18 @@ func SetPolicySupported() error { return platformDoesNotSupportError("SetPolicy") } +// ModifyLoadbalancerSupported returns an error if the HCN version does not support ModifyLoadbalancer. +func ModifyLoadbalancerSupported() error { + supported, err := GetCachedSupportedFeatures() + if err != nil { + return err + } + if supported.ModifyLoadbalancer { + return nil + } + return platformDoesNotSupportError("ModifyLoadbalancer") +} + // VxlanPortSupported returns an error if the HCN version does not support configuring the VXLAN TCP port. func VxlanPortSupported() error { supported, err := GetCachedSupportedFeatures() diff --git a/hcn/hcnerrors.go b/hcn/hcnerrors.go index ad30d320d9..c8cd009749 100644 --- a/hcn/hcnerrors.go +++ b/hcn/hcnerrors.go @@ -10,6 +10,7 @@ import ( "github.com/Microsoft/hcsshim/internal/hcserror" "github.com/Microsoft/hcsshim/internal/interop" "github.com/sirupsen/logrus" + "golang.org/x/sys/windows" ) var ( @@ -50,6 +51,7 @@ type ErrorCode uint32 const ( ERROR_NOT_FOUND = 0x490 HCN_E_PORT_ALREADY_EXISTS ErrorCode = 0x803b0013 + HCN_E_NOTIMPL ErrorCode = ErrorCode(windows.E_NOTIMPL) ) type HcnError struct { @@ -77,6 +79,10 @@ func IsPortAlreadyExistsError(err error) bool { return CheckErrorWithCode(err, HCN_E_PORT_ALREADY_EXISTS) } +func IsNotImplemented(err error) bool { + return CheckErrorWithCode(err, HCN_E_NOTIMPL) +} + func new(hr error, title string, rest string) error { err := &HcnError{} hcsError := hcserror.New(hr, title, rest) diff --git a/hcn/hcnglobals.go b/hcn/hcnglobals.go index 14903bc5e9..c0e9bc63bc 100644 --- a/hcn/hcnglobals.go +++ b/hcn/hcnglobals.go @@ -82,6 +82,11 @@ var ( //HNS 15.0 allows for NestedIpSet support NestedIpSetVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 0}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} + + //HNS 15.1 allows support for DisableHostPort flag. + DisableHostPortVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 1}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} + // HNS 15.4 allows for Modify Loadbalancer support + ModifyLoadbalancerVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 4}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}} ) // GetGlobals returns the global properties of the HCN Service. diff --git a/hcn/hcnsupport.go b/hcn/hcnsupport.go index bacb91feda..c34d89dbec 100644 --- a/hcn/hcnsupport.go +++ b/hcn/hcnsupport.go @@ -34,6 +34,8 @@ type SupportedFeatures struct { TierAcl bool `json:"TierAcl"` NetworkACL bool `json:"NetworkACL"` NestedIpSet bool `json:"NestedIpSet"` + DisableHostPort bool `json:"DisableHostPort"` + ModifyLoadbalancer bool `json:"ModifyLoadbalancer"` } // AclFeatures are the supported ACL possibilities. @@ -111,6 +113,8 @@ func getSupportedFeatures() (SupportedFeatures, error) { features.TierAcl = isFeatureSupported(globals.Version, TierAclPolicyVersion) features.NetworkACL = isFeatureSupported(globals.Version, NetworkACLPolicyVersion) features.NestedIpSet = isFeatureSupported(globals.Version, NestedIpSetVersion) + features.DisableHostPort = isFeatureSupported(globals.Version, DisableHostPortVersion) + features.ModifyLoadbalancer = isFeatureSupported(globals.Version, ModifyLoadbalancerVersion) logrus.WithFields(logrus.Fields{ "version": fmt.Sprintf("%+v", globals.Version),