Skip to content

Commit 8beabac

Browse files
Changes for checking the global version for modify policy version support. (microsoft#2139)
Signed-off-by: Prince Pereira <[email protected]>
1 parent c79a631 commit 8beabac

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

hcn/hcn.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ func SetPolicySupported() error {
264264
return platformDoesNotSupportError("SetPolicy")
265265
}
266266

267+
// ModifyLoadbalancerSupported returns an error if the HCN version does not support ModifyLoadbalancer.
268+
func ModifyLoadbalancerSupported() error {
269+
supported, err := GetCachedSupportedFeatures()
270+
if err != nil {
271+
return err
272+
}
273+
if supported.ModifyLoadbalancer {
274+
return nil
275+
}
276+
return platformDoesNotSupportError("ModifyLoadbalancer")
277+
}
278+
267279
// VxlanPortSupported returns an error if the HCN version does not support configuring the VXLAN TCP port.
268280
func VxlanPortSupported() error {
269281
supported, err := GetCachedSupportedFeatures()

hcn/hcnerrors.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type ErrorCode uint32
5252
const (
5353
ERROR_NOT_FOUND = ErrorCode(windows.ERROR_NOT_FOUND)
5454
HCN_E_PORT_ALREADY_EXISTS ErrorCode = ErrorCode(windows.HCN_E_PORT_ALREADY_EXISTS)
55+
HCN_E_NOTIMPL ErrorCode = ErrorCode(windows.E_NOTIMPL)
5556
)
5657

5758
type HcnError struct {
@@ -79,6 +80,10 @@ func IsPortAlreadyExistsError(err error) bool {
7980
return CheckErrorWithCode(err, HCN_E_PORT_ALREADY_EXISTS)
8081
}
8182

83+
func IsNotImplemented(err error) bool {
84+
return CheckErrorWithCode(err, HCN_E_NOTIMPL)
85+
}
86+
8287
func new(hr error, title string, rest string) error {
8388
err := &HcnError{}
8489
hcsError := hcserror.New(hr, title, rest)

hcn/hcnglobals.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ var (
8787

8888
//HNS 15.1 allows support for DisableHostPort flag.
8989
DisableHostPortVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 1}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
90+
// HNS 15.4 allows for Modify Loadbalancer support
91+
ModifyLoadbalancerVersion = VersionRanges{VersionRange{MinVersion: Version{Major: 15, Minor: 4}, MaxVersion: Version{Major: math.MaxInt32, Minor: math.MaxInt32}}}
9092
)
9193

9294
// GetGlobals returns the global properties of the HCN Service.

hcn/hcnsupport.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type SupportedFeatures struct {
3838
NetworkACL bool `json:"NetworkACL"`
3939
NestedIpSet bool `json:"NestedIpSet"`
4040
DisableHostPort bool `json:"DisableHostPort"`
41+
ModifyLoadbalancer bool `json:"ModifyLoadbalancer"`
4142
}
4243

4344
// AclFeatures are the supported ACL possibilities.
@@ -116,6 +117,7 @@ func getSupportedFeatures() (SupportedFeatures, error) {
116117
features.NetworkACL = isFeatureSupported(globals.Version, NetworkACLPolicyVersion)
117118
features.NestedIpSet = isFeatureSupported(globals.Version, NestedIpSetVersion)
118119
features.DisableHostPort = isFeatureSupported(globals.Version, DisableHostPortVersion)
120+
features.ModifyLoadbalancer = isFeatureSupported(globals.Version, ModifyLoadbalancerVersion)
119121

120122
log.L.WithFields(logrus.Fields{
121123
"version": globals.Version,

0 commit comments

Comments
 (0)