diff --git a/cluster-autoscaler/cloudprovider/azure/azure_client.go b/cluster-autoscaler/cloudprovider/azure/azure_client.go index fbc39a62ed28..b875f32168d0 100644 --- a/cluster-autoscaler/cloudprovider/azure/azure_client.go +++ b/cluster-autoscaler/cloudprovider/azure/azure_client.go @@ -30,7 +30,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4" - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure/auth" diff --git a/cluster-autoscaler/go.mod b/cluster-autoscaler/go.mod index f10d0740196c..8fbbea33322f 100644 --- a/cluster-autoscaler/go.mod +++ b/cluster-autoscaler/go.mod @@ -14,7 +14,7 @@ require ( github.com/Azure/go-autorest/autorest/azure/auth v0.5.13 github.com/Azure/go-autorest/autorest/date v0.3.0 github.com/Azure/go-autorest/autorest/to v0.4.0 - github.com/Azure/skewer v0.0.14 + github.com/Azure/skewer v0.0.19 github.com/aws/aws-sdk-go v1.44.241 github.com/cenkalti/backoff/v4 v4.2.1 github.com/digitalocean/godo v1.27.0 diff --git a/cluster-autoscaler/go.sum b/cluster-autoscaler/go.sum index 38231df3e2f6..5d29a86b461c 100644 --- a/cluster-autoscaler/go.sum +++ b/cluster-autoscaler/go.sum @@ -48,7 +48,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/Azure/azure-sdk-for-go v46.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU= github.com/Azure/azure-sdk-for-go v68.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go-extensions v0.1.6 h1:EXGvDcj54u98XfaI/Cy65Ds6vNsIJeGKYf0eNLB1y4Q= @@ -89,12 +88,9 @@ github.com/Azure/go-armbalancer v0.0.2 h1:NVnxsTWHI5/fEzL6k6TjxPUfcB/3Si3+HFOZXO github.com/Azure/go-armbalancer v0.0.2/go.mod h1:yTg7MA/8YnfKQc9o97tzAJ7fbdVkod1xGsIvKmhYPRE= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.11.4/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= github.com/Azure/go-autorest/autorest v0.11.28/go.mod h1:MrkzG3Y3AH668QyF9KRk5neJnGgmhQ6krbhR8Q5eMvA= github.com/Azure/go-autorest/autorest v0.11.29 h1:I4+HL/JDvErx2LjyzaVxllw2lRDB5/BT2Bm4g20iqYw= github.com/Azure/go-autorest/autorest v0.11.29/go.mod h1:ZtEzC4Jy2JDrZLxvWs8LrBWEBycl1hbT1eknI8MtfAs= -github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= -github.com/Azure/go-autorest/autorest/adal v0.9.2/go.mod h1:/3SMAM86bP6wC9Ev35peQDUeqFZBMH07vvUOmg4z/fE= github.com/Azure/go-autorest/autorest/adal v0.9.18/go.mod h1:XVVeme+LZwABT8K5Lc3hA4nAe8LDBVle26gTrguhhPQ= github.com/Azure/go-autorest/autorest/adal v0.9.22/go.mod h1:XuAbAEUv2Tta//+voMI038TrJBqjKam0me7qR+L8Cmk= github.com/Azure/go-autorest/autorest/adal v0.9.24 h1:BHZfgGsGwdkHDyZdtQRQk1WeUdW0m2WPAwuHZwUi5i4= @@ -105,22 +101,19 @@ github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 h1:w77/uPk80ZET2F+AfQExZy github.com/Azure/go-autorest/autorest/azure/cli v0.4.6/go.mod h1:piCfgPho7BiIDdEQ1+g4VmKyD5y+p/XtSNqE6Hc4QD0= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/autorest/mocks v0.4.2 h1:PGN4EDXnuQbojHbU0UWoNvmu9AGVwYHG9/fkDYhtAfw= github.com/Azure/go-autorest/autorest/mocks v0.4.2/go.mod h1:Vy7OitM9Kei0i1Oj+LvyAWMXJHeKH1MVlzFugfVrmyU= github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk= github.com/Azure/go-autorest/autorest/to v0.4.0/go.mod h1:fE8iZBn7LQR7zH/9XU2NcPR4o9jEImooCeWJcYV/zLE= -github.com/Azure/go-autorest/autorest/validation v0.3.0/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E= github.com/Azure/go-autorest/autorest/validation v0.3.1 h1:AgyqjAd94fwNAoTjl/WQXg4VvFeRFpO+UhNyRXqF1ac= github.com/Azure/go-autorest/autorest/validation v0.3.1/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E= -github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/Azure/skewer v0.0.14 h1:0mzUJhspECkajYyynYsOCp//E2PSnYXrgP45bcskqfQ= -github.com/Azure/skewer v0.0.14/go.mod h1:6WTecuPyfGtuvS8Mh4JYWuHhO4kcWycGfsUBB+XTFG4= +github.com/Azure/skewer v0.0.19 h1:+qA1z8isKmlNkhAwZErNS2wD2jaemSk9NszYKr8dddU= +github.com/Azure/skewer v0.0.19/go.mod h1:LVH7jmduRKmPj8YcIz7V4f53xJEntjweL4aoLyChkwk= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -693,7 +686,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/.golangci.yml b/cluster-autoscaler/vendor/github.com/Azure/skewer/.golangci.yml index cd462664baf3..56cded8736bd 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/.golangci.yml +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/.golangci.yml @@ -77,21 +77,18 @@ linters: - gocyclo - gofmt - goimports - - golint - gomnd - goprintffuncname - gosec - gosimple - govet - ineffassign - - interfacer - lll - misspell - nakedret - noctx - nolintlint - rowserrcheck - - scopelint - staticcheck - structcheck - stylecheck diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/README.md b/cluster-autoscaler/vendor/github.com/Azure/skewer/README.md index 33064dd2a451..fccb5f57594e 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/README.md +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/README.md @@ -16,7 +16,7 @@ import ( "fmt" "github.com/Azure/go-autorest/autorest/azure/auth" - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute" //nolint:staticcheck "github.com/Azure/skewer" ) diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/cache.go b/cluster-autoscaler/vendor/github.com/Azure/skewer/cache.go index b48f3d8c5d5c..5248d812d4d8 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/cache.go +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/cache.go @@ -8,9 +8,10 @@ import ( // Config contains configuration options for a cache. type Config struct { - location string - filter string - client client + location string + includeExtendedLocations string + filter string + client client } // Cache stores a list of known skus, possibly fetched with a provided client @@ -31,6 +32,14 @@ func WithLocation(location string) Option { } } +// WithExtendedLocations is a functional option to include extended locations +func WithExtendedLocations() Option { + return func(c *Config) (*Config, error) { + c.includeExtendedLocations = "true" + return c, nil + } +} + // ErrClientNil will be returned when a user attempts to create a cache // without a client and use it. type ErrClientNil struct { @@ -139,7 +148,7 @@ func NewStaticCache(data []SKU, opts ...Option) (*Cache, error) { } func (c *Cache) refresh(ctx context.Context) error { - data, err := c.config.client.List(ctx, c.config.filter) + data, err := c.config.client.List(ctx, c.config.filter, c.config.includeExtendedLocations) if err != nil { return err } diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/clients.go b/cluster-autoscaler/vendor/github.com/Azure/skewer/clients.go index 8d8538d14138..ab90c85a111b 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/clients.go +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/clients.go @@ -3,7 +3,7 @@ package skewer import ( "context" - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute" //nolint:staticcheck "github.com/pkg/errors" ) @@ -18,8 +18,8 @@ func newWrappedResourceClient(client ResourceClient) *wrappedResourceClient { } // List greedily traverses all returned sku pages -func (w *wrappedResourceClient) List(ctx context.Context, filter string) ([]compute.ResourceSku, error) { - return iterate(ctx, filter, w.client.ListComplete) +func (w *wrappedResourceClient) List(ctx context.Context, filter, includeExtendedLocations string) ([]compute.ResourceSku, error) { + return iterate(ctx, filter, includeExtendedLocations, w.client.ListComplete) } // wrappedResourceProviderClient defines a wrapper for the typical Azure client @@ -33,19 +33,20 @@ func newWrappedResourceProviderClient(client ResourceProviderClient) *wrappedRes return &wrappedResourceProviderClient{client} } -func (w *wrappedResourceProviderClient) ListComplete(ctx context.Context, filter string) (compute.ResourceSkusResultIterator, error) { - page, err := w.client.List(ctx, filter) +//nolint:lll +func (w *wrappedResourceProviderClient) ListComplete(ctx context.Context, filter, includeExtendedLocations string) (compute.ResourceSkusResultIterator, error) { + page, err := w.client.List(ctx, filter, includeExtendedLocations) if err != nil { return compute.ResourceSkusResultIterator{}, nil } return compute.NewResourceSkusResultIterator(page), nil } -type iterFunc func(context.Context, string) (compute.ResourceSkusResultIterator, error) +type iterFunc func(context.Context, string, string) (compute.ResourceSkusResultIterator, error) // iterate invokes fn to get an iterator, then drains it into an array. -func iterate(ctx context.Context, filter string, fn iterFunc) ([]compute.ResourceSku, error) { - iter, err := fn(ctx, filter) +func iterate(ctx context.Context, filter, includeExtendedLocations string, fn iterFunc) ([]compute.ResourceSku, error) { + iter, err := fn(ctx, filter, includeExtendedLocations) if err != nil { return nil, errors.Wrap(err, "could not list resource skus") } diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/const.go b/cluster-autoscaler/vendor/github.com/Azure/skewer/const.go index 1be0005c6838..1b6f8fb13124 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/const.go +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/const.go @@ -24,6 +24,8 @@ const ( AcceleratedNetworking = "AcceleratedNetworkingEnabled" // VCPUs identifies the capability for the number of vCPUS. VCPUs = "vCPUs" + // GPUs identifies the capability for the number of GPUS. + GPUs = "GPUs" // MemoryGB identifies the capability for memory capacity. MemoryGB = "MemoryGB" // HyperVGenerations identifies the hyper-v generations this vm sku supports. @@ -39,6 +41,16 @@ const ( // MaxResourceVolumeMB identifies the maximum size of the temporary // disk for a vm. MaxResourceVolumeMB = "MaxResourceVolumeMB" + // CapabilityPremiumIO identifies the capability for PremiumIO. + CapabilityPremiumIO = "PremiumIO" + // CapabilityCpuArchitectureType identifies the type of CPU architecture (x64,Arm64). + CapabilityCPUArchitectureType = "CpuArchitectureType" + // CapabilityTrustedLaunchDisabled identifes whether TrustedLaunch is disabled. + CapabilityTrustedLaunchDisabled = "TrustedLaunchDisabled" + // CapabilityConfidentialComputingType identifies the type of ConfidentialComputing. + CapabilityConfidentialComputingType = "ConfidentialComputingType" + // ConfidentialComputingTypeSNP denoted the "SNP" ConfidentialComputing. + ConfidentialComputingTypeSNP = "SNP" ) const ( @@ -49,3 +61,8 @@ const ( // Generation 2. HyperVGeneration2 = "V2" ) + +const ( + ten = 10 + sixtyFour = 64 +) diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/interface.go b/cluster-autoscaler/vendor/github.com/Azure/skewer/interface.go index fd20bc3e2028..9cb506b6feab 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/interface.go +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/interface.go @@ -3,22 +3,22 @@ package skewer import ( "context" - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute" //nolint:staticcheck ) // ResourceClient is the required Azure client interface used to populate skewer's data. type ResourceClient interface { - ListComplete(ctx context.Context, filter string) (compute.ResourceSkusResultIterator, error) + ListComplete(ctx context.Context, filter, includeExtendedLocations string) (compute.ResourceSkusResultIterator, error) } // ResourceProviderClient is a convenience interface for uses cases // specific to Azure resource providers. type ResourceProviderClient interface { - List(ctx context.Context, filter string) (compute.ResourceSkusResultPage, error) + List(ctx context.Context, filter, includeExtendedLocations string) (compute.ResourceSkusResultPage, error) } // client defines the internal interface required by the skewer Cache. // TODO(ace): implement a lazy iterator with caching (and a cursor?) type client interface { - List(ctx context.Context, filter string) ([]compute.ResourceSku, error) + List(ctx context.Context, filter, includeExtendedLocations string) ([]compute.ResourceSku, error) } diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/sku.go b/cluster-autoscaler/vendor/github.com/Azure/skewer/sku.go index 167c330e03fe..565f82fa636c 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/sku.go +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/sku.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute" //nolint:staticcheck "github.com/pkg/errors" ) @@ -33,7 +33,7 @@ func (e *ErrCapabilityValueNil) Error() string { } // ErrCapabilityValueParse will be returned when a capability was found by -// name but the value was nil. +// name but there was error parsing the capability. type ErrCapabilityValueParse struct { capability string value string @@ -49,6 +49,11 @@ func (s *SKU) VCPU() (int64, error) { return s.GetCapabilityIntegerQuantity(VCPUs) } +// GPU returns the number of GPU this SKU supports. +func (s *SKU) GPU() (int64, error) { + return s.GetCapabilityIntegerQuantity(GPUs) +} + // Memory returns the amount of memory this SKU supports. func (s *SKU) Memory() (float64, error) { return s.GetCapabilityFloatQuantity(MemoryGB) @@ -94,7 +99,7 @@ func (s *SKU) IsUltraSSDAvailableInAvailabilityZone(zone string) bool { // IsUltraSSDAvailable returns true when a VM size has ultra SSD enabled // in at least 1 unrestricted zone. // -// Deprecated. Use either IsUltraSSDAvailableWithoutAvailabilityZone or IsUltraSSDAvailableInAvailabilityZone +// Deprecated: use either IsUltraSSDAvailableWithoutAvailabilityZone or IsUltraSSDAvailableInAvailabilityZone func (s *SKU) IsUltraSSDAvailable() bool { return s.HasZonalCapability(UltraSSDAvailable) } @@ -111,12 +116,29 @@ func (s *SKU) IsAcceleratedNetworkingSupported() bool { return s.HasCapability(AcceleratedNetworking) } +// IsPremiumIO returns true when the VM size supports PremiumIO. +func (s *SKU) IsPremiumIO() bool { + return s.HasCapability(CapabilityPremiumIO) +} + +// IsHyperVGen1Supported returns true when the VM size supports +// accelerated networking. +func (s *SKU) IsHyperVGen1Supported() bool { + return s.HasCapabilityWithSeparator(HyperVGenerations, HyperVGeneration1) +} + // IsHyperVGen2Supported returns true when the VM size supports // accelerated networking. func (s *SKU) IsHyperVGen2Supported() bool { return s.HasCapabilityWithSeparator(HyperVGenerations, HyperVGeneration2) } +// GetCPUArchitectureType returns cpu arch for the VM size. +// It errors if value is nil or not found. +func (s *SKU) GetCPUArchitectureType() (string, error) { + return s.GetCapabilityString(CapabilityCPUArchitectureType) +} + // GetCapabilityIntegerQuantity retrieves and parses the value of an // integer numeric capability with the provided name. It errors if the // capability is not found, the value was nil, or the value could not be @@ -128,7 +150,7 @@ func (s *SKU) GetCapabilityIntegerQuantity(name string) (int64, error) { for _, capability := range *s.Capabilities { if capability.Name != nil && *capability.Name == name { if capability.Value != nil { - intVal, err := strconv.ParseInt(*capability.Value, 10, 64) + intVal, err := strconv.ParseInt(*capability.Value, ten, sixtyFour) if err != nil { return -1, &ErrCapabilityValueParse{name, *capability.Value, err} } @@ -151,7 +173,7 @@ func (s *SKU) GetCapabilityFloatQuantity(name string) (float64, error) { for _, capability := range *s.Capabilities { if capability.Name != nil && *capability.Name == name { if capability.Value != nil { - intVal, err := strconv.ParseFloat(*capability.Value, 64) + intVal, err := strconv.ParseFloat(*capability.Value, sixtyFour) if err != nil { return -1, &ErrCapabilityValueParse{name, *capability.Value, err} } @@ -163,6 +185,23 @@ func (s *SKU) GetCapabilityFloatQuantity(name string) (float64, error) { return -1, &ErrCapabilityNotFound{name} } +// GetCapabilityString retrieves string capability with the provided name. +// It errors if the capability is not found or the value was nil +func (s *SKU) GetCapabilityString(name string) (string, error) { + if s.Capabilities == nil { + return "", &ErrCapabilityNotFound{name} + } + for _, capability := range *s.Capabilities { + if capability.Name != nil && *capability.Name == name { + if capability.Value != nil { + return *capability.Value, nil + } + return "", &ErrCapabilityValueNil{name} + } + } + return "", &ErrCapabilityNotFound{name} +} + // HasCapability return true for a capability which can be either // supported or not. Examples include "EphemeralOSDiskSupported", // "EncryptionAtHostSupported", "AcceleratedNetworkingEnabled", and @@ -213,7 +252,7 @@ func (s *SKU) HasZonalCapability(name string) bool { // HasCapabilityInZone return true if the specified capability name is supported in the // specified zone. -func (s *SKU) HasCapabilityInZone(name string, zone string) bool { +func (s *SKU) HasCapabilityInZone(name, zone string) bool { if s.LocationInfo == nil { return false } @@ -281,7 +320,7 @@ func (s *SKU) HasCapabilityWithMinCapacity(name string, value int64) (bool, erro for _, capability := range *s.Capabilities { if capability.Name != nil && strings.EqualFold(*capability.Name, name) { if capability.Value != nil { - intVal, err := strconv.ParseInt(*capability.Value, 10, 64) + intVal, err := strconv.ParseInt(*capability.Value, ten, sixtyFour) if err != nil { return false, errors.Wrapf(err, "failed to parse string '%s' as int64", *capability.Value) } @@ -379,6 +418,21 @@ func (s *SKU) GetFamilyName() string { return *s.Family } +// GetSize returns the size of this resource sku. It normalizes pointers +// to the empty string for comparison purposes. For example, +// "M416ms_v2" for a virtual machine. +func (s *SKU) GetSize() string { + if s.Size == nil { + return "" + } + + return *s.Size +} + +func (s *SKU) GetVMSize() (*VMSizeType, error) { + return getVMSize(s.GetSize()) +} + // GetLocation returns the location for a given SKU. func (s *SKU) GetLocation() (string, error) { if s.Locations == nil { @@ -435,8 +489,27 @@ func (s *SKU) HasLocationRestriction(location string) bool { return false } +// IsConfidentialComputingTypeSNP return true if ConfidentialComputingType is SNP for this sku. +func (s *SKU) IsConfidentialComputingTypeSNP() (bool, error) { + return s.HasCapabilityWithSeparator(CapabilityConfidentialComputingType, ConfidentialComputingTypeSNP), nil +} + +// Official documentation for Trusted Launch states: +// The response will be similar to the following form: +// IsTrustedLaunchEnabled True in the output indicates that the Generation 2 VM size does not support Trusted launch. +// If it's a Generation 2 VM size and TrustedLaunchDisabled is not part of the output, +// it implies that Trusted launch is supported for that VM size. +func (s *SKU) IsTrustedLaunchEnabled() (bool, error) { + if s.IsHyperVGen2Supported() { + if !s.HasCapabilityWithSeparator(CapabilityTrustedLaunchDisabled, string(CapabilitySupported)) { + return true, nil + } + } + return false, nil +} + // AvailabilityZones returns the list of Availability Zones which have this resource SKU available and unrestricted. -func (s *SKU) AvailabilityZones(location string) map[string]bool { // nolint:gocyclo +func (s *SKU) AvailabilityZones(location string) map[string]bool { //nolint:gocyclo if s.LocationInfo == nil { return nil } diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/vmsize.go b/cluster-autoscaler/vendor/github.com/Azure/skewer/vmsize.go new file mode 100644 index 000000000000..3f79a0ceb3cd --- /dev/null +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/vmsize.go @@ -0,0 +1,131 @@ +package skewer + +import ( + "fmt" + "regexp" + "strconv" +) + +// This file adds support for more capabilities based on VM naming conventions that includes vmsize parsing. +// VM naming conventions are documented at: https://docs.microsoft.com/en-us/azure/virtual-machines/vm-naming-conventions +// Note: Some common capabilities like familyName and VCPUs, which can also be +// fetched using the ResourceSKU API, are not included here. They can be found in sku.go. + +var skuSizeScheme = regexp.MustCompile( + `^([A-Z])([A-Z]?)([0-9]+)-?((?:[0-9]+)?)((?:[abcdilmtspPr]+|C+|NP)?)_?(?:([A-Z][0-9]+)_?)?(_cc_)?((?:[vV][1-9])?)?(_Promo)?$`, +) + +// unParsableVMSizes map holds vmSize strings that cannot be easily parsed with skuSizeScheme. +var unParsableVMSizes = map[string]VMSizeType{ + "M416s_8_v2": { + Family: "M", + Subfamily: nil, + Cpus: "416", + CpusConstrained: nil, + AdditiveFeatures: []rune{'s'}, + AcceleratorType: nil, + ConfidentialChildCapability: false, + Version: "v2", + PromoVersion: false, + Series: "Ms_v2", + }, +} + +type VMSizeType struct { + Family string + Subfamily *string + Cpus string + CpusConstrained *string + AdditiveFeatures []rune + AcceleratorType *string + ConfidentialChildCapability bool + Version string + PromoVersion bool + Series string +} + +// parseVMSize parses the VM size and returns the parts as a map. +func parseVMSize(vmSizeName string) ([]string, error) { + parts := skuSizeScheme.FindStringSubmatch(vmSizeName) + if parts == nil || len(parts) < 10 { + return nil, fmt.Errorf("could not parse VM size %s", vmSizeName) + } + return parts, nil +} + +// getVMSize is a helper function used by GetVMSize() in sku.go +func getVMSize(vmSizeName string) (*VMSizeType, error) { + vmSize := VMSizeType{} + + parts, err := parseVMSize(vmSizeName) + if err != nil { + if vmSizeVal, ok := unParsableVMSizes[vmSizeName]; ok { + return &vmSizeVal, nil + } + return nil, err + } + + // [Family] - ([A-Z]): Captures a single uppercase letter. + vmSize.Family = parts[1] + + // [Sub-family]* - ([A-Z]?): Optionally captures another uppercase letter. + if len(parts[2]) > 0 { + vmSize.Subfamily = &parts[2] + } + + // [# of vCPUs] - ([0-9]+): Captures one or more digits. + vmSize.Cpus = parts[3] + + // [Constrained vCPUs]* + // -?: Optionally captures a hyphen. + // ((?:[0-9]+)?): Optionally captures another sequence of one or more digits. + if len(parts[4]) > 0 { + _, err := strconv.Atoi(parts[4]) + if err != nil { + return nil, fmt.Errorf("converting constrained CPUs, %w", err) + } + vmSize.CpusConstrained = &parts[4] + } + + // [Additive Features] + // ((?:[abcdilmtspPr]+|C+|NP)?): Captures a sequence of letters representing certain attributes. + // It can capture combinations like 'abcdilmtspPr' or 'C+' or 'NP'. + vmSize.AdditiveFeatures = []rune(parts[5]) + + // [Accelerator Type]* + // _?: Optionally captures an underscore. + // (?:([A-Z][0-9]+)_?)?: Optionally captures a pattern that starts with an uppercase letter followed by digits, + // followed by an optional underscore. + if len(parts[6]) > 0 { + vmSize.AcceleratorType = &parts[6] + } + + // [Confidential Child Capability]* - only AKS + // (_cc_)?: Optionally captures the string "cc" with underscores on both sides. + if parts[7] == "_cc_" { + vmSize.ConfidentialChildCapability = true + } + + // [Version]* + // Optionally captures the pattern 'v' or 'V' followed by a digit from 1 to 9. + vmSize.Version = parts[8] + + // [Promo]* + // (_Promo)?: Optionally captures the string "_Promo". + if parts[9] == "_Promo" { + vmSize.PromoVersion = true + } + + // [Series] + subfamily := "" + if vmSize.Subfamily != nil { + subfamily = *vmSize.Subfamily + } + version := "" + if len(vmSize.Version) > 0 { + version = "_" + vmSize.Version + } + vmSize.Series = vmSize.Family + subfamily + string(vmSize.AdditiveFeatures) + version + + return &vmSize, nil +} diff --git a/cluster-autoscaler/vendor/github.com/Azure/skewer/wrap.go b/cluster-autoscaler/vendor/github.com/Azure/skewer/wrap.go index a9c5eee4e6b5..711555dabfb5 100644 --- a/cluster-autoscaler/vendor/github.com/Azure/skewer/wrap.go +++ b/cluster-autoscaler/vendor/github.com/Azure/skewer/wrap.go @@ -1,6 +1,6 @@ package skewer -import "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute" +import "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute" //nolint:staticcheck // Wrap takes an array of compute resource skus and wraps them into an // array of our richer type. diff --git a/cluster-autoscaler/vendor/modules.txt b/cluster-autoscaler/vendor/modules.txt index 16e48d3246ee..7c3fde863c4f 100644 --- a/cluster-autoscaler/vendor/modules.txt +++ b/cluster-autoscaler/vendor/modules.txt @@ -125,8 +125,8 @@ github.com/Azure/go-autorest/logger # github.com/Azure/go-autorest/tracing v0.6.0 ## explicit; go 1.12 github.com/Azure/go-autorest/tracing -# github.com/Azure/skewer v0.0.14 -## explicit; go 1.13 +# github.com/Azure/skewer v0.0.19 +## explicit; go 1.18 github.com/Azure/skewer # github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 ## explicit; go 1.18