diff --git a/go.mod b/go.mod index 8aa12f4ba1..f3c4d6738f 100644 --- a/go.mod +++ b/go.mod @@ -34,15 +34,15 @@ require ( k8s.io/api v0.31.3 k8s.io/apimachinery v0.31.3 k8s.io/client-go v0.31.3 - k8s.io/cloud-provider v0.31.2 - k8s.io/component-base v0.31.2 + k8s.io/cloud-provider v0.31.3 + k8s.io/component-base v0.31.3 k8s.io/klog/v2 v2.130.1 k8s.io/kubernetes v1.31.3 k8s.io/mount-utils v0.29.7 k8s.io/pod-security-admission v0.0.0 k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 - sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241111034044-6ebb6c3c3260 - sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.15 + sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241129020458-82e716a56f86 + sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.21 sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader v0.1.8 sigs.k8s.io/yaml v1.4.0 ) @@ -52,7 +52,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2 v2.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry v1.2.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.3.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.4.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/msi/armmsi v1.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.3.0 // indirect @@ -122,7 +122,7 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.20.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.60.0 // indirect + github.com/prometheus/common v0.60.1 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -132,9 +132,9 @@ require ( go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect go.etcd.io/etcd/client/v3 v3.5.14 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect - go.opentelemetry.io/otel/exporters/prometheus v0.53.0 // indirect + go.opentelemetry.io/otel/exporters/prometheus v0.54.0 // indirect go.opentelemetry.io/otel/metric v1.32.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.11.0 // indirect @@ -156,13 +156,13 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.0.0 // indirect - k8s.io/apiserver v0.31.2 // indirect - k8s.io/component-helpers v0.31.2 // indirect - k8s.io/controller-manager v0.31.2 // indirect + k8s.io/apiserver v0.31.3 // indirect + k8s.io/component-helpers v0.31.3 // indirect + k8s.io/controller-manager v0.31.3 // indirect k8s.io/kms v0.32.0-alpha.0 // indirect k8s.io/kube-openapi v0.0.0-20240730131305-7a9a4e85957e // indirect k8s.io/kubectl v0.0.0 // indirect - k8s.io/kubelet v0.31.2 // indirect + k8s.io/kubelet v0.31.3 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect diff --git a/go.sum b/go.sum index 8522fb2155..880c61cdfa 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armconta github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry v1.2.0/go.mod h1:E7ltexgRDmeJ0fJWv0D/HLwY2xbDdN+uv+X2uZtOx3w= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v5 v5.0.0 h1:5n7dPVqsWfVKw+ZiEKSd3Kzu7gwBkbEBkeXb8rgaE9Q= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v5 v5.0.0/go.mod h1:HcZY0PHPo/7d75p99lB6lK0qYOP4vLRJUBpiehYXtLQ= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.2.0 h1:qXCssQ563JFkqh+5YQSXqqJMROSTh9ZraEe33nVeDAA= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.2.0/go.mod h1:drbnYtukMoZqUQq9hJASf41w3RB4VoTJPoPpe+XDHPU= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.3.0 h1:4ZTvMq5AWtRIPM06RzdfKwKyVJ0eUOfm4QUBVDQFqQ4= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.3.0/go.mod h1:drbnYtukMoZqUQq9hJASf41w3RB4VoTJPoPpe+XDHPU= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 h1:2qsIIvxVT+uE6yrNldntJKlLRgxGbZ85kgtz5SNBhMw= @@ -356,8 +356,8 @@ github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/j github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.60.0 h1:+V9PAREWNvJMAuJ1x1BaWl9dewMW4YrHZQbx0sJNllA= -github.com/prometheus/common v0.60.0/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= +github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4= @@ -431,14 +431,14 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 h1:IJFEoHiytixx8cMiVAO go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0/go.mod h1:3rHrKNtLIoS0oZwkY2vxi+oJcwFRWdtUyRII+so45p8= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 h1:9kV11HXBHZAvuPUZxmMWrH8hZn/6UnHX4K0mu36vNsU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0/go.mod h1:JyA0FHXe22E1NeNiHmVp7kFHglnexDQ7uRWDiiJ1hKQ= -go.opentelemetry.io/otel/exporters/prometheus v0.53.0 h1:QXobPHrwiGLM4ufrY3EOmDPJpo2P90UuFau4CDPJA/I= -go.opentelemetry.io/otel/exporters/prometheus v0.53.0/go.mod h1:WOAXGr3D00CfzmFxtTV1eR0GpoHuPEu+HJT8UWW2SIU= +go.opentelemetry.io/otel/exporters/prometheus v0.54.0 h1:rFwzp68QMgtzu9PgP3jm9XaMICI6TsofWWPcBDKwlsU= +go.opentelemetry.io/otel/exporters/prometheus v0.54.0/go.mod h1:QyjcV9qDP6VeK5qPyKETvNjmaaEc7+gqjh4SS0ZYzDU= go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= -go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= -go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= @@ -784,10 +784,10 @@ k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 h1:jGnCPejIetjiy2gqaJ5V0NLwTpF4w k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 h1:2770sDpzrjjsAtVhSeUFseziht227YAWYHLGNM8QPwY= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= -sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241111034044-6ebb6c3c3260 h1:fojDjExSwK4UcEV5uGBNiGp55uly70rp9k7+YXhNjXI= -sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241111034044-6ebb6c3c3260/go.mod h1:mHnDlABcVBbkfA9qNFIYeFcEOritZWoJkpUylkIA7Mo= -sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.15 h1:8M5S8zVUoK8HU0rKqbPw5/sWL/NAmnO8+GqPIz4w+iA= -sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.15/go.mod h1:OJBnDbWJgOndWItjTj3LMf8n2Px1kgj9zjhA9ZMGYI0= +sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241129020458-82e716a56f86 h1:n3MLuoJQ/KOXWcTe3e/5Hj6H6wkEqAe9HyxMyakVgv4= +sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241129020458-82e716a56f86/go.mod h1:6ji4L5w0rvIbOKoavxdthyRVhy1TWU3JBmpzdZZGKX0= +sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.21 h1:HQk15tR9x2Vzeo+7kP66fN0zvI/0wjaD+/FHOfztng8= +sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.21/go.mod h1:WSsOhr3Kr9BqIb88mgoEvcreu7vZujsQ31x3HXM+X6Y= sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader v0.1.8 h1:fwg1J+nRRXkcA0lIJ/a4fJPg7tNggRH1pPOukthuAGw= sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader v0.1.8/go.mod h1:kUW9qMqi412c5+nXdYA00oSudWC9nVUCM4v1k3HtgZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/pkg/azureutils/azure_disk_utils.go b/pkg/azureutils/azure_disk_utils.go index 62dda56a84..62f0c2b022 100644 --- a/pkg/azureutils/azure_disk_utils.go +++ b/pkg/azureutils/azure_disk_utils.go @@ -48,6 +48,7 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader" azclients "sigs.k8s.io/cloud-provider-azure/pkg/azureclients" azure "sigs.k8s.io/cloud-provider-azure/pkg/provider" + azureconfig "sigs.k8s.io/cloud-provider-azure/pkg/provider/config" ) const ( @@ -153,13 +154,13 @@ func GetAttachDiskInitialDelay(attributes map[string]string) int { // GetCloudProviderFromClient get Azure Cloud Provider func GetCloudProviderFromClient(ctx context.Context, kubeClient clientset.Interface, secretName, secretNamespace, userAgent string, allowEmptyCloudConfig bool, enableTrafficMgr bool, trafficMgrPort int64) (*azure.Cloud, error) { - var config *azure.Config + var config *azureconfig.Config var fromSecret bool var err error az := &azure.Cloud{} if kubeClient != nil { klog.V(2).Infof("reading cloud config from secret %s/%s", secretNamespace, secretName) - config, err = configloader.Load[azure.Config](ctx, &configloader.K8sSecretLoaderConfig{ + config, err = configloader.Load[azureconfig.Config](ctx, &configloader.K8sSecretLoaderConfig{ K8sSecretConfig: configloader.K8sSecretConfig{ SecretName: secretName, SecretNamespace: secretNamespace, @@ -189,7 +190,7 @@ func GetCloudProviderFromClient(ctx context.Context, kubeClient clientset.Interf } klog.V(2).Infof("use default %s env var: %v", consts.DefaultAzureCredentialFileEnv, credFile) } - config, err = configloader.Load[azure.Config](ctx, nil, &configloader.FileLoaderConfig{FilePath: credFile}) + config, err = configloader.Load[azureconfig.Config](ctx, nil, &configloader.FileLoaderConfig{FilePath: credFile}) if err != nil { klog.Warningf("load azure config from file(%s) failed with %v", credFile, err) } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/CHANGELOG.md index 297d79344f..ce6f863756 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/CHANGELOG.md @@ -1,5 +1,25 @@ # Release History +## 6.3.0 (2024-11-18) +### Features Added + +- New enum type `RestrictionLevel` with values `RestrictionLevelReadOnly`, `RestrictionLevelUnrestricted` +- New struct `AdvancedNetworking` +- New struct `AdvancedNetworkingObservability` +- New struct `AdvancedNetworkingSecurity` +- New struct `ManagedClusterNodeResourceGroupProfile` +- New field `IfMatch`, `IfNoneMatch` in struct `AgentPoolsClientBeginCreateOrUpdateOptions` +- New field `IfMatch` in struct `AgentPoolsClientBeginDeleteOptions` +- New field `ETag` in struct `ManagedCluster` +- New field `ETag` in struct `ManagedClusterAgentPoolProfile` +- New field `ETag` in struct `ManagedClusterAgentPoolProfileProperties` +- New field `NodeResourceGroupProfile` in struct `ManagedClusterProperties` +- New field `IfMatch`, `IfNoneMatch` in struct `ManagedClustersClientBeginCreateOrUpdateOptions` +- New field `IfMatch` in struct `ManagedClustersClientBeginDeleteOptions` +- New field `IfMatch` in struct `ManagedClustersClientBeginUpdateTagsOptions` +- New field `AdvancedNetworking` in struct `NetworkProfile` + + ## 6.2.0 (2024-10-24) ### Features Added diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/README.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/README.md index b2e7e682be..3ce88ae6a0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/README.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/README.md @@ -1,7 +1,5 @@ # Azure Container Service Module for Go -[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6) - The `armcontainerservice` module provides operations for working with Azure Container Service. [Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/containerservice/armcontainerservice) @@ -25,7 +23,7 @@ go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/ar ## Authorization -When creating a client, you will need to provide a credential for authenticating with Azure Container Service. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. +When creating a client, you will need to provide a credential for authenticating with Azure Container Service. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. ```go cred, err := azidentity.NewDefaultAzureCredential(nil) @@ -54,7 +52,7 @@ clientFactory, err := armcontainerservice.NewClientFactory(, cr ## Clients -A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go client := clientFactory.NewAgentPoolsClient() diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/agentpools_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/agentpools_client.go index c62fa5e25c..6b5d592fe3 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/agentpools_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/agentpools_client.go @@ -49,7 +49,7 @@ func NewAgentPoolsClient(subscriptionID string, credential azcore.TokenCredentia // before cancellation can take place, a 409 error code is returned. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -78,7 +78,7 @@ func (client *AgentPoolsClient) BeginAbortLatestOperation(ctx context.Context, r // before cancellation can take place, a 409 error code is returned. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *AgentPoolsClient) abortLatestOperation(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, options *AgentPoolsClientBeginAbortLatestOperationOptions) (*http.Response, error) { var err error const operationName = "AgentPoolsClient.BeginAbortLatestOperation" @@ -124,7 +124,7 @@ func (client *AgentPoolsClient) abortLatestOperationCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -133,7 +133,7 @@ func (client *AgentPoolsClient) abortLatestOperationCreateRequest(ctx context.Co // BeginCreateOrUpdate - Creates or updates an agent pool in the specified managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -160,7 +160,7 @@ func (client *AgentPoolsClient) BeginCreateOrUpdate(ctx context.Context, resourc // CreateOrUpdate - Creates or updates an agent pool in the specified managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *AgentPoolsClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, parameters AgentPool, options *AgentPoolsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "AgentPoolsClient.BeginCreateOrUpdate" @@ -206,9 +206,15 @@ func (client *AgentPoolsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header["If-None-Match"] = []string{*options.IfNoneMatch} + } if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -218,7 +224,7 @@ func (client *AgentPoolsClient) createOrUpdateCreateRequest(ctx context.Context, // BeginDelete - Deletes an agent pool in the specified managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -243,7 +249,7 @@ func (client *AgentPoolsClient) BeginDelete(ctx context.Context, resourceGroupNa // Delete - Deletes an agent pool in the specified managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *AgentPoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, options *AgentPoolsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "AgentPoolsClient.BeginDelete" @@ -289,19 +295,22 @@ func (client *AgentPoolsClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") if options != nil && options.IgnorePodDisruptionBudget != nil { reqQP.Set("ignore-pod-disruption-budget", strconv.FormatBool(*options.IgnorePodDisruptionBudget)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } return req, nil } // BeginDeleteMachines - Deletes specific machines in an agent pool. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -328,7 +337,7 @@ func (client *AgentPoolsClient) BeginDeleteMachines(ctx context.Context, resourc // DeleteMachines - Deletes specific machines in an agent pool. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *AgentPoolsClient) deleteMachines(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, machines AgentPoolDeleteMachinesParameter, options *AgentPoolsClientBeginDeleteMachinesOptions) (*http.Response, error) { var err error const operationName = "AgentPoolsClient.BeginDeleteMachines" @@ -374,7 +383,7 @@ func (client *AgentPoolsClient) deleteMachinesCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, machines); err != nil { @@ -386,7 +395,7 @@ func (client *AgentPoolsClient) deleteMachinesCreateRequest(ctx context.Context, // Get - Gets the specified managed cluster agent pool. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -437,7 +446,7 @@ func (client *AgentPoolsClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -456,7 +465,7 @@ func (client *AgentPoolsClient) getHandleResponse(resp *http.Response) (AgentPoo // for more details about the version lifecycle. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - AgentPoolsClientGetAvailableAgentPoolVersionsOptions contains the optional parameters for the AgentPoolsClient.GetAvailableAgentPoolVersions @@ -503,7 +512,7 @@ func (client *AgentPoolsClient) getAvailableAgentPoolVersionsCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -521,7 +530,7 @@ func (client *AgentPoolsClient) getAvailableAgentPoolVersionsHandleResponse(resp // GetUpgradeProfile - Gets the upgrade profile for an agent pool. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -573,7 +582,7 @@ func (client *AgentPoolsClient) getUpgradeProfileCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -590,7 +599,7 @@ func (client *AgentPoolsClient) getUpgradeProfileHandleResponse(resp *http.Respo // NewListPager - Gets a list of agent pools in the specified managed cluster. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - AgentPoolsClientListOptions contains the optional parameters for the AgentPoolsClient.NewListPager method. @@ -637,7 +646,7 @@ func (client *AgentPoolsClient) listCreateRequest(ctx context.Context, resourceG return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -657,7 +666,7 @@ func (client *AgentPoolsClient) listHandleResponse(resp *http.Response) (AgentPo // versions, see: https://docs.microsoft.com/azure/aks/node-image-upgrade // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -686,7 +695,7 @@ func (client *AgentPoolsClient) BeginUpgradeNodeImageVersion(ctx context.Context // versions, see: https://docs.microsoft.com/azure/aks/node-image-upgrade // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *AgentPoolsClient) upgradeNodeImageVersion(ctx context.Context, resourceGroupName string, resourceName string, agentPoolName string, options *AgentPoolsClientBeginUpgradeNodeImageVersionOptions) (*http.Response, error) { var err error const operationName = "AgentPoolsClient.BeginUpgradeNodeImageVersion" @@ -732,7 +741,7 @@ func (client *AgentPoolsClient) upgradeNodeImageVersionCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/assets.json b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/assets.json index dabcb0ed37..d442470501 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/assets.json +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/resourcemanager/containerservice/armcontainerservice", - "Tag": "go/resourcemanager/containerservice/armcontainerservice_134198359a" + "Tag": "go/resourcemanager/containerservice/armcontainerservice_d075a00cde" } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/autorest.md b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/autorest.md index 157c2aede5..f2339883a6 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/autorest.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/ad60d7f8eba124edc6999677c55aba2184e303b0/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/e838027e88cca634c1545e744630de9262a6e72a/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/e838027e88cca634c1545e744630de9262a6e72a/specification/containerservice/resource-manager/Microsoft.ContainerService/aks/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 6.2.0 -tag: package-2024-08 +module-version: 6.3.0 +tag: package-2024-09 ``` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/constants.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/constants.go index db1a2ad33a..46e99857b1 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/constants.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/constants.go @@ -10,7 +10,7 @@ package armcontainerservice const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice" - moduleVersion = "v6.2.0" + moduleVersion = "v6.3.0" ) // AgentPoolMode - A cluster must have at least one 'System' Agent Pool at all times. For additional information on agent @@ -728,6 +728,25 @@ func PossibleResourceIdentityTypeValues() []ResourceIdentityType { } } +// RestrictionLevel - The restriction level applied to the cluster's node resource group. If not specified, the default is +// 'Unrestricted' +type RestrictionLevel string + +const ( + // RestrictionLevelReadOnly - Only */read RBAC permissions allowed on the managed node resource group + RestrictionLevelReadOnly RestrictionLevel = "ReadOnly" + // RestrictionLevelUnrestricted - All RBAC permissions are allowed on the managed node resource group + RestrictionLevelUnrestricted RestrictionLevel = "Unrestricted" +) + +// PossibleRestrictionLevelValues returns the possible values for the RestrictionLevel const type. +func PossibleRestrictionLevelValues() []RestrictionLevel { + return []RestrictionLevel{ + RestrictionLevelReadOnly, + RestrictionLevelUnrestricted, + } +} + // ScaleDownMode - Describes how VMs are added to or removed from Agent Pools. See billing states [https://docs.microsoft.com/azure/virtual-machines/states-billing]. type ScaleDownMode string diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/machines_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/machines_client.go index c3c6d885fe..562112dea9 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/machines_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/machines_client.go @@ -46,7 +46,7 @@ func NewMachinesClient(subscriptionID string, credential azcore.TokenCredential, // Get - Get a specific machine in the specified agent pool. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -102,7 +102,7 @@ func (client *MachinesClient) getCreateRequest(ctx context.Context, resourceGrou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -119,7 +119,7 @@ func (client *MachinesClient) getHandleResponse(resp *http.Response) (MachinesCl // NewListPager - Gets a list of machines in the specified agent pool. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - agentPoolName - The name of the agent pool. @@ -171,7 +171,7 @@ func (client *MachinesClient) listCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/maintenanceconfigurations_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/maintenanceconfigurations_client.go index 622117c2c6..bf9a0d592b 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/maintenanceconfigurations_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/maintenanceconfigurations_client.go @@ -46,7 +46,7 @@ func NewMaintenanceConfigurationsClient(subscriptionID string, credential azcore // CreateOrUpdate - Creates or updates a maintenance configuration in the specified managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - configName - The name of the maintenance configuration. @@ -99,7 +99,7 @@ func (client *MaintenanceConfigurationsClient) createOrUpdateCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -120,7 +120,7 @@ func (client *MaintenanceConfigurationsClient) createOrUpdateHandleResponse(resp // Delete - Deletes a maintenance configuration. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - configName - The name of the maintenance configuration. @@ -171,7 +171,7 @@ func (client *MaintenanceConfigurationsClient) deleteCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -180,7 +180,7 @@ func (client *MaintenanceConfigurationsClient) deleteCreateRequest(ctx context.C // Get - Gets the specified maintenance configuration of a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - configName - The name of the maintenance configuration. @@ -232,7 +232,7 @@ func (client *MaintenanceConfigurationsClient) getCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -249,7 +249,7 @@ func (client *MaintenanceConfigurationsClient) getHandleResponse(resp *http.Resp // NewListByManagedClusterPager - Gets a list of maintenance configurations in the specified managed cluster. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - MaintenanceConfigurationsClientListByManagedClusterOptions contains the optional parameters for the MaintenanceConfigurationsClient.NewListByManagedClusterPager @@ -297,7 +297,7 @@ func (client *MaintenanceConfigurationsClient) listByManagedClusterCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/managedclusters_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/managedclusters_client.go index f79514584a..e9f1dbc41d 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/managedclusters_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/managedclusters_client.go @@ -48,7 +48,7 @@ func NewManagedClustersClient(subscriptionID string, credential azcore.TokenCred // completes before cancellation can take place, a 409 error code is returned. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientBeginAbortLatestOperationOptions contains the optional parameters for the ManagedClustersClient.BeginAbortLatestOperation @@ -76,7 +76,7 @@ func (client *ManagedClustersClient) BeginAbortLatestOperation(ctx context.Conte // completes before cancellation can take place, a 409 error code is returned. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) abortLatestOperation(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginAbortLatestOperationOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginAbortLatestOperation" @@ -118,7 +118,7 @@ func (client *ManagedClustersClient) abortLatestOperationCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -127,7 +127,7 @@ func (client *ManagedClustersClient) abortLatestOperationCreateRequest(ctx conte // BeginCreateOrUpdate - Creates or updates a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - parameters - The managed cluster to create or update. @@ -153,7 +153,7 @@ func (client *ManagedClustersClient) BeginCreateOrUpdate(ctx context.Context, re // CreateOrUpdate - Creates or updates a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters ManagedCluster, options *ManagedClustersClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginCreateOrUpdate" @@ -195,9 +195,15 @@ func (client *ManagedClustersClient) createOrUpdateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } + if options != nil && options.IfNoneMatch != nil { + req.Raw().Header["If-None-Match"] = []string{*options.IfNoneMatch} + } if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -207,7 +213,7 @@ func (client *ManagedClustersClient) createOrUpdateCreateRequest(ctx context.Con // BeginDelete - Deletes a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientBeginDeleteOptions contains the optional parameters for the ManagedClustersClient.BeginDelete @@ -232,7 +238,7 @@ func (client *ManagedClustersClient) BeginDelete(ctx context.Context, resourceGr // Delete - Deletes a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginDelete" @@ -274,16 +280,19 @@ func (client *ManagedClustersClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } return req, nil } // Get - Gets a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientGetOptions contains the optional parameters for the ManagedClustersClient.Get method. @@ -329,7 +338,7 @@ func (client *ManagedClustersClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -349,7 +358,7 @@ func (client *ManagedClustersClient) getHandleResponse(resp *http.Response) (Man // [https://docs.microsoft.com/rest/api/aks/managedclusters/listclusteradmincredentials] . // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - roleName - The name of the role for managed cluster accessProfile resource. @@ -401,7 +410,7 @@ func (client *ManagedClustersClient) getAccessProfileCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -419,7 +428,7 @@ func (client *ManagedClustersClient) getAccessProfileHandleResponse(resp *http.R // GetCommandResult - Gets the results of a command which has been run on the Managed Cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - commandID - Id of the command. @@ -471,7 +480,7 @@ func (client *ManagedClustersClient) getCommandResultCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -493,7 +502,7 @@ func (client *ManagedClustersClient) getCommandResultHandleResponse(resp *http.R // and available upgrades // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - location - The name of the Azure region. // - mode - The mode of the mesh. // - options - ManagedClustersClientGetMeshRevisionProfileOptions contains the optional parameters for the ManagedClustersClient.GetMeshRevisionProfile @@ -540,7 +549,7 @@ func (client *ManagedClustersClient) getMeshRevisionProfileCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -558,7 +567,7 @@ func (client *ManagedClustersClient) getMeshRevisionProfileHandleResponse(resp * // GetMeshUpgradeProfile - Gets available upgrades for a service mesh in a cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - mode - The mode of the mesh. @@ -610,7 +619,7 @@ func (client *ManagedClustersClient) getMeshUpgradeProfileCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -628,7 +637,7 @@ func (client *ManagedClustersClient) getMeshUpgradeProfileHandleResponse(resp *h // GetUpgradeProfile - Gets the upgrade profile of a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientGetUpgradeProfileOptions contains the optional parameters for the ManagedClustersClient.GetUpgradeProfile @@ -675,7 +684,7 @@ func (client *ManagedClustersClient) getUpgradeProfileCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -692,7 +701,7 @@ func (client *ManagedClustersClient) getUpgradeProfileHandleResponse(resp *http. // NewListPager - Gets a list of managed clusters in the specified subscription. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - options - ManagedClustersClientListOptions contains the optional parameters for the ManagedClustersClient.NewListPager // method. func (client *ManagedClustersClient) NewListPager(options *ManagedClustersClientListOptions) *runtime.Pager[ManagedClustersClientListResponse] { @@ -730,7 +739,7 @@ func (client *ManagedClustersClient) listCreateRequest(ctx context.Context, opti return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -747,7 +756,7 @@ func (client *ManagedClustersClient) listHandleResponse(resp *http.Response) (Ma // NewListByResourceGroupPager - Lists managed clusters in the specified subscription and resource group. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ManagedClustersClientListByResourceGroupOptions contains the optional parameters for the ManagedClustersClient.NewListByResourceGroupPager // method. @@ -790,7 +799,7 @@ func (client *ManagedClustersClient) listByResourceGroupCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -808,7 +817,7 @@ func (client *ManagedClustersClient) listByResourceGroupHandleResponse(resp *htt // ListClusterAdminCredentials - Lists the admin credentials of a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientListClusterAdminCredentialsOptions contains the optional parameters for the ManagedClustersClient.ListClusterAdminCredentials @@ -855,7 +864,7 @@ func (client *ManagedClustersClient) listClusterAdminCredentialsCreateRequest(ct return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") if options != nil && options.ServerFqdn != nil { reqQP.Set("server-fqdn", *options.ServerFqdn) } @@ -876,7 +885,7 @@ func (client *ManagedClustersClient) listClusterAdminCredentialsHandleResponse(r // ListClusterMonitoringUserCredentials - Lists the cluster monitoring user credentials of a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientListClusterMonitoringUserCredentialsOptions contains the optional parameters for the ManagedClustersClient.ListClusterMonitoringUserCredentials @@ -923,7 +932,7 @@ func (client *ManagedClustersClient) listClusterMonitoringUserCredentialsCreateR return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") if options != nil && options.ServerFqdn != nil { reqQP.Set("server-fqdn", *options.ServerFqdn) } @@ -944,7 +953,7 @@ func (client *ManagedClustersClient) listClusterMonitoringUserCredentialsHandleR // ListClusterUserCredentials - Lists the user credentials of a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientListClusterUserCredentialsOptions contains the optional parameters for the ManagedClustersClient.ListClusterUserCredentials @@ -991,7 +1000,7 @@ func (client *ManagedClustersClient) listClusterUserCredentialsCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") if options != nil && options.Format != nil { reqQP.Set("format", string(*options.Format)) } @@ -1016,7 +1025,7 @@ func (client *ManagedClustersClient) listClusterUserCredentialsHandleResponse(re // upgrades, and details on preview status of the version // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - location - The name of the Azure region. // - options - ManagedClustersClientListKubernetesVersionsOptions contains the optional parameters for the ManagedClustersClient.ListKubernetesVersions // method. @@ -1058,7 +1067,7 @@ func (client *ManagedClustersClient) listKubernetesVersionsCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1076,7 +1085,7 @@ func (client *ManagedClustersClient) listKubernetesVersionsHandleResponse(resp * // NewListMeshRevisionProfilesPager - Contains extra metadata on each revision, including supported revisions, cluster compatibility // and available upgrades // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - location - The name of the Azure region. // - options - ManagedClustersClientListMeshRevisionProfilesOptions contains the optional parameters for the ManagedClustersClient.NewListMeshRevisionProfilesPager // method. @@ -1119,7 +1128,7 @@ func (client *ManagedClustersClient) listMeshRevisionProfilesCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1136,7 +1145,7 @@ func (client *ManagedClustersClient) listMeshRevisionProfilesHandleResponse(resp // NewListMeshUpgradeProfilesPager - Lists available upgrades for all service meshes in a specific cluster. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientListMeshUpgradeProfilesOptions contains the optional parameters for the ManagedClustersClient.NewListMeshUpgradeProfilesPager @@ -1184,7 +1193,7 @@ func (client *ManagedClustersClient) listMeshUpgradeProfilesCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1202,7 +1211,7 @@ func (client *ManagedClustersClient) listMeshUpgradeProfilesHandleResponse(resp // NewListOutboundNetworkDependenciesEndpointsPager - Gets a list of egress endpoints (network endpoints of all outbound dependencies) // in the specified managed cluster. The operation returns properties of each egress endpoint. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the @@ -1250,7 +1259,7 @@ func (client *ManagedClustersClient) listOutboundNetworkDependenciesEndpointsCre return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1269,7 +1278,7 @@ func (client *ManagedClustersClient) listOutboundNetworkDependenciesEndpointsHan // [https://aka.ms/aks-managed-aad] to update your cluster with AKS-managed Azure AD. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - parameters - The AAD profile to set on the Managed Cluster @@ -1297,7 +1306,7 @@ func (client *ManagedClustersClient) BeginResetAADProfile(ctx context.Context, r // to update your cluster with AKS-managed Azure AD. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) resetAADProfile(ctx context.Context, resourceGroupName string, resourceName string, parameters ManagedClusterAADProfile, options *ManagedClustersClientBeginResetAADProfileOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginResetAADProfile" @@ -1339,7 +1348,7 @@ func (client *ManagedClustersClient) resetAADProfileCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -1351,7 +1360,7 @@ func (client *ManagedClustersClient) resetAADProfileCreateRequest(ctx context.Co // BeginResetServicePrincipalProfile - This action cannot be performed on a cluster that is not using a service principal // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - parameters - The service principal profile to set on the managed cluster. @@ -1378,7 +1387,7 @@ func (client *ManagedClustersClient) BeginResetServicePrincipalProfile(ctx conte // ResetServicePrincipalProfile - This action cannot be performed on a cluster that is not using a service principal // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) resetServicePrincipalProfile(ctx context.Context, resourceGroupName string, resourceName string, parameters ManagedClusterServicePrincipalProfile, options *ManagedClustersClientBeginResetServicePrincipalProfileOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginResetServicePrincipalProfile" @@ -1420,7 +1429,7 @@ func (client *ManagedClustersClient) resetServicePrincipalProfileCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -1433,7 +1442,7 @@ func (client *ManagedClustersClient) resetServicePrincipalProfileCreateRequest(c // more details about rotating managed cluster certificates. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientBeginRotateClusterCertificatesOptions contains the optional parameters for the ManagedClustersClient.BeginRotateClusterCertificates @@ -1460,7 +1469,7 @@ func (client *ManagedClustersClient) BeginRotateClusterCertificates(ctx context. // details about rotating managed cluster certificates. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) rotateClusterCertificates(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginRotateClusterCertificatesOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginRotateClusterCertificates" @@ -1502,7 +1511,7 @@ func (client *ManagedClustersClient) rotateClusterCertificatesCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1511,7 +1520,7 @@ func (client *ManagedClustersClient) rotateClusterCertificatesCreateRequest(ctx // BeginRotateServiceAccountSigningKeys - Rotates the service account signing keys of a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientBeginRotateServiceAccountSigningKeysOptions contains the optional parameters for the ManagedClustersClient.BeginRotateServiceAccountSigningKeys @@ -1537,7 +1546,7 @@ func (client *ManagedClustersClient) BeginRotateServiceAccountSigningKeys(ctx co // RotateServiceAccountSigningKeys - Rotates the service account signing keys of a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) rotateServiceAccountSigningKeys(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginRotateServiceAccountSigningKeysOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginRotateServiceAccountSigningKeys" @@ -1579,7 +1588,7 @@ func (client *ManagedClustersClient) rotateServiceAccountSigningKeysCreateReques return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1590,7 +1599,7 @@ func (client *ManagedClustersClient) rotateServiceAccountSigningKeysCreateReques // [https://docs.microsoft.com/azure/aks/private-clusters#aks-run-command-preview]. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - requestPayload - The run command request @@ -1619,7 +1628,7 @@ func (client *ManagedClustersClient) BeginRunCommand(ctx context.Context, resour // [https://docs.microsoft.com/azure/aks/private-clusters#aks-run-command-preview]. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) runCommand(ctx context.Context, resourceGroupName string, resourceName string, requestPayload RunCommandRequest, options *ManagedClustersClientBeginRunCommandOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginRunCommand" @@ -1661,7 +1670,7 @@ func (client *ManagedClustersClient) runCommandCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, requestPayload); err != nil { @@ -1674,7 +1683,7 @@ func (client *ManagedClustersClient) runCommandCreateRequest(ctx context.Context // a cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientBeginStartOptions contains the optional parameters for the ManagedClustersClient.BeginStart @@ -1701,7 +1710,7 @@ func (client *ManagedClustersClient) BeginStart(ctx context.Context, resourceGro // a cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) start(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginStartOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginStart" @@ -1743,7 +1752,7 @@ func (client *ManagedClustersClient) startCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1755,7 +1764,7 @@ func (client *ManagedClustersClient) startCreateRequest(ctx context.Context, res // for more details about stopping a cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - ManagedClustersClientBeginStopOptions contains the optional parameters for the ManagedClustersClient.BeginStop @@ -1784,7 +1793,7 @@ func (client *ManagedClustersClient) BeginStop(ctx context.Context, resourceGrou // for more details about stopping a cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) stop(ctx context.Context, resourceGroupName string, resourceName string, options *ManagedClustersClientBeginStopOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginStop" @@ -1826,7 +1835,7 @@ func (client *ManagedClustersClient) stopCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1835,7 +1844,7 @@ func (client *ManagedClustersClient) stopCreateRequest(ctx context.Context, reso // BeginUpdateTags - Updates tags on a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - parameters - Parameters supplied to the Update Managed Cluster Tags operation. @@ -1861,7 +1870,7 @@ func (client *ManagedClustersClient) BeginUpdateTags(ctx context.Context, resour // UpdateTags - Updates tags on a managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *ManagedClustersClient) updateTags(ctx context.Context, resourceGroupName string, resourceName string, parameters TagsObject, options *ManagedClustersClientBeginUpdateTagsOptions) (*http.Response, error) { var err error const operationName = "ManagedClustersClient.BeginUpdateTags" @@ -1903,9 +1912,12 @@ func (client *ManagedClustersClient) updateTagsCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.IfMatch != nil { + req.Raw().Header["If-Match"] = []string{*options.IfMatch} + } if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models.go index aa214773fa..8aa03b31a1 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models.go @@ -25,6 +25,35 @@ type AccessProfile struct { KubeConfig []byte } +// AdvancedNetworking - Advanced Networking profile for enabling observability and security feature suite on a cluster. For +// more information see aka.ms/aksadvancednetworking. +type AdvancedNetworking struct { + // Indicates the enablement of Advanced Networking functionalities of observability and security on AKS clusters. When this + // is set to true, all observability and security features will be set to enabled + // unless explicitly disabled. If not specified, the default is false. + Enabled *bool + + // Observability profile to enable advanced network metrics and flow logs with historical contexts. + Observability *AdvancedNetworkingObservability + + // Security profile to enable security features on cilium based cluster. + Security *AdvancedNetworkingSecurity +} + +// AdvancedNetworkingObservability - Observability profile to enable advanced network metrics and flow logs with historical +// contexts. +type AdvancedNetworkingObservability struct { + // Indicates the enablement of Advanced Networking observability functionalities on clusters. + Enabled *bool +} + +// AdvancedNetworkingSecurity - Security profile to enable security features on cilium based cluster. +type AdvancedNetworkingSecurity struct { + // This feature allows user to configure network policy based on DNS (FQDN) names. It can be enabled only on cilium based + // clusters. If not specified, the default is false. + Enabled *bool +} + // AgentPool - Agent Pool. type AgentPool struct { // Properties of an agent pool. @@ -635,6 +664,11 @@ type ManagedCluster struct { // Resource tags. Tags map[string]*string + // READ-ONLY; Unique read-only string used to implement optimistic concurrency. The eTag value will change when the resource + // is updated. Specify an if-match or if-none-match header with the eTag value for a + // subsequent request to enable optimistic concurrency per the normal etag convention. + ETag *string + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string @@ -905,6 +939,11 @@ type ManagedClusterAgentPoolProfile struct { // is , this field will contain the full version being used. CurrentOrchestratorVersion *string + // READ-ONLY; Unique read-only string used to implement optimistic concurrency. The eTag value will change when the resource + // is updated. Specify an if-match or if-none-match header with the eTag value for a + // subsequent request to enable optimistic concurrency per the normal etag convention. + ETag *string + // READ-ONLY; The version of node image NodeImageVersion *string @@ -1073,6 +1112,11 @@ type ManagedClusterAgentPoolProfileProperties struct { // is , this field will contain the full version being used. CurrentOrchestratorVersion *string + // READ-ONLY; Unique read-only string used to implement optimistic concurrency. The eTag value will change when the resource + // is updated. Specify an if-match or if-none-match header with the eTag value for a + // subsequent request to enable optimistic concurrency per the normal etag convention. + ETag *string + // READ-ONLY; The version of node image NodeImageVersion *string @@ -1282,6 +1326,12 @@ type ManagedClusterNATGatewayProfile struct { ManagedOutboundIPProfile *ManagedClusterManagedOutboundIPProfile } +// ManagedClusterNodeResourceGroupProfile - Node resource group lockdown profile for a managed cluster. +type ManagedClusterNodeResourceGroupProfile struct { + // The restriction level applied to the cluster's node resource group. If not specified, the default is 'Unrestricted' + RestrictionLevel *RestrictionLevel +} + // ManagedClusterOIDCIssuerProfile - The OIDC issuer profile of the Managed Cluster. type ManagedClusterOIDCIssuerProfile struct { // Whether the OIDC issuer is enabled. @@ -1441,7 +1491,9 @@ type ManagedClusterProperties struct { // Configurations for provisioning the cluster with HTTP proxy servers. HTTPProxyConfig *ManagedClusterHTTPProxyConfig - // Identities associated with the cluster. + // The user identity associated with the managed cluster. This identity will be used by the kubelet. Only one user assigned + // identity is allowed. The only accepted key is "kubeletidentity", with value of + // "resourceId": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}". IdentityProfile map[string]*UserAssignedIdentity // Ingress profile for the managed cluster. @@ -1468,6 +1520,9 @@ type ManagedClusterProperties struct { // The name of the resource group containing agent pool nodes. NodeResourceGroup *string + // Profile of the node resource group configuration. + NodeResourceGroupProfile *ManagedClusterNodeResourceGroupProfile + // The OIDC issuer profile of the Managed Cluster. OidcIssuerProfile *ManagedClusterOIDCIssuerProfile @@ -1890,6 +1945,10 @@ type MeshUpgradeProfileProperties struct { // NetworkProfile - Profile of network configuration. type NetworkProfile struct { + // Advanced Networking profile for enabling observability and security feature suite on a cluster. For more information see + // aka.ms/aksadvancednetworking. + AdvancedNetworking *AdvancedNetworking + // An IP address assigned to the Kubernetes DNS service. It must be within the Kubernetes service address range specified // in serviceCidr. DNSServiceIP *string diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models_serde.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models_serde.go index 2cbf85c4fc..c680389b79 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models_serde.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/models_serde.go @@ -78,6 +78,95 @@ func (a *AccessProfile) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AdvancedNetworking. +func (a AdvancedNetworking) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", a.Enabled) + populate(objectMap, "observability", a.Observability) + populate(objectMap, "security", a.Security) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdvancedNetworking. +func (a *AdvancedNetworking) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabled": + err = unpopulate(val, "Enabled", &a.Enabled) + delete(rawMsg, key) + case "observability": + err = unpopulate(val, "Observability", &a.Observability) + delete(rawMsg, key) + case "security": + err = unpopulate(val, "Security", &a.Security) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AdvancedNetworkingObservability. +func (a AdvancedNetworkingObservability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", a.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdvancedNetworkingObservability. +func (a *AdvancedNetworkingObservability) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabled": + err = unpopulate(val, "Enabled", &a.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AdvancedNetworkingSecurity. +func (a AdvancedNetworkingSecurity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", a.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AdvancedNetworkingSecurity. +func (a *AdvancedNetworkingSecurity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabled": + err = unpopulate(val, "Enabled", &a.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type AgentPool. func (a AgentPool) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1748,6 +1837,7 @@ func (m *MaintenanceWindow) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ManagedCluster. func (m ManagedCluster) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "eTag", m.ETag) populate(objectMap, "extendedLocation", m.ExtendedLocation) populate(objectMap, "id", m.ID) populate(objectMap, "identity", m.Identity) @@ -1770,6 +1860,9 @@ func (m *ManagedCluster) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "eTag": + err = unpopulate(val, "ETag", &m.ETag) + delete(rawMsg, key) case "extendedLocation": err = unpopulate(val, "ExtendedLocation", &m.ExtendedLocation) delete(rawMsg, key) @@ -2031,6 +2124,7 @@ func (m ManagedClusterAgentPoolProfile) MarshalJSON() ([]byte, error) { populate(objectMap, "count", m.Count) populate(objectMap, "creationData", m.CreationData) populate(objectMap, "currentOrchestratorVersion", m.CurrentOrchestratorVersion) + populate(objectMap, "eTag", m.ETag) populate(objectMap, "enableAutoScaling", m.EnableAutoScaling) populate(objectMap, "enableEncryptionAtHost", m.EnableEncryptionAtHost) populate(objectMap, "enableFIPS", m.EnableFIPS) @@ -2099,6 +2193,9 @@ func (m *ManagedClusterAgentPoolProfile) UnmarshalJSON(data []byte) error { case "currentOrchestratorVersion": err = unpopulate(val, "CurrentOrchestratorVersion", &m.CurrentOrchestratorVersion) delete(rawMsg, key) + case "eTag": + err = unpopulate(val, "ETag", &m.ETag) + delete(rawMsg, key) case "enableAutoScaling": err = unpopulate(val, "EnableAutoScaling", &m.EnableAutoScaling) delete(rawMsg, key) @@ -2238,6 +2335,7 @@ func (m ManagedClusterAgentPoolProfileProperties) MarshalJSON() ([]byte, error) populate(objectMap, "count", m.Count) populate(objectMap, "creationData", m.CreationData) populate(objectMap, "currentOrchestratorVersion", m.CurrentOrchestratorVersion) + populate(objectMap, "eTag", m.ETag) populate(objectMap, "enableAutoScaling", m.EnableAutoScaling) populate(objectMap, "enableEncryptionAtHost", m.EnableEncryptionAtHost) populate(objectMap, "enableFIPS", m.EnableFIPS) @@ -2305,6 +2403,9 @@ func (m *ManagedClusterAgentPoolProfileProperties) UnmarshalJSON(data []byte) er case "currentOrchestratorVersion": err = unpopulate(val, "CurrentOrchestratorVersion", &m.CurrentOrchestratorVersion) delete(rawMsg, key) + case "eTag": + err = unpopulate(val, "ETag", &m.ETag) + delete(rawMsg, key) case "enableAutoScaling": err = unpopulate(val, "EnableAutoScaling", &m.EnableAutoScaling) delete(rawMsg, key) @@ -2984,6 +3085,33 @@ func (m *ManagedClusterNATGatewayProfile) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ManagedClusterNodeResourceGroupProfile. +func (m ManagedClusterNodeResourceGroupProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "restrictionLevel", m.RestrictionLevel) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedClusterNodeResourceGroupProfile. +func (m *ManagedClusterNodeResourceGroupProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "restrictionLevel": + err = unpopulate(val, "RestrictionLevel", &m.RestrictionLevel) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ManagedClusterOIDCIssuerProfile. func (m ManagedClusterOIDCIssuerProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3327,6 +3455,7 @@ func (m ManagedClusterProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "metricsProfile", m.MetricsProfile) populate(objectMap, "networkProfile", m.NetworkProfile) populate(objectMap, "nodeResourceGroup", m.NodeResourceGroup) + populate(objectMap, "nodeResourceGroupProfile", m.NodeResourceGroupProfile) populate(objectMap, "oidcIssuerProfile", m.OidcIssuerProfile) populate(objectMap, "podIdentityProfile", m.PodIdentityProfile) populate(objectMap, "powerState", m.PowerState) @@ -3430,6 +3559,9 @@ func (m *ManagedClusterProperties) UnmarshalJSON(data []byte) error { case "nodeResourceGroup": err = unpopulate(val, "NodeResourceGroup", &m.NodeResourceGroup) delete(rawMsg, key) + case "nodeResourceGroupProfile": + err = unpopulate(val, "NodeResourceGroupProfile", &m.NodeResourceGroupProfile) + delete(rawMsg, key) case "oidcIssuerProfile": err = unpopulate(val, "OidcIssuerProfile", &m.OidcIssuerProfile) delete(rawMsg, key) @@ -4430,6 +4562,7 @@ func (m *MeshUpgradeProfileProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type NetworkProfile. func (n NetworkProfile) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "advancedNetworking", n.AdvancedNetworking) populate(objectMap, "dnsServiceIP", n.DNSServiceIP) populate(objectMap, "ipFamilies", n.IPFamilies) populate(objectMap, "loadBalancerProfile", n.LoadBalancerProfile) @@ -4457,6 +4590,9 @@ func (n *NetworkProfile) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "advancedNetworking": + err = unpopulate(val, "AdvancedNetworking", &n.AdvancedNetworking) + delete(rawMsg, key) case "dnsServiceIP": err = unpopulate(val, "DNSServiceIP", &n.DNSServiceIP) delete(rawMsg, key) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/operations_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/operations_client.go index 06d8cc67c8..708497743a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/operations_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Gets a list of operations. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -73,7 +73,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/options.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/options.go index 46faa5387c..84c564e892 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/options.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/options.go @@ -18,6 +18,12 @@ type AgentPoolsClientBeginAbortLatestOperationOptions struct { // AgentPoolsClientBeginCreateOrUpdateOptions contains the optional parameters for the AgentPoolsClient.BeginCreateOrUpdate // method. type AgentPoolsClientBeginCreateOrUpdateOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + + // The request should only proceed if no entity matches this string. + IfNoneMatch *string + // Resumes the LRO from the provided token. ResumeToken string } @@ -31,6 +37,9 @@ type AgentPoolsClientBeginDeleteMachinesOptions struct { // AgentPoolsClientBeginDeleteOptions contains the optional parameters for the AgentPoolsClient.BeginDelete method. type AgentPoolsClientBeginDeleteOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // ignore-pod-disruption-budget=true to delete those pods on a node without considering Pod Disruption Budget IgnorePodDisruptionBudget *bool @@ -110,12 +119,21 @@ type ManagedClustersClientBeginAbortLatestOperationOptions struct { // ManagedClustersClientBeginCreateOrUpdateOptions contains the optional parameters for the ManagedClustersClient.BeginCreateOrUpdate // method. type ManagedClustersClientBeginCreateOrUpdateOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + + // The request should only proceed if no entity matches this string. + IfNoneMatch *string + // Resumes the LRO from the provided token. ResumeToken string } // ManagedClustersClientBeginDeleteOptions contains the optional parameters for the ManagedClustersClient.BeginDelete method. type ManagedClustersClientBeginDeleteOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // Resumes the LRO from the provided token. ResumeToken string } @@ -170,6 +188,9 @@ type ManagedClustersClientBeginStopOptions struct { // ManagedClustersClientBeginUpdateTagsOptions contains the optional parameters for the ManagedClustersClient.BeginUpdateTags // method. type ManagedClustersClientBeginUpdateTagsOptions struct { + // The request should only proceed if an entity matches this string. + IfMatch *string + // Resumes the LRO from the provided token. ResumeToken string } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privateendpointconnections_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privateendpointconnections_client.go index 975a836bf5..e666eb61df 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privateendpointconnections_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privateendpointconnections_client.go @@ -46,7 +46,7 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // BeginDelete - Deletes a private endpoint connection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - privateEndpointConnectionName - The name of the private endpoint connection. @@ -72,7 +72,7 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Delete - Deletes a private endpoint connection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginDelete" @@ -118,7 +118,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -127,7 +127,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - To learn more about private clusters, see: https://docs.microsoft.com/azure/aks/private-clusters // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - privateEndpointConnectionName - The name of the private endpoint connection. @@ -179,7 +179,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -197,7 +197,7 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // List - To learn more about private clusters, see: https://docs.microsoft.com/azure/aks/private-clusters // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - PrivateEndpointConnectionsClientListOptions contains the optional parameters for the PrivateEndpointConnectionsClient.List @@ -244,7 +244,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -262,7 +262,7 @@ func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *http.Re // Update - Updates a private endpoint connection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - privateEndpointConnectionName - The name of the private endpoint connection. @@ -315,7 +315,7 @@ func (client *PrivateEndpointConnectionsClient) updateCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privatelinkresources_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privatelinkresources_client.go index eac5bfaf38..e85c096902 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privatelinkresources_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/privatelinkresources_client.go @@ -46,7 +46,7 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // List - To learn more about private clusters, see: https://docs.microsoft.com/azure/aks/private-clusters // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - PrivateLinkResourcesClientListOptions contains the optional parameters for the PrivateLinkResourcesClient.List @@ -93,7 +93,7 @@ func (client *PrivateLinkResourcesClient) listCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/resolveprivatelinkserviceid_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/resolveprivatelinkserviceid_client.go index b9be6ed99a..b1a8fc1144 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/resolveprivatelinkserviceid_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/resolveprivatelinkserviceid_client.go @@ -46,7 +46,7 @@ func NewResolvePrivateLinkServiceIDClient(subscriptionID string, credential azco // POST - Gets the private link service ID for the specified managed cluster. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - parameters - Parameters required in order to resolve a private link service ID. @@ -94,7 +94,7 @@ func (client *ResolvePrivateLinkServiceIDClient) postCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/snapshots_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/snapshots_client.go index 3ce76250e6..b720528337 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/snapshots_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/snapshots_client.go @@ -46,7 +46,7 @@ func NewSnapshotsClient(subscriptionID string, credential azcore.TokenCredential // CreateOrUpdate - Creates or updates a snapshot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - parameters - The snapshot to create or update. @@ -94,7 +94,7 @@ func (client *SnapshotsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -115,7 +115,7 @@ func (client *SnapshotsClient) createOrUpdateHandleResponse(resp *http.Response) // Delete - Deletes a snapshot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - SnapshotsClientDeleteOptions contains the optional parameters for the SnapshotsClient.Delete method. @@ -160,7 +160,7 @@ func (client *SnapshotsClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -169,7 +169,7 @@ func (client *SnapshotsClient) deleteCreateRequest(ctx context.Context, resource // Get - Gets a snapshot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - SnapshotsClientGetOptions contains the optional parameters for the SnapshotsClient.Get method. @@ -215,7 +215,7 @@ func (client *SnapshotsClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -232,7 +232,7 @@ func (client *SnapshotsClient) getHandleResponse(resp *http.Response) (Snapshots // NewListPager - Gets a list of snapshots in the specified subscription. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - options - SnapshotsClientListOptions contains the optional parameters for the SnapshotsClient.NewListPager method. func (client *SnapshotsClient) NewListPager(options *SnapshotsClientListOptions) *runtime.Pager[SnapshotsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[SnapshotsClientListResponse]{ @@ -269,7 +269,7 @@ func (client *SnapshotsClient) listCreateRequest(ctx context.Context, options *S return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -286,7 +286,7 @@ func (client *SnapshotsClient) listHandleResponse(resp *http.Response) (Snapshot // NewListByResourceGroupPager - Lists snapshots in the specified subscription and resource group. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - SnapshotsClientListByResourceGroupOptions contains the optional parameters for the SnapshotsClient.NewListByResourceGroupPager // method. @@ -329,7 +329,7 @@ func (client *SnapshotsClient) listByResourceGroupCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -347,7 +347,7 @@ func (client *SnapshotsClient) listByResourceGroupHandleResponse(resp *http.Resp // UpdateTags - Updates tags on a snapshot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - parameters - Parameters supplied to the Update snapshot Tags operation. @@ -394,7 +394,7 @@ func (client *SnapshotsClient) updateTagsCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessrolebindings_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessrolebindings_client.go index 56ae891dd3..3f2357ddc0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessrolebindings_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessrolebindings_client.go @@ -46,7 +46,7 @@ func NewTrustedAccessRoleBindingsClient(subscriptionID string, credential azcore // BeginCreateOrUpdate - Create or update a trusted access role binding // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - trustedAccessRoleBindingName - The name of trusted access role binding. @@ -73,7 +73,7 @@ func (client *TrustedAccessRoleBindingsClient) BeginCreateOrUpdate(ctx context.C // CreateOrUpdate - Create or update a trusted access role binding // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *TrustedAccessRoleBindingsClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, trustedAccessRoleBindingName string, trustedAccessRoleBinding TrustedAccessRoleBinding, options *TrustedAccessRoleBindingsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error const operationName = "TrustedAccessRoleBindingsClient.BeginCreateOrUpdate" @@ -119,7 +119,7 @@ func (client *TrustedAccessRoleBindingsClient) createOrUpdateCreateRequest(ctx c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, trustedAccessRoleBinding); err != nil { @@ -131,7 +131,7 @@ func (client *TrustedAccessRoleBindingsClient) createOrUpdateCreateRequest(ctx c // BeginDelete - Delete a trusted access role binding. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - trustedAccessRoleBindingName - The name of trusted access role binding. @@ -157,7 +157,7 @@ func (client *TrustedAccessRoleBindingsClient) BeginDelete(ctx context.Context, // Delete - Delete a trusted access role binding. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 func (client *TrustedAccessRoleBindingsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, trustedAccessRoleBindingName string, options *TrustedAccessRoleBindingsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "TrustedAccessRoleBindingsClient.BeginDelete" @@ -203,7 +203,7 @@ func (client *TrustedAccessRoleBindingsClient) deleteCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -212,7 +212,7 @@ func (client *TrustedAccessRoleBindingsClient) deleteCreateRequest(ctx context.C // Get - Get a trusted access role binding. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - trustedAccessRoleBindingName - The name of trusted access role binding. @@ -264,7 +264,7 @@ func (client *TrustedAccessRoleBindingsClient) getCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -281,7 +281,7 @@ func (client *TrustedAccessRoleBindingsClient) getHandleResponse(resp *http.Resp // NewListPager - List trusted access role bindings. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceName - The name of the managed cluster resource. // - options - TrustedAccessRoleBindingsClientListOptions contains the optional parameters for the TrustedAccessRoleBindingsClient.NewListPager @@ -329,7 +329,7 @@ func (client *TrustedAccessRoleBindingsClient) listCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessroles_client.go b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessroles_client.go index e08d2af088..c8b0df43ea 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessroles_client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6/trustedaccessroles_client.go @@ -45,7 +45,7 @@ func NewTrustedAccessRolesClient(subscriptionID string, credential azcore.TokenC // NewListPager - List supported trusted access roles. // -// Generated from API version 2024-08-01 +// Generated from API version 2024-09-01 // - location - The name of the Azure region. // - options - TrustedAccessRolesClientListOptions contains the optional parameters for the TrustedAccessRolesClient.NewListPager // method. @@ -88,7 +88,7 @@ func (client *TrustedAccessRolesClient) listCreateRequest(ctx context.Context, l return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2024-08-01") + reqQP.Set("api-version", "2024-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/vendor/go.opentelemetry.io/otel/exporters/prometheus/exporter.go b/vendor/go.opentelemetry.io/otel/exporters/prometheus/exporter.go index b0f5f3730d..3cd457a03c 100644 --- a/vendor/go.opentelemetry.io/otel/exporters/prometheus/exporter.go +++ b/vendor/go.opentelemetry.io/otel/exporters/prometheus/exporter.go @@ -33,15 +33,14 @@ const ( scopeInfoMetricName = "otel_scope_info" scopeInfoDescription = "Instrumentation Scope metadata" + scopeNameLabel = "otel_scope_name" + scopeVersionLabel = "otel_scope_version" + traceIDExemplarKey = "trace_id" spanIDExemplarKey = "span_id" ) -var ( - scopeInfoKeys = [2]string{"otel_scope_name", "otel_scope_version"} - - errScopeInvalid = errors.New("invalid scope") -) +var errScopeInvalid = errors.New("invalid scope") // Exporter is a Prometheus Exporter that embeds the OTel metric.Reader // interface for easy instantiation with a MeterProvider. @@ -187,7 +186,11 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) { } for _, scopeMetrics := range metrics.ScopeMetrics { - var keys, values [2]string + n := len(c.resourceKeyVals.keys) + 2 // resource attrs + scope name + scope version + kv := keyVals{ + keys: make([]string, 0, n), + vals: make([]string, 0, n), + } if !c.disableScopeInfo { scopeInfo, err := c.scopeInfo(scopeMetrics.Scope) @@ -202,10 +205,13 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) { ch <- scopeInfo - keys = scopeInfoKeys - values = [2]string{scopeMetrics.Scope.Name, scopeMetrics.Scope.Version} + kv.keys = append(kv.keys, scopeNameLabel, scopeVersionLabel) + kv.vals = append(kv.vals, scopeMetrics.Scope.Name, scopeMetrics.Scope.Version) } + kv.keys = append(kv.keys, c.resourceKeyVals.keys...) + kv.vals = append(kv.vals, c.resourceKeyVals.vals...) + for _, m := range scopeMetrics.Metrics { typ := c.metricType(m) if typ == nil { @@ -224,25 +230,27 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) { switch v := m.Data.(type) { case metricdata.Histogram[int64]: - addHistogramMetric(ch, v, m, keys, values, name, c.resourceKeyVals) + addHistogramMetric(ch, v, m, name, kv) case metricdata.Histogram[float64]: - addHistogramMetric(ch, v, m, keys, values, name, c.resourceKeyVals) + addHistogramMetric(ch, v, m, name, kv) case metricdata.Sum[int64]: - addSumMetric(ch, v, m, keys, values, name, c.resourceKeyVals) + addSumMetric(ch, v, m, name, kv) case metricdata.Sum[float64]: - addSumMetric(ch, v, m, keys, values, name, c.resourceKeyVals) + addSumMetric(ch, v, m, name, kv) case metricdata.Gauge[int64]: - addGaugeMetric(ch, v, m, keys, values, name, c.resourceKeyVals) + addGaugeMetric(ch, v, m, name, kv) case metricdata.Gauge[float64]: - addGaugeMetric(ch, v, m, keys, values, name, c.resourceKeyVals) + addGaugeMetric(ch, v, m, name, kv) } } } } -func addHistogramMetric[N int64 | float64](ch chan<- prometheus.Metric, histogram metricdata.Histogram[N], m metricdata.Metrics, ks, vs [2]string, name string, resourceKV keyVals) { +func addHistogramMetric[N int64 | float64](ch chan<- prometheus.Metric, histogram metricdata.Histogram[N], m metricdata.Metrics, name string, kv keyVals) { for _, dp := range histogram.DataPoints { - keys, values := getAttrs(dp.Attributes, ks, vs, resourceKV) + keys, values := getAttrs(dp.Attributes) + keys = append(keys, kv.keys...) + values = append(values, kv.vals...) desc := prometheus.NewDesc(name, m.Description, keys, nil) buckets := make(map[float64]uint64, len(dp.Bounds)) @@ -262,14 +270,16 @@ func addHistogramMetric[N int64 | float64](ch chan<- prometheus.Metric, histogra } } -func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata.Sum[N], m metricdata.Metrics, ks, vs [2]string, name string, resourceKV keyVals) { +func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata.Sum[N], m metricdata.Metrics, name string, kv keyVals) { valueType := prometheus.CounterValue if !sum.IsMonotonic { valueType = prometheus.GaugeValue } for _, dp := range sum.DataPoints { - keys, values := getAttrs(dp.Attributes, ks, vs, resourceKV) + keys, values := getAttrs(dp.Attributes) + keys = append(keys, kv.keys...) + values = append(values, kv.vals...) desc := prometheus.NewDesc(name, m.Description, keys, nil) m, err := prometheus.NewConstMetric(desc, valueType, float64(dp.Value), values...) @@ -277,14 +287,20 @@ func addSumMetric[N int64 | float64](ch chan<- prometheus.Metric, sum metricdata otel.Handle(err) continue } - m = addExemplars(m, dp.Exemplars) + // GaugeValues don't support Exemplars at this time + // https://github.com/prometheus/client_golang/blob/aef8aedb4b6e1fb8ac1c90790645169125594096/prometheus/metric.go#L199 + if valueType != prometheus.GaugeValue { + m = addExemplars(m, dp.Exemplars) + } ch <- m } } -func addGaugeMetric[N int64 | float64](ch chan<- prometheus.Metric, gauge metricdata.Gauge[N], m metricdata.Metrics, ks, vs [2]string, name string, resourceKV keyVals) { +func addGaugeMetric[N int64 | float64](ch chan<- prometheus.Metric, gauge metricdata.Gauge[N], m metricdata.Metrics, name string, kv keyVals) { for _, dp := range gauge.DataPoints { - keys, values := getAttrs(dp.Attributes, ks, vs, resourceKV) + keys, values := getAttrs(dp.Attributes) + keys = append(keys, kv.keys...) + values = append(values, kv.vals...) desc := prometheus.NewDesc(name, m.Description, keys, nil) m, err := prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(dp.Value), values...) @@ -296,9 +312,9 @@ func addGaugeMetric[N int64 | float64](ch chan<- prometheus.Metric, gauge metric } } -// getAttrs parses the attribute.Set to two lists of matching Prometheus-style +// getAttrs converts the attribute.Set to two lists of matching Prometheus-style // keys and values. -func getAttrs(attrs attribute.Set, ks, vs [2]string, resourceKV keyVals) ([]string, []string) { +func getAttrs(attrs attribute.Set) ([]string, []string) { keys := make([]string, 0, attrs.Len()) values := make([]string, 0, attrs.Len()) itr := attrs.Iter() @@ -330,30 +346,24 @@ func getAttrs(attrs attribute.Set, ks, vs [2]string, resourceKV keyVals) ([]stri values = append(values, strings.Join(vals, ";")) } } - - if ks[0] != "" { - keys = append(keys, ks[:]...) - values = append(values, vs[:]...) - } - - for idx := range resourceKV.keys { - keys = append(keys, resourceKV.keys[idx]) - values = append(values, resourceKV.vals[idx]) - } - return keys, values } func createInfoMetric(name, description string, res *resource.Resource) (prometheus.Metric, error) { - keys, values := getAttrs(*res.Set(), [2]string{}, [2]string{}, keyVals{}) + keys, values := getAttrs(*res.Set()) desc := prometheus.NewDesc(name, description, keys, nil) return prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(1), values...) } func createScopeInfoMetric(scope instrumentation.Scope) (prometheus.Metric, error) { - keys := scopeInfoKeys[:] + attrs := make([]attribute.KeyValue, 0, scope.Attributes.Len()+2) // resource attrs + scope name + scope version + attrs = append(attrs, scope.Attributes.ToSlice()...) + attrs = append(attrs, attribute.String(scopeNameLabel, scope.Name)) + attrs = append(attrs, attribute.String(scopeVersionLabel, scope.Version)) + + keys, values := getAttrs(attribute.NewSet(attrs...)) desc := prometheus.NewDesc(scopeInfoMetricName, scopeInfoDescription, keys, nil) - return prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(1), scope.Name, scope.Version) + return prometheus.NewConstMetric(desc, prometheus.GaugeValue, float64(1), values...) } var unitSuffixes = map[string]string{ @@ -442,7 +452,7 @@ func (c *collector) createResourceAttributes(res *resource.Resource) { defer c.mu.Unlock() resourceAttrs, _ := res.Set().Filter(c.resourceAttributesFilter) - resourceKeys, resourceValues := getAttrs(resourceAttrs, [2]string{}, [2]string{}, keyVals{}) + resourceKeys, resourceValues := getAttrs(resourceAttrs) c.resourceKeyVals = keyVals{keys: resourceKeys, vals: resourceValues} } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/config.go b/vendor/go.opentelemetry.io/otel/sdk/metric/config.go index 544275a114..203cd9d650 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/config.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/config.go @@ -5,18 +5,22 @@ package metric // import "go.opentelemetry.io/otel/sdk/metric" import ( "context" - "fmt" + "errors" + "os" + "strings" "sync" "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/sdk/metric/exemplar" "go.opentelemetry.io/otel/sdk/resource" ) // config contains configuration options for a MeterProvider. type config struct { - res *resource.Resource - readers []Reader - views []View + res *resource.Resource + readers []Reader + views []View + exemplarFilter exemplar.Filter } // readerSignals returns a force-flush and shutdown function for a @@ -40,25 +44,13 @@ func (c config) readerSignals() (forceFlush, shutdown func(context.Context) erro // value. func unify(funcs []func(context.Context) error) func(context.Context) error { return func(ctx context.Context) error { - var errs []error + var err error for _, f := range funcs { - if err := f(ctx); err != nil { - errs = append(errs, err) + if e := f(ctx); e != nil { + err = errors.Join(err, e) } } - return unifyErrors(errs) - } -} - -// unifyErrors combines multiple errors into a single error. -func unifyErrors(errs []error) error { - switch len(errs) { - case 0: - return nil - case 1: - return errs[0] - default: - return fmt.Errorf("%v", errs) + return err } } @@ -76,7 +68,13 @@ func unifyShutdown(funcs []func(context.Context) error) func(context.Context) er // newConfig returns a config configured with options. func newConfig(options []Option) config { - conf := config{res: resource.Default()} + conf := config{ + res: resource.Default(), + exemplarFilter: exemplar.TraceBasedFilter, + } + for _, o := range meterProviderOptionsFromEnv() { + conf = o.apply(conf) + } for _, o := range options { conf = o.apply(conf) } @@ -140,3 +138,35 @@ func WithView(views ...View) Option { return cfg }) } + +// WithExemplarFilter configures the exemplar filter. +// +// The exemplar filter determines which measurements are offered to the +// exemplar reservoir, but the exemplar reservoir makes the final decision of +// whether to store an exemplar. +// +// By default, the [exemplar.SampledFilter] +// is used. Exemplars can be entirely disabled by providing the +// [exemplar.AlwaysOffFilter]. +func WithExemplarFilter(filter exemplar.Filter) Option { + return optionFunc(func(cfg config) config { + cfg.exemplarFilter = filter + return cfg + }) +} + +func meterProviderOptionsFromEnv() []Option { + var opts []Option + // https://github.com/open-telemetry/opentelemetry-specification/blob/d4b241f451674e8f611bb589477680341006ad2b/specification/configuration/sdk-environment-variables.md#exemplar + const filterEnvKey = "OTEL_METRICS_EXEMPLAR_FILTER" + + switch strings.ToLower(strings.TrimSpace(os.Getenv(filterEnvKey))) { + case "always_on": + opts = append(opts, WithExemplarFilter(exemplar.AlwaysOnFilter)) + case "always_off": + opts = append(opts, WithExemplarFilter(exemplar.AlwaysOffFilter)) + case "trace_based": + opts = append(opts, WithExemplarFilter(exemplar.TraceBasedFilter)) + } + return opts +} diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go index 4beaa9ea00..0335b8ae48 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar.go @@ -4,48 +4,49 @@ package metric // import "go.opentelemetry.io/otel/sdk/metric" import ( - "os" "runtime" - "slices" + "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/sdk/metric/exemplar" "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" ) -// reservoirFunc returns the appropriately configured exemplar reservoir -// creation func based on the passed InstrumentKind and user defined -// environment variables. -// -// Note: This will only return non-nil values when the experimental exemplar -// feature is enabled and the OTEL_METRICS_EXEMPLAR_FILTER environment variable -// is not set to always_off. -func reservoirFunc[N int64 | float64](agg Aggregation) func() aggregate.FilteredExemplarReservoir[N] { - // https://github.com/open-telemetry/opentelemetry-specification/blob/d4b241f451674e8f611bb589477680341006ad2b/specification/configuration/sdk-environment-variables.md#exemplar - const filterEnvKey = "OTEL_METRICS_EXEMPLAR_FILTER" - - var filter exemplar.Filter +// ExemplarReservoirProviderSelector selects the +// [exemplar.ReservoirProvider] to use +// based on the [Aggregation] of the metric. +type ExemplarReservoirProviderSelector func(Aggregation) exemplar.ReservoirProvider - switch os.Getenv(filterEnvKey) { - case "always_on": - filter = exemplar.AlwaysOnFilter - case "always_off": - return aggregate.DropReservoir - case "trace_based": - fallthrough - default: - filter = exemplar.TraceBasedFilter +// reservoirFunc returns the appropriately configured exemplar reservoir +// creation func based on the passed InstrumentKind and filter configuration. +func reservoirFunc[N int64 | float64](provider exemplar.ReservoirProvider, filter exemplar.Filter) func(attribute.Set) aggregate.FilteredExemplarReservoir[N] { + return func(attrs attribute.Set) aggregate.FilteredExemplarReservoir[N] { + return aggregate.NewFilteredExemplarReservoir[N](filter, provider(attrs)) } +} +// DefaultExemplarReservoirProviderSelector returns the default +// [exemplar.ReservoirProvider] for the +// provided [Aggregation]. +// +// For explicit bucket histograms with more than 1 bucket, it uses the +// [exemplar.HistogramReservoirProvider]. +// For exponential histograms, it uses the +// [exemplar.FixedSizeReservoirProvider] +// with a size of min(20, max_buckets). +// For all other aggregations, it uses the +// [exemplar.FixedSizeReservoirProvider] +// with a size equal to the number of CPUs. +// +// Exemplar default reservoirs MAY change in a minor version bump. No +// guarantees are made on the shape or statistical properties of returned +// exemplars. +func DefaultExemplarReservoirProviderSelector(agg Aggregation) exemplar.ReservoirProvider { // https://github.com/open-telemetry/opentelemetry-specification/blob/d4b241f451674e8f611bb589477680341006ad2b/specification/metrics/sdk.md#exemplar-defaults // Explicit bucket histogram aggregation with more than 1 bucket will // use AlignedHistogramBucketExemplarReservoir. a, ok := agg.(AggregationExplicitBucketHistogram) if ok && len(a.Boundaries) > 0 { - cp := slices.Clone(a.Boundaries) - return func() aggregate.FilteredExemplarReservoir[N] { - bounds := cp - return aggregate.NewFilteredExemplarReservoir[N](filter, exemplar.NewHistogramReservoir(bounds)) - } + return exemplar.HistogramReservoirProvider(a.Boundaries) } var n int @@ -72,7 +73,5 @@ func reservoirFunc[N int64 | float64](agg Aggregation) func() aggregate.Filtered } } - return func() aggregate.FilteredExemplarReservoir[N] { - return aggregate.NewFilteredExemplarReservoir[N](filter, exemplar.NewFixedSizeReservoir(n)) - } + return exemplar.FixedSizeReservoirProvider(n) } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go index 4d485200f5..b595e2acef 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/filter.go @@ -27,3 +27,8 @@ func TraceBasedFilter(ctx context.Context) bool { func AlwaysOnFilter(ctx context.Context) bool { return true } + +// AlwaysOffFilter is a [Filter] that never offers measurements. +func AlwaysOffFilter(ctx context.Context) bool { + return false +} diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go index 34160ca608..d4aab0aad4 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/fixed_size_reservoir.go @@ -12,6 +12,13 @@ import ( "go.opentelemetry.io/otel/attribute" ) +// FixedSizeReservoirProvider returns a provider of [FixedSizeReservoir]. +func FixedSizeReservoirProvider(k int) ReservoirProvider { + return func(_ attribute.Set) Reservoir { + return NewFixedSizeReservoir(k) + } +} + // NewFixedSizeReservoir returns a [FixedSizeReservoir] that samples at most // k exemplars. If there are k or less measurements made, the Reservoir will // sample each one. If there are more than k, the Reservoir will then randomly diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go index c27545a409..3b76cf305a 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/histogram_reservoir.go @@ -12,13 +12,21 @@ import ( "go.opentelemetry.io/otel/attribute" ) +// HistogramReservoirProvider is a provider of [HistogramReservoir]. +func HistogramReservoirProvider(bounds []float64) ReservoirProvider { + cp := slices.Clone(bounds) + slices.Sort(cp) + return func(_ attribute.Set) Reservoir { + return NewHistogramReservoir(cp) + } +} + // NewHistogramReservoir returns a [HistogramReservoir] that samples the last // measurement that falls within a histogram bucket. The histogram bucket // upper-boundaries are define by bounds. // -// The passed bounds will be sorted by this function. +// The passed bounds must be sorted before calling this function. func NewHistogramReservoir(bounds []float64) *HistogramReservoir { - slices.Sort(bounds) return &HistogramReservoir{ bounds: bounds, storage: newStorage(len(bounds) + 1), diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go index 055ce5bc8e..ba5cd1a6b3 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/exemplar/reservoir.go @@ -30,3 +30,11 @@ type Reservoir interface { // The Reservoir state is preserved after this call. Collect(dest *[]Exemplar) } + +// ReservoirProvider creates new [Reservoir]s. +// +// The attributes provided are attributes which are kept by the aggregation, and +// are exclusive with attributes passed to Offer. The combination of these +// attributes and the attributes passed to Offer is the complete set of +// attributes a measurement was made with. +type ReservoirProvider func(attr attribute.Set) Reservoir diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go b/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go index 2e6ac54340..48b723a7b3 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/instrument.go @@ -144,6 +144,12 @@ type Stream struct { // Use NewAllowKeysFilter from "go.opentelemetry.io/otel/attribute" to // provide an allow-list of attribute keys here. AttributeFilter attribute.Filter + // ExemplarReservoirProvider selects the + // [go.opentelemetry.io/otel/sdk/metric/exemplar.ReservoirProvider] based + // on the [Aggregation]. + // + // If unspecified, [DefaultExemplarReservoirProviderSelector] is used. + ExemplarReservoirProviderSelector ExemplarReservoirProviderSelector } // instID are the identifying properties of a instrument. diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go index f1f3ab6731..fde2193338 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/aggregate.go @@ -37,8 +37,8 @@ type Builder[N int64 | float64] struct { // create new exemplar reservoirs for a new seen attribute set. // // If this is not provided a default factory function that returns an - // DropReservoir reservoir will be used. - ReservoirFunc func() FilteredExemplarReservoir[N] + // dropReservoir reservoir will be used. + ReservoirFunc func(attribute.Set) FilteredExemplarReservoir[N] // AggregationLimit is the cardinality limit of measurement attributes. Any // measurement for new attributes once the limit has been reached will be // aggregated into a single aggregate for the "otel.metric.overflow" @@ -49,12 +49,12 @@ type Builder[N int64 | float64] struct { AggregationLimit int } -func (b Builder[N]) resFunc() func() FilteredExemplarReservoir[N] { +func (b Builder[N]) resFunc() func(attribute.Set) FilteredExemplarReservoir[N] { if b.ReservoirFunc != nil { return b.ReservoirFunc } - return DropReservoir + return dropReservoir } type fltrMeasure[N int64 | float64] func(ctx context.Context, value N, fltrAttr attribute.Set, droppedAttr []attribute.KeyValue) diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go index 4a3d4cc221..8396faaa4a 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/drop.go @@ -10,8 +10,10 @@ import ( "go.opentelemetry.io/otel/sdk/metric/exemplar" ) -// DropReservoir returns a [FilteredReservoir] that drops all measurements it is offered. -func DropReservoir[N int64 | float64]() FilteredExemplarReservoir[N] { return &dropRes[N]{} } +// dropReservoir returns a [FilteredReservoir] that drops all measurements it is offered. +func dropReservoir[N int64 | float64](attribute.Set) FilteredExemplarReservoir[N] { + return &dropRes[N]{} +} type dropRes[N int64 | float64] struct{} @@ -20,5 +22,6 @@ func (r *dropRes[N]) Offer(context.Context, N, []attribute.KeyValue) {} // Collect resets dest. No exemplars will ever be returned. func (r *dropRes[N]) Collect(dest *[]exemplar.Exemplar) { + clear(*dest) // Erase elements to let GC collect objects *dest = (*dest)[:0] } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go index dcb899d626..25d709948e 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exemplar.go @@ -17,6 +17,7 @@ var exemplarPool = sync.Pool{ func collectExemplars[N int64 | float64](out *[]metricdata.Exemplar[N], f func(*[]exemplar.Exemplar)) { dest := exemplarPool.Get().(*[]exemplar.Exemplar) defer func() { + clear(*dest) // Erase elements to let GC collect objects. *dest = (*dest)[:0] exemplarPool.Put(dest) }() diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go index a4de5674ba..b7aa721651 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/exponential_histogram.go @@ -283,7 +283,7 @@ func (b *expoBuckets) downscale(delta int32) { // newExponentialHistogram returns an Aggregator that summarizes a set of // measurements as an exponential histogram. Each histogram is scoped by attributes // and the aggregation cycle the measurements were made in. -func newExponentialHistogram[N int64 | float64](maxSize, maxScale int32, noMinMax, noSum bool, limit int, r func() FilteredExemplarReservoir[N]) *expoHistogram[N] { +func newExponentialHistogram[N int64 | float64](maxSize, maxScale int32, noMinMax, noSum bool, limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *expoHistogram[N] { return &expoHistogram[N]{ noSum: noSum, noMinMax: noMinMax, @@ -306,7 +306,7 @@ type expoHistogram[N int64 | float64] struct { maxSize int maxScale int32 - newRes func() FilteredExemplarReservoir[N] + newRes func(attribute.Set) FilteredExemplarReservoir[N] limit limiter[*expoHistogramDataPoint[N]] values map[attribute.Distinct]*expoHistogramDataPoint[N] valuesMu sync.Mutex @@ -327,7 +327,7 @@ func (e *expoHistogram[N]) measure(ctx context.Context, value N, fltrAttr attrib v, ok := e.values[attr.Equivalent()] if !ok { v = newExpoHistogramDataPoint[N](attr, e.maxSize, e.maxScale, e.noMinMax, e.noSum) - v.res = e.newRes() + v.res = e.newRes(attr) e.values[attr.Equivalent()] = v } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go index 35d020378b..d577ae2c19 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/histogram.go @@ -47,13 +47,13 @@ type histValues[N int64 | float64] struct { noSum bool bounds []float64 - newRes func() FilteredExemplarReservoir[N] + newRes func(attribute.Set) FilteredExemplarReservoir[N] limit limiter[*buckets[N]] values map[attribute.Distinct]*buckets[N] valuesMu sync.Mutex } -func newHistValues[N int64 | float64](bounds []float64, noSum bool, limit int, r func() FilteredExemplarReservoir[N]) *histValues[N] { +func newHistValues[N int64 | float64](bounds []float64, noSum bool, limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *histValues[N] { // The responsibility of keeping all buckets correctly associated with the // passed boundaries is ultimately this type's responsibility. Make a copy // here so we can always guarantee this. Or, in the case of failure, have @@ -93,7 +93,7 @@ func (s *histValues[N]) measure(ctx context.Context, value N, fltrAttr attribute // // buckets = (-∞, 0], (0, 5.0], (5.0, 10.0], (10.0, +∞) b = newBuckets[N](attr, len(s.bounds)+1) - b.res = s.newRes() + b.res = s.newRes(attr) // Ensure min and max are recorded values (not zero), for new buckets. b.min, b.max = value, value @@ -108,7 +108,7 @@ func (s *histValues[N]) measure(ctx context.Context, value N, fltrAttr attribute // newHistogram returns an Aggregator that summarizes a set of measurements as // an histogram. -func newHistogram[N int64 | float64](boundaries []float64, noMinMax, noSum bool, limit int, r func() FilteredExemplarReservoir[N]) *histogram[N] { +func newHistogram[N int64 | float64](boundaries []float64, noMinMax, noSum bool, limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *histogram[N] { return &histogram[N]{ histValues: newHistValues[N](boundaries, noSum, limit, r), noMinMax: noMinMax, diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go index a7b5fe572b..d3a93f085c 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/lastvalue.go @@ -19,7 +19,7 @@ type datapoint[N int64 | float64] struct { res FilteredExemplarReservoir[N] } -func newLastValue[N int64 | float64](limit int, r func() FilteredExemplarReservoir[N]) *lastValue[N] { +func newLastValue[N int64 | float64](limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *lastValue[N] { return &lastValue[N]{ newRes: r, limit: newLimiter[datapoint[N]](limit), @@ -32,7 +32,7 @@ func newLastValue[N int64 | float64](limit int, r func() FilteredExemplarReservo type lastValue[N int64 | float64] struct { sync.Mutex - newRes func() FilteredExemplarReservoir[N] + newRes func(attribute.Set) FilteredExemplarReservoir[N] limit limiter[datapoint[N]] values map[attribute.Distinct]datapoint[N] start time.Time @@ -45,7 +45,7 @@ func (s *lastValue[N]) measure(ctx context.Context, value N, fltrAttr attribute. attr := s.limit.Attributes(fltrAttr, s.values) d, ok := s.values[attr.Equivalent()] if !ok { - d.res = s.newRes() + d.res = s.newRes(attr) } d.attrs = attr @@ -114,7 +114,7 @@ func (s *lastValue[N]) copyDpts(dest *[]metricdata.DataPoint[N], t time.Time) in // newPrecomputedLastValue returns an aggregator that summarizes a set of // observations as the last one made. -func newPrecomputedLastValue[N int64 | float64](limit int, r func() FilteredExemplarReservoir[N]) *precomputedLastValue[N] { +func newPrecomputedLastValue[N int64 | float64](limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *precomputedLastValue[N] { return &precomputedLastValue[N]{lastValue: newLastValue[N](limit, r)} } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go index c3b591c37c..8e132ad618 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/internal/aggregate/sum.go @@ -21,12 +21,12 @@ type sumValue[N int64 | float64] struct { // valueMap is the storage for sums. type valueMap[N int64 | float64] struct { sync.Mutex - newRes func() FilteredExemplarReservoir[N] + newRes func(attribute.Set) FilteredExemplarReservoir[N] limit limiter[sumValue[N]] values map[attribute.Distinct]sumValue[N] } -func newValueMap[N int64 | float64](limit int, r func() FilteredExemplarReservoir[N]) *valueMap[N] { +func newValueMap[N int64 | float64](limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *valueMap[N] { return &valueMap[N]{ newRes: r, limit: newLimiter[sumValue[N]](limit), @@ -41,7 +41,7 @@ func (s *valueMap[N]) measure(ctx context.Context, value N, fltrAttr attribute.S attr := s.limit.Attributes(fltrAttr, s.values) v, ok := s.values[attr.Equivalent()] if !ok { - v.res = s.newRes() + v.res = s.newRes(attr) } v.attrs = attr @@ -54,7 +54,7 @@ func (s *valueMap[N]) measure(ctx context.Context, value N, fltrAttr attribute.S // newSum returns an aggregator that summarizes a set of measurements as their // arithmetic sum. Each sum is scoped by attributes and the aggregation cycle // the measurements were made in. -func newSum[N int64 | float64](monotonic bool, limit int, r func() FilteredExemplarReservoir[N]) *sum[N] { +func newSum[N int64 | float64](monotonic bool, limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *sum[N] { return &sum[N]{ valueMap: newValueMap[N](limit, r), monotonic: monotonic, @@ -143,7 +143,7 @@ func (s *sum[N]) cumulative(dest *metricdata.Aggregation) int { // newPrecomputedSum returns an aggregator that summarizes a set of // observations as their arithmetic sum. Each sum is scoped by attributes and // the aggregation cycle the measurements were made in. -func newPrecomputedSum[N int64 | float64](monotonic bool, limit int, r func() FilteredExemplarReservoir[N]) *precomputedSum[N] { +func newPrecomputedSum[N int64 | float64](monotonic bool, limit int, r func(attribute.Set) FilteredExemplarReservoir[N]) *precomputedSum[N] { return &precomputedSum[N]{ valueMap: newValueMap[N](limit, r), monotonic: monotonic, diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go b/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go index e0fd86ca78..c495985bc2 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/manual_reader.go @@ -113,18 +113,17 @@ func (mr *ManualReader) Collect(ctx context.Context, rm *metricdata.ResourceMetr if err != nil { return err } - var errs []error for _, producer := range mr.externalProducers.Load().([]Producer) { - externalMetrics, err := producer.Produce(ctx) - if err != nil { - errs = append(errs, err) + externalMetrics, e := producer.Produce(ctx) + if e != nil { + err = errors.Join(err, e) } rm.ScopeMetrics = append(rm.ScopeMetrics, externalMetrics...) } global.Debug("ManualReader collection", "Data", rm) - return unifyErrors(errs) + return err } // MarshalLog returns logging data about the ManualReader. diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go b/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go index abff4650e1..823cdf2c62 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/meter.go @@ -150,6 +150,11 @@ func (m *meter) int64ObservableInstrument(id Instrument, callbacks []metric.Int6 continue } inst.appendMeasures(in) + + // Add the measures to the pipeline. It is required to maintain + // measures per pipeline to avoid calling the measure that + // is not part of the pipeline. + insert.pipeline.addInt64Measure(inst.observableID, in) for _, cback := range callbacks { inst := int64Observer{measures: in} fn := cback @@ -309,6 +314,11 @@ func (m *meter) float64ObservableInstrument(id Instrument, callbacks []metric.Fl continue } inst.appendMeasures(in) + + // Add the measures to the pipeline. It is required to maintain + // measures per pipeline to avoid calling the measure that + // is not part of the pipeline. + insert.pipeline.addFloat64Measure(inst.observableID, in) for _, cback := range callbacks { inst := float64Observer{measures: in} fn := cback @@ -441,68 +451,75 @@ func (m *meter) RegisterCallback(f metric.Callback, insts ...metric.Observable) return noopRegister{}, nil } - reg := newObserver() - var errs multierror + var err error + validInstruments := make([]metric.Observable, 0, len(insts)) for _, inst := range insts { - // Unwrap any global. - if u, ok := inst.(interface { - Unwrap() metric.Observable - }); ok { - inst = u.Unwrap() - } - switch o := inst.(type) { case int64Observable: - if err := o.registerable(m); err != nil { - if !errors.Is(err, errEmptyAgg) { - errs.append(err) + if e := o.registerable(m); e != nil { + if !errors.Is(e, errEmptyAgg) { + err = errors.Join(err, e) } continue } - reg.registerInt64(o.observableID) + + validInstruments = append(validInstruments, inst) case float64Observable: - if err := o.registerable(m); err != nil { - if !errors.Is(err, errEmptyAgg) { - errs.append(err) + if e := o.registerable(m); e != nil { + if !errors.Is(e, errEmptyAgg) { + err = errors.Join(err, e) } continue } - reg.registerFloat64(o.observableID) + + validInstruments = append(validInstruments, inst) default: // Instrument external to the SDK. return nil, fmt.Errorf("invalid observable: from different implementation") } } - err := errs.errorOrNil() - if reg.len() == 0 { + if len(validInstruments) == 0 { // All insts use drop aggregation or are invalid. return noopRegister{}, err } - // Some or all instruments were valid. - cback := func(ctx context.Context) error { return f(ctx, reg) } - return m.pipes.registerMultiCallback(cback), err + unregs := make([]func(), len(m.pipes)) + for ix, pipe := range m.pipes { + reg := newObserver(pipe) + for _, inst := range validInstruments { + switch o := inst.(type) { + case int64Observable: + reg.registerInt64(o.observableID) + case float64Observable: + reg.registerFloat64(o.observableID) + } + } + + // Some or all instruments were valid. + cBack := func(ctx context.Context) error { return f(ctx, reg) } + unregs[ix] = pipe.addMultiCallback(cBack) + } + + return unregisterFuncs{f: unregs}, err } type observer struct { embedded.Observer + pipe *pipeline float64 map[observableID[float64]]struct{} int64 map[observableID[int64]]struct{} } -func newObserver() observer { +func newObserver(p *pipeline) observer { return observer{ + pipe: p, float64: make(map[observableID[float64]]struct{}), int64: make(map[observableID[int64]]struct{}), } } -func (r observer) len() int { - return len(r.float64) + len(r.int64) -} - func (r observer) registerFloat64(id observableID[float64]) { r.float64[id] = struct{}{} } @@ -521,16 +538,6 @@ func (r observer) ObserveFloat64(o metric.Float64Observable, v float64, opts ... switch conv := o.(type) { case float64Observable: oImpl = conv - case interface { - Unwrap() metric.Observable - }: - // Unwrap any global. - async := conv.Unwrap() - var ok bool - if oImpl, ok = async.(float64Observable); !ok { - global.Error(errUnknownObserver, "failed to record asynchronous") - return - } default: global.Error(errUnknownObserver, "failed to record") return @@ -548,7 +555,12 @@ func (r observer) ObserveFloat64(o metric.Float64Observable, v float64, opts ... return } c := metric.NewObserveConfig(opts) - oImpl.observe(v, c.Attributes()) + // Access to r.pipe.float64Measure is already guarded by a lock in pipeline.produce. + // TODO (#5946): Refactor pipeline and observable measures. + measures := r.pipe.float64Measures[oImpl.observableID] + for _, m := range measures { + m(context.Background(), v, c.Attributes()) + } } func (r observer) ObserveInt64(o metric.Int64Observable, v int64, opts ...metric.ObserveOption) { @@ -556,16 +568,6 @@ func (r observer) ObserveInt64(o metric.Int64Observable, v int64, opts ...metric switch conv := o.(type) { case int64Observable: oImpl = conv - case interface { - Unwrap() metric.Observable - }: - // Unwrap any global. - async := conv.Unwrap() - var ok bool - if oImpl, ok = async.(int64Observable); !ok { - global.Error(errUnknownObserver, "failed to record asynchronous") - return - } default: global.Error(errUnknownObserver, "failed to record") return @@ -583,7 +585,12 @@ func (r observer) ObserveInt64(o metric.Int64Observable, v int64, opts ...metric return } c := metric.NewObserveConfig(opts) - oImpl.observe(v, c.Attributes()) + // Access to r.pipe.int64Measures is already guarded b a lock in pipeline.produce. + // TODO (#5946): Refactor pipeline and observable measures. + measures := r.pipe.int64Measures[oImpl.observableID] + for _, m := range measures { + m(context.Background(), v, c.Attributes()) + } } type noopRegister struct{ embedded.Registration } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go b/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go index 67ee1b11a2..dcd2182d9a 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/periodic_reader.go @@ -251,18 +251,17 @@ func (r *PeriodicReader) collect(ctx context.Context, p interface{}, rm *metricd if err != nil { return err } - var errs []error for _, producer := range r.externalProducers.Load().([]Producer) { - externalMetrics, err := producer.Produce(ctx) - if err != nil { - errs = append(errs, err) + externalMetrics, e := producer.Produce(ctx) + if e != nil { + err = errors.Join(err, e) } rm.ScopeMetrics = append(rm.ScopeMetrics, externalMetrics...) } global.Debug("PeriodicReader collection", "Data", rm) - return unifyErrors(errs) + return err } // export exports metric data m using r's exporter. diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go b/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go index 823bf2fe3d..775e245261 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/pipeline.go @@ -8,14 +8,13 @@ import ( "context" "errors" "fmt" - "strings" "sync" "sync/atomic" "go.opentelemetry.io/otel/internal/global" - "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/metric/embedded" "go.opentelemetry.io/otel/sdk/instrumentation" + "go.opentelemetry.io/otel/sdk/metric/exemplar" "go.opentelemetry.io/otel/sdk/metric/internal" "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" "go.opentelemetry.io/otel/sdk/metric/internal/x" @@ -38,14 +37,17 @@ type instrumentSync struct { compAgg aggregate.ComputeAggregation } -func newPipeline(res *resource.Resource, reader Reader, views []View) *pipeline { +func newPipeline(res *resource.Resource, reader Reader, views []View, exemplarFilter exemplar.Filter) *pipeline { if res == nil { res = resource.Empty() } return &pipeline{ - resource: res, - reader: reader, - views: views, + resource: res, + reader: reader, + views: views, + int64Measures: map[observableID[int64]][]aggregate.Measure[int64]{}, + float64Measures: map[observableID[float64]][]aggregate.Measure[float64]{}, + exemplarFilter: exemplarFilter, // aggregations is lazy allocated when needed. } } @@ -63,9 +65,26 @@ type pipeline struct { views []View sync.Mutex - aggregations map[instrumentation.Scope][]instrumentSync - callbacks []func(context.Context) error - multiCallbacks list.List + int64Measures map[observableID[int64]][]aggregate.Measure[int64] + float64Measures map[observableID[float64]][]aggregate.Measure[float64] + aggregations map[instrumentation.Scope][]instrumentSync + callbacks []func(context.Context) error + multiCallbacks list.List + exemplarFilter exemplar.Filter +} + +// addInt64Measure adds a new int64 measure to the pipeline for each observer. +func (p *pipeline) addInt64Measure(id observableID[int64], m []aggregate.Measure[int64]) { + p.Lock() + defer p.Unlock() + p.int64Measures[id] = m +} + +// addFloat64Measure adds a new float64 measure to the pipeline for each observer. +func (p *pipeline) addFloat64Measure(id observableID[float64], m []aggregate.Measure[float64]) { + p.Lock() + defer p.Unlock() + p.float64Measures[id] = m } // addSync adds the instrumentSync to pipeline p with scope. This method is not @@ -105,14 +124,15 @@ func (p *pipeline) produce(ctx context.Context, rm *metricdata.ResourceMetrics) p.Lock() defer p.Unlock() - var errs multierror + var err error for _, c := range p.callbacks { // TODO make the callbacks parallel. ( #3034 ) - if err := c(ctx); err != nil { - errs.append(err) + if e := c(ctx); e != nil { + err = errors.Join(err, e) } if err := ctx.Err(); err != nil { rm.Resource = nil + clear(rm.ScopeMetrics) // Erase elements to let GC collect objects. rm.ScopeMetrics = rm.ScopeMetrics[:0] return err } @@ -120,12 +140,13 @@ func (p *pipeline) produce(ctx context.Context, rm *metricdata.ResourceMetrics) for e := p.multiCallbacks.Front(); e != nil; e = e.Next() { // TODO make the callbacks parallel. ( #3034 ) f := e.Value.(multiCallback) - if err := f(ctx); err != nil { - errs.append(err) + if e := f(ctx); e != nil { + err = errors.Join(err, e) } if err := ctx.Err(); err != nil { // This means the context expired before we finished running callbacks. rm.Resource = nil + clear(rm.ScopeMetrics) // Erase elements to let GC collect objects. rm.ScopeMetrics = rm.ScopeMetrics[:0] return err } @@ -157,7 +178,7 @@ func (p *pipeline) produce(ctx context.Context, rm *metricdata.ResourceMetrics) rm.ScopeMetrics = rm.ScopeMetrics[:i] - return errs.errorOrNil() + return err } // inserter facilitates inserting of new instruments from a single scope into a @@ -219,7 +240,7 @@ func (i *inserter[N]) Instrument(inst Instrument, readerAggregation Aggregation) measures []aggregate.Measure[N] ) - errs := &multierror{wrapped: errCreatingAggregators} + var err error seen := make(map[uint64]struct{}) for _, v := range i.pipeline.views { stream, match := v(inst) @@ -227,9 +248,9 @@ func (i *inserter[N]) Instrument(inst Instrument, readerAggregation Aggregation) continue } matched = true - in, id, err := i.cachedAggregator(inst.Scope, inst.Kind, stream, readerAggregation) - if err != nil { - errs.append(err) + in, id, e := i.cachedAggregator(inst.Scope, inst.Kind, stream, readerAggregation) + if e != nil { + err = errors.Join(err, e) } if in == nil { // Drop aggregation. continue @@ -242,8 +263,12 @@ func (i *inserter[N]) Instrument(inst Instrument, readerAggregation Aggregation) measures = append(measures, in) } + if err != nil { + err = errors.Join(errCreatingAggregators, err) + } + if matched { - return measures, errs.errorOrNil() + return measures, err } // Apply implicit default view if no explicit matched. @@ -252,15 +277,18 @@ func (i *inserter[N]) Instrument(inst Instrument, readerAggregation Aggregation) Description: inst.Description, Unit: inst.Unit, } - in, _, err := i.cachedAggregator(inst.Scope, inst.Kind, stream, readerAggregation) - if err != nil { - errs.append(err) + in, _, e := i.cachedAggregator(inst.Scope, inst.Kind, stream, readerAggregation) + if e != nil { + if err == nil { + err = errCreatingAggregators + } + err = errors.Join(err, e) } if in != nil { // Ensured to have not seen given matched was false. measures = append(measures, in) } - return measures, errs.errorOrNil() + return measures, err } // addCallback registers a single instrument callback to be run when @@ -329,6 +357,9 @@ func (i *inserter[N]) cachedAggregator(scope instrumentation.Scope, kind Instrum // The view explicitly requested the default aggregation. stream.Aggregation = DefaultAggregationSelector(kind) } + if stream.ExemplarReservoirProviderSelector == nil { + stream.ExemplarReservoirProviderSelector = DefaultExemplarReservoirProviderSelector + } if err := isAggregatorCompatible(kind, stream.Aggregation); err != nil { return nil, 0, fmt.Errorf( @@ -349,7 +380,7 @@ func (i *inserter[N]) cachedAggregator(scope instrumentation.Scope, kind Instrum cv := i.aggregators.Lookup(normID, func() aggVal[N] { b := aggregate.Builder[N]{ Temporality: i.pipeline.reader.temporality(kind), - ReservoirFunc: reservoirFunc[N](stream.Aggregation), + ReservoirFunc: reservoirFunc[N](stream.ExemplarReservoirProviderSelector(stream.Aggregation), i.pipeline.exemplarFilter), } b.Filter = stream.AttributeFilter // A value less than or equal to zero will disable the aggregation @@ -552,24 +583,16 @@ func isAggregatorCompatible(kind InstrumentKind, agg Aggregation) error { // measurement. type pipelines []*pipeline -func newPipelines(res *resource.Resource, readers []Reader, views []View) pipelines { +func newPipelines(res *resource.Resource, readers []Reader, views []View, exemplarFilter exemplar.Filter) pipelines { pipes := make([]*pipeline, 0, len(readers)) for _, r := range readers { - p := newPipeline(res, r, views) + p := newPipeline(res, r, views, exemplarFilter) r.register(p) pipes = append(pipes, p) } return pipes } -func (p pipelines) registerMultiCallback(c multiCallback) metric.Registration { - unregs := make([]func(), len(p)) - for i, pipe := range p { - unregs[i] = pipe.addMultiCallback(c) - } - return unregisterFuncs{f: unregs} -} - type unregisterFuncs struct { embedded.Registration f []func() @@ -602,15 +625,15 @@ func newResolver[N int64 | float64](p pipelines, vc *cache[string, instID]) reso func (r resolver[N]) Aggregators(id Instrument) ([]aggregate.Measure[N], error) { var measures []aggregate.Measure[N] - errs := &multierror{} + var err error for _, i := range r.inserters { - in, err := i.Instrument(id, i.readerDefaultAggregation(id.Kind)) - if err != nil { - errs.append(err) + in, e := i.Instrument(id, i.readerDefaultAggregation(id.Kind)) + if e != nil { + err = errors.Join(err, e) } measures = append(measures, in...) } - return measures, errs.errorOrNil() + return measures, err } // HistogramAggregators returns the histogram Aggregators that must be updated by the instrument @@ -619,37 +642,18 @@ func (r resolver[N]) Aggregators(id Instrument) ([]aggregate.Measure[N], error) func (r resolver[N]) HistogramAggregators(id Instrument, boundaries []float64) ([]aggregate.Measure[N], error) { var measures []aggregate.Measure[N] - errs := &multierror{} + var err error for _, i := range r.inserters { agg := i.readerDefaultAggregation(id.Kind) if histAgg, ok := agg.(AggregationExplicitBucketHistogram); ok && len(boundaries) > 0 { histAgg.Boundaries = boundaries agg = histAgg } - in, err := i.Instrument(id, agg) - if err != nil { - errs.append(err) + in, e := i.Instrument(id, agg) + if e != nil { + err = errors.Join(err, e) } measures = append(measures, in...) } - return measures, errs.errorOrNil() -} - -type multierror struct { - wrapped error - errors []string -} - -func (m *multierror) errorOrNil() error { - if len(m.errors) == 0 { - return nil - } - if m.wrapped == nil { - return errors.New(strings.Join(m.errors, "; ")) - } - return fmt.Errorf("%w: %s", m.wrapped, strings.Join(m.errors, "; ")) -} - -func (m *multierror) append(err error) { - m.errors = append(m.errors, err.Error()) + return measures, err } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go b/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go index a82af538e6..2fca89e5a8 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/provider.go @@ -42,7 +42,7 @@ func NewMeterProvider(options ...Option) *MeterProvider { flush, sdown := conf.readerSignals() mp := &MeterProvider{ - pipes: newPipelines(conf.res, conf.readers, conf.views), + pipes: newPipelines(conf.res, conf.readers, conf.views, conf.exemplarFilter), forceFlush: flush, shutdown: sdown, } @@ -76,15 +76,17 @@ func (mp *MeterProvider) Meter(name string, options ...metric.MeterOption) metri c := metric.NewMeterConfig(options...) s := instrumentation.Scope{ - Name: name, - Version: c.InstrumentationVersion(), - SchemaURL: c.SchemaURL(), + Name: name, + Version: c.InstrumentationVersion(), + SchemaURL: c.SchemaURL(), + Attributes: c.InstrumentationAttributes(), } global.Info("Meter created", "Name", s.Name, "Version", s.Version, "SchemaURL", s.SchemaURL, + "Attributes", s.Attributes, ) return mp.meters.Lookup(s, func() *meter { diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/version.go b/vendor/go.opentelemetry.io/otel/sdk/metric/version.go index fa43f8469c..6347060bf4 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/version.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/version.go @@ -5,5 +5,5 @@ package metric // import "go.opentelemetry.io/otel/sdk/metric" // version is the current release version of the metric SDK in use. func version() string { - return "1.31.0" + return "1.32.0" } diff --git a/vendor/go.opentelemetry.io/otel/sdk/metric/view.go b/vendor/go.opentelemetry.io/otel/sdk/metric/view.go index cd08c67324..630890f426 100644 --- a/vendor/go.opentelemetry.io/otel/sdk/metric/view.go +++ b/vendor/go.opentelemetry.io/otel/sdk/metric/view.go @@ -96,11 +96,12 @@ func NewView(criteria Instrument, mask Stream) View { return func(i Instrument) (Stream, bool) { if matchFunc(i) { return Stream{ - Name: nonZero(mask.Name, i.Name), - Description: nonZero(mask.Description, i.Description), - Unit: nonZero(mask.Unit, i.Unit), - Aggregation: agg, - AttributeFilter: mask.AttributeFilter, + Name: nonZero(mask.Name, i.Name), + Description: nonZero(mask.Description, i.Description), + Unit: nonZero(mask.Unit, i.Unit), + Aggregation: agg, + AttributeFilter: mask.AttributeFilter, + ExemplarReservoirProviderSelector: mask.ExemplarReservoirProviderSelector, }, true } return Stream{}, false diff --git a/vendor/modules.txt b/vendor/modules.txt index 4846cc9ede..046ea214d0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -49,7 +49,7 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v6 # github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry v1.2.0 ## explicit; go 1.18 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry -# github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.2.0 +# github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 v6.3.0 ## explicit; go 1.18 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v6 # github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.4.0 @@ -436,7 +436,7 @@ github.com/prometheus/client_golang/prometheus/testutil/promlint/validations # github.com/prometheus/client_model v0.6.1 ## explicit; go 1.19 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.60.0 +# github.com/prometheus/common v0.60.1 ## explicit; go 1.21 github.com/prometheus/common/expfmt github.com/prometheus/common/model @@ -521,7 +521,7 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/envconfig go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/otlpconfig go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc/internal/retry -# go.opentelemetry.io/otel/exporters/prometheus v0.53.0 +# go.opentelemetry.io/otel/exporters/prometheus v0.54.0 ## explicit; go 1.22 go.opentelemetry.io/otel/exporters/prometheus # go.opentelemetry.io/otel/metric v1.32.0 @@ -537,7 +537,7 @@ go.opentelemetry.io/otel/sdk/internal/env go.opentelemetry.io/otel/sdk/internal/x go.opentelemetry.io/otel/sdk/resource go.opentelemetry.io/otel/sdk/trace -# go.opentelemetry.io/otel/sdk/metric v1.31.0 +# go.opentelemetry.io/otel/sdk/metric v1.32.0 ## explicit; go 1.22 go.opentelemetry.io/otel/sdk/metric go.opentelemetry.io/otel/sdk/metric/exemplar @@ -955,7 +955,7 @@ k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/netutil k8s.io/apimachinery/third_party/forked/golang/reflect -# k8s.io/apiserver v0.31.2 => k8s.io/apiserver v0.31.2 +# k8s.io/apiserver v0.31.3 => k8s.io/apiserver v0.31.2 ## explicit; go 1.22.0 k8s.io/apiserver/pkg/admission k8s.io/apiserver/pkg/admission/configuration @@ -1448,7 +1448,7 @@ k8s.io/client-go/util/keyutil k8s.io/client-go/util/retry k8s.io/client-go/util/watchlist k8s.io/client-go/util/workqueue -# k8s.io/cloud-provider v0.31.2 => k8s.io/cloud-provider v0.31.2 +# k8s.io/cloud-provider v0.31.3 => k8s.io/cloud-provider v0.31.2 ## explicit; go 1.22.0 k8s.io/cloud-provider k8s.io/cloud-provider/api @@ -1468,7 +1468,7 @@ k8s.io/cloud-provider/service/helpers k8s.io/cloud-provider/volume k8s.io/cloud-provider/volume/errors k8s.io/cloud-provider/volume/helpers -# k8s.io/component-base v0.31.2 => k8s.io/component-base v0.31.2 +# k8s.io/component-base v0.31.3 => k8s.io/component-base v0.31.2 ## explicit; go 1.22.0 k8s.io/component-base/cli/flag k8s.io/component-base/config @@ -1491,13 +1491,13 @@ k8s.io/component-base/metrics/testutil k8s.io/component-base/tracing k8s.io/component-base/tracing/api/v1 k8s.io/component-base/version -# k8s.io/component-helpers v0.31.2 => k8s.io/component-helpers v0.31.2 +# k8s.io/component-helpers v0.31.3 => k8s.io/component-helpers v0.31.2 ## explicit; go 1.22.0 k8s.io/component-helpers/node/util k8s.io/component-helpers/node/util/sysctl k8s.io/component-helpers/scheduling/corev1 k8s.io/component-helpers/scheduling/corev1/nodeaffinity -# k8s.io/controller-manager v0.31.2 => k8s.io/controller-manager v0.31.2 +# k8s.io/controller-manager v0.31.3 => k8s.io/controller-manager v0.31.2 ## explicit; go 1.22.0 k8s.io/controller-manager/config k8s.io/controller-manager/config/v1 @@ -1551,7 +1551,7 @@ k8s.io/kube-openapi/pkg/validation/strfmt/bson ## explicit; go 1.22.0 k8s.io/kubectl/pkg/scale k8s.io/kubectl/pkg/util/podutils -# k8s.io/kubelet v0.31.2 => k8s.io/kubelet v0.31.2 +# k8s.io/kubelet v0.31.3 => k8s.io/kubelet v0.31.2 ## explicit; go 1.22.0 k8s.io/kubelet/pkg/apis # k8s.io/kubernetes v1.31.3 @@ -1652,7 +1652,7 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/metrics sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/common/metrics sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client -# sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241111034044-6ebb6c3c3260 +# sigs.k8s.io/cloud-provider-azure v1.29.1-0.20241129020458-82e716a56f86 ## explicit; go 1.23.1 sigs.k8s.io/cloud-provider-azure/pkg/azureclients sigs.k8s.io/cloud-provider-azure/pkg/azureclients/armauth @@ -1669,8 +1669,6 @@ sigs.k8s.io/cloud-provider-azure/pkg/azureclients/privatednszonegroupclient sigs.k8s.io/cloud-provider-azure/pkg/azureclients/privateendpointclient sigs.k8s.io/cloud-provider-azure/pkg/azureclients/publicipclient sigs.k8s.io/cloud-provider-azure/pkg/azureclients/publicipclient/mockpublicipclient -sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient -sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient sigs.k8s.io/cloud-provider-azure/pkg/azureclients/storageaccountclient sigs.k8s.io/cloud-provider-azure/pkg/azureclients/subnetclient sigs.k8s.io/cloud-provider-azure/pkg/azureclients/subnetclient/mocksubnetclient @@ -1690,6 +1688,7 @@ sigs.k8s.io/cloud-provider-azure/pkg/provider sigs.k8s.io/cloud-provider-azure/pkg/provider/config sigs.k8s.io/cloud-provider-azure/pkg/provider/loadbalancer sigs.k8s.io/cloud-provider-azure/pkg/provider/privatelinkservice +sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable sigs.k8s.io/cloud-provider-azure/pkg/provider/securitygroup sigs.k8s.io/cloud-provider-azure/pkg/provider/subnet sigs.k8s.io/cloud-provider-azure/pkg/provider/virtualmachine @@ -1707,7 +1706,7 @@ sigs.k8s.io/cloud-provider-azure/pkg/util/string sigs.k8s.io/cloud-provider-azure/pkg/util/taints sigs.k8s.io/cloud-provider-azure/pkg/util/vm sigs.k8s.io/cloud-provider-azure/pkg/version -# sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.15 +# sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.1.21 ## explicit; go 1.23.1 sigs.k8s.io/cloud-provider-azure/pkg/azclient sigs.k8s.io/cloud-provider-azure/pkg/azclient/accountclient diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/azure_routetableclient.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/azure_routetableclient.go deleted file mode 100644 index 1eea86106d..0000000000 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/azure_routetableclient.go +++ /dev/null @@ -1,219 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package routetableclient - -import ( - "context" - "net/http" - "strings" - "time" - - "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - - "k8s.io/client-go/util/flowcontrol" - "k8s.io/klog/v2" - - azclients "sigs.k8s.io/cloud-provider-azure/pkg/azureclients" - "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/armclient" - "sigs.k8s.io/cloud-provider-azure/pkg/metrics" - "sigs.k8s.io/cloud-provider-azure/pkg/retry" -) - -var _ Interface = &Client{} - -const routeTablesResourceType = "Microsoft.Network/routeTables" - -// Client implements RouteTable client Interface. -type Client struct { - armClient armclient.Interface - subscriptionID string - cloudName string - - // Rate limiting configures. - rateLimiterReader flowcontrol.RateLimiter - rateLimiterWriter flowcontrol.RateLimiter - - // ARM throttling configures. - RetryAfterReader time.Time - RetryAfterWriter time.Time -} - -// New creates a new RouteTable client with ratelimiting. -func New(config *azclients.ClientConfig) *Client { - baseURI := config.ResourceManagerEndpoint - authorizer := config.Authorizer - apiVersion := APIVersion - if strings.EqualFold(config.CloudName, AzureStackCloudName) && !config.DisableAzureStackCloud { - apiVersion = AzureStackCloudAPIVersion - } - armClient := armclient.New(authorizer, *config, baseURI, apiVersion) - rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig) - - if azclients.RateLimitEnabled(config.RateLimitConfig) { - klog.V(2).Infof("Azure RouteTablesClient (read ops) using rate limit config: QPS=%g, bucket=%d", - config.RateLimitConfig.CloudProviderRateLimitQPS, - config.RateLimitConfig.CloudProviderRateLimitBucket) - klog.V(2).Infof("Azure RouteTablesClient (write ops) using rate limit config: QPS=%g, bucket=%d", - config.RateLimitConfig.CloudProviderRateLimitQPSWrite, - config.RateLimitConfig.CloudProviderRateLimitBucketWrite) - } - - client := &Client{ - armClient: armClient, - rateLimiterReader: rateLimiterReader, - rateLimiterWriter: rateLimiterWriter, - subscriptionID: config.SubscriptionID, - cloudName: config.CloudName, - } - - return client -} - -// Get gets a RouteTable. -func (c *Client) Get(ctx context.Context, resourceGroupName string, routeTableName string, expand string) (network.RouteTable, *retry.Error) { - mc := metrics.NewMetricContext("route_tables", "get", resourceGroupName, c.subscriptionID, "") - - // Report errors if the client is rate limited. - if !c.rateLimiterReader.TryAccept() { - mc.RateLimitedCount() - return network.RouteTable{}, retry.GetRateLimitError(false, "RouteTableGet") - } - - // Report errors if the client is throttled. - if c.RetryAfterReader.After(time.Now()) { - mc.ThrottledCount() - rerr := retry.GetThrottlingError("RouteTableGet", "client throttled", c.RetryAfterReader) - return network.RouteTable{}, rerr - } - - result, rerr := c.getRouteTable(ctx, resourceGroupName, routeTableName, expand) - mc.Observe(rerr) - if rerr != nil { - if rerr.IsThrottled() { - // Update RetryAfterReader so that no more requests would be sent until RetryAfter expires. - c.RetryAfterReader = rerr.RetryAfter - } - - return result, rerr - } - - return result, nil -} - -// getRouteTable gets a RouteTable. -func (c *Client) getRouteTable(ctx context.Context, resourceGroupName string, routeTableName string, expand string) (network.RouteTable, *retry.Error) { - resourceID := armclient.GetResourceID( - c.subscriptionID, - resourceGroupName, - routeTablesResourceType, - routeTableName, - ) - result := network.RouteTable{} - - response, rerr := c.armClient.GetResourceWithExpandQuery(ctx, resourceID, expand) - defer c.armClient.CloseResponse(ctx, response) - if rerr != nil { - klog.V(5).Infof("Received error in %s: resourceID: %s, error: %s", "routetable.get.request", resourceID, rerr.Error()) - return result, rerr - } - - err := autorest.Respond( - response, - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result)) - if err != nil { - klog.V(5).Infof("Received error in %s: resourceID: %s, error: %s", "routetable.get.respond", resourceID, err) - return result, retry.GetError(response, err) - } - - result.Response = autorest.Response{Response: response} - return result, nil -} - -// CreateOrUpdate creates or updates a RouteTable. -func (c *Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, routeTableName string, parameters network.RouteTable, etag string) *retry.Error { - mc := metrics.NewMetricContext("route_tables", "create_or_update", resourceGroupName, c.subscriptionID, "") - - // Report errors if the client is rate limited. - if !c.rateLimiterWriter.TryAccept() { - mc.RateLimitedCount() - return retry.GetRateLimitError(true, "RouteTableCreateOrUpdate") - } - - // Report errors if the client is throttled. - if c.RetryAfterWriter.After(time.Now()) { - mc.ThrottledCount() - rerr := retry.GetThrottlingError("RouteTableCreateOrUpdate", "client throttled", c.RetryAfterWriter) - return rerr - } - - rerr := c.createOrUpdateRouteTable(ctx, resourceGroupName, routeTableName, parameters, etag) - mc.Observe(rerr) - if rerr != nil { - if rerr.IsThrottled() { - // Update RetryAfterReader so that no more requests would be sent until RetryAfter expires. - c.RetryAfterWriter = rerr.RetryAfter - } - - return rerr - } - - return nil -} - -// createOrUpdateRouteTable creates or updates a RouteTable. -func (c *Client) createOrUpdateRouteTable(ctx context.Context, resourceGroupName string, routeTableName string, parameters network.RouteTable, etag string) *retry.Error { - resourceID := armclient.GetResourceID( - c.subscriptionID, - resourceGroupName, - routeTablesResourceType, - routeTableName, - ) - decorators := []autorest.PrepareDecorator{} - if etag != "" { - decorators = append(decorators, autorest.WithHeader("If-Match", autorest.String(etag))) - } - - response, rerr := c.armClient.PutResource(ctx, resourceID, parameters, decorators...) - defer c.armClient.CloseResponse(ctx, response) - if rerr != nil { - klog.V(5).Infof("Received error in %s: resourceID: %s, error: %s", "routetable.put.request", resourceID, rerr.Error()) - return rerr - } - - if response != nil && response.StatusCode != http.StatusNoContent { - _, rerr = c.createOrUpdateResponder(response) - if rerr != nil { - klog.V(5).Infof("Received error in %s: resourceID: %s, error: %s", "routetable.put.respond", resourceID, rerr.Error()) - return rerr - } - } - - return nil -} - -func (c *Client) createOrUpdateResponder(resp *http.Response) (*network.RouteTable, *retry.Error) { - result := &network.RouteTable{} - err := autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result)) - result.Response = autorest.Response{Response: resp} - return result, retry.GetError(resp, err) -} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/doc.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/doc.go deleted file mode 100644 index 49d8ed616f..0000000000 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package routetableclient implements the client for RouteTable. -package routetableclient // import "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient" diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/interface.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/interface.go deleted file mode 100644 index 1ef8cfc08a..0000000000 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/interface.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package routetableclient - -import ( - "context" - - "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network" - - "sigs.k8s.io/cloud-provider-azure/pkg/retry" -) - -const ( - // APIVersion is the API version for network. - APIVersion = "2022-07-01" - // AzureStackCloudAPIVersion is the API version for Azure Stack - AzureStackCloudAPIVersion = "2018-11-01" - // AzureStackCloudName is the cloud name of Azure Stack - AzureStackCloudName = "AZURESTACKCLOUD" -) - -// Interface is the client interface for RouteTable. -// Don't forget to run "hack/update-mock-clients.sh" command to generate the mock client. -type Interface interface { - // Get gets a RouteTable. - Get(ctx context.Context, resourceGroupName string, routeTableName string, expand string) (result network.RouteTable, rerr *retry.Error) - - // CreateOrUpdate creates or updates a RouteTable. - CreateOrUpdate(ctx context.Context, resourceGroupName string, routeTableName string, parameters network.RouteTable, etag string) *retry.Error -} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient/doc.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient/doc.go deleted file mode 100644 index c2aa4cc399..0000000000 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient/doc.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package mockroutetableclient implements the mock client for RouteTable. -package mockroutetableclient // import "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient" diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient/interface.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient/interface.go deleted file mode 100644 index 200ff014c5..0000000000 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient/interface.go +++ /dev/null @@ -1,88 +0,0 @@ -// /* -// Copyright The Kubernetes Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// */ -// - -// Code generated by MockGen. DO NOT EDIT. -// Source: pkg/azureclients/routetableclient/interface.go -// -// Generated by this command: -// -// mockgen -copyright_file=/home/runner/work/cloud-provider-azure/cloud-provider-azure/hack/boilerplate/boilerplate.generatego.txt -source=pkg/azureclients/routetableclient/interface.go -package=mockroutetableclient Interface -// - -// Package mockroutetableclient is a generated GoMock package. -package mockroutetableclient - -import ( - context "context" - reflect "reflect" - - network "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network" - gomock "go.uber.org/mock/gomock" - retry "sigs.k8s.io/cloud-provider-azure/pkg/retry" -) - -// MockInterface is a mock of Interface interface. -type MockInterface struct { - ctrl *gomock.Controller - recorder *MockInterfaceMockRecorder -} - -// MockInterfaceMockRecorder is the mock recorder for MockInterface. -type MockInterfaceMockRecorder struct { - mock *MockInterface -} - -// NewMockInterface creates a new mock instance. -func NewMockInterface(ctrl *gomock.Controller) *MockInterface { - mock := &MockInterface{ctrl: ctrl} - mock.recorder = &MockInterfaceMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockInterface) EXPECT() *MockInterfaceMockRecorder { - return m.recorder -} - -// CreateOrUpdate mocks base method. -func (m *MockInterface) CreateOrUpdate(ctx context.Context, resourceGroupName, routeTableName string, parameters network.RouteTable, etag string) *retry.Error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateOrUpdate", ctx, resourceGroupName, routeTableName, parameters, etag) - ret0, _ := ret[0].(*retry.Error) - return ret0 -} - -// CreateOrUpdate indicates an expected call of CreateOrUpdate. -func (mr *MockInterfaceMockRecorder) CreateOrUpdate(ctx, resourceGroupName, routeTableName, parameters, etag any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdate", reflect.TypeOf((*MockInterface)(nil).CreateOrUpdate), ctx, resourceGroupName, routeTableName, parameters, etag) -} - -// Get mocks base method. -func (m *MockInterface) Get(ctx context.Context, resourceGroupName, routeTableName, expand string) (network.RouteTable, *retry.Error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, resourceGroupName, routeTableName, expand) - ret0, _ := ret[0].(network.RouteTable) - ret1, _ := ret[1].(*retry.Error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockInterfaceMockRecorder) Get(ctx, resourceGroupName, routeTableName, expand any) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockInterface)(nil).Get), ctx, resourceGroupName, routeTableName, expand) -} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go index 677bb2ea13..3dbd0dae85 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure.go @@ -20,7 +20,6 @@ import ( "context" "errors" "fmt" - "io" "net/http" "os" "strings" @@ -33,7 +32,6 @@ import ( "github.com/Azure/go-autorest/autorest/azure" v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" @@ -60,7 +58,6 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/privatednszonegroupclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/privateendpointclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/publicipclient" - "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/storageaccountclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/subnetclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmasclient" @@ -68,16 +65,17 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmsizeclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmssclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmssvmclient" + "sigs.k8s.io/cloud-provider-azure/pkg/provider/config" "sigs.k8s.io/cloud-provider-azure/pkg/provider/privatelinkservice" + "sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable" + "sigs.k8s.io/cloud-provider-azure/pkg/provider/securitygroup" "sigs.k8s.io/cloud-provider-azure/pkg/provider/subnet" "sigs.k8s.io/cloud-provider-azure/pkg/provider/zone" - - "sigs.k8s.io/yaml" + "sigs.k8s.io/cloud-provider-azure/pkg/version" azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache" "sigs.k8s.io/cloud-provider-azure/pkg/consts" - ratelimitconfig "sigs.k8s.io/cloud-provider-azure/pkg/provider/config" - "sigs.k8s.io/cloud-provider-azure/pkg/provider/securitygroup" + azureconfig "sigs.k8s.io/cloud-provider-azure/pkg/provider/config" "sigs.k8s.io/cloud-provider-azure/pkg/retry" utilsets "sigs.k8s.io/cloud-provider-azure/pkg/util/sets" "sigs.k8s.io/cloud-provider-azure/pkg/util/taints" @@ -100,249 +98,6 @@ var ( } ) -// Config holds the configuration parsed from the --cloud-config flag -// All fields are required unless otherwise specified -// NOTE: Cloud config files should follow the same Kubernetes deprecation policy as -// flags or CLIs. Config fields should not change behavior in incompatible ways and -// should be deprecated for at least 2 release prior to removing. -// See https://kubernetes.io/docs/reference/using-api/deprecation-policy/#deprecating-a-flag-or-cli -// for more details. -type Config struct { - ratelimitconfig.AzureAuthConfig `json:",inline" yaml:",inline"` - ratelimitconfig.CloudProviderRateLimitConfig `json:",inline" yaml:",inline"` - - // The cloud configure type for Azure cloud provider. Supported values are file, secret and merge. - CloudConfigType configloader.CloudConfigType `json:"cloudConfigType,omitempty" yaml:"cloudConfigType,omitempty"` - - // The name of the resource group that the cluster is deployed in - ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resourceGroup,omitempty"` - // The location of the resource group that the cluster is deployed in - Location string `json:"location,omitempty" yaml:"location,omitempty"` - // The name of site where the cluster will be deployed to that is more granular than the region specified by the "location" field. - // Currently only public ip, load balancer and managed disks support this. - ExtendedLocationName string `json:"extendedLocationName,omitempty" yaml:"extendedLocationName,omitempty"` - // The type of site that is being targeted. - // Currently only public ip, load balancer and managed disks support this. - ExtendedLocationType string `json:"extendedLocationType,omitempty" yaml:"extendedLocationType,omitempty"` - // The name of the VNet that the cluster is deployed in - VnetName string `json:"vnetName,omitempty" yaml:"vnetName,omitempty"` - // The name of the resource group that the Vnet is deployed in - VnetResourceGroup string `json:"vnetResourceGroup,omitempty" yaml:"vnetResourceGroup,omitempty"` - // The name of the subnet that the cluster is deployed in - SubnetName string `json:"subnetName,omitempty" yaml:"subnetName,omitempty"` - // The name of the security group attached to the cluster's subnet - SecurityGroupName string `json:"securityGroupName,omitempty" yaml:"securityGroupName,omitempty"` - // The name of the resource group that the security group is deployed in - SecurityGroupResourceGroup string `json:"securityGroupResourceGroup,omitempty" yaml:"securityGroupResourceGroup,omitempty"` - // (Optional in 1.6) The name of the route table attached to the subnet that the cluster is deployed in - RouteTableName string `json:"routeTableName,omitempty" yaml:"routeTableName,omitempty"` - // The name of the resource group that the RouteTable is deployed in - RouteTableResourceGroup string `json:"routeTableResourceGroup,omitempty" yaml:"routeTableResourceGroup,omitempty"` - // (Optional) The name of the availability set that should be used as the load balancer backend - // If this is set, the Azure cloudprovider will only add nodes from that availability set to the load - // balancer backend pool. If this is not set, and multiple agent pools (availability sets) are used, then - // the cloudprovider will try to add all nodes to a single backend pool which is forbidden. - // In other words, if you use multiple agent pools (availability sets), you MUST set this field. - PrimaryAvailabilitySetName string `json:"primaryAvailabilitySetName,omitempty" yaml:"primaryAvailabilitySetName,omitempty"` - // The type of azure nodes. Candidate values are: vmss, standard and vmssflex. - // If not set, it will be default to vmss. - VMType string `json:"vmType,omitempty" yaml:"vmType,omitempty"` - // The name of the scale set that should be used as the load balancer backend. - // If this is set, the Azure cloudprovider will only add nodes from that scale set to the load - // balancer backend pool. If this is not set, and multiple agent pools (scale sets) are used, then - // the cloudprovider will try to add all nodes to a single backend pool which is forbidden in the basic sku. - // In other words, if you use multiple agent pools (scale sets), and loadBalancerSku is set to basic, you MUST set this field. - PrimaryScaleSetName string `json:"primaryScaleSetName,omitempty" yaml:"primaryScaleSetName,omitempty"` - // Tags determines what tags shall be applied to the shared resources managed by controller manager, which - // includes load balancer, security group and route table. The supported format is `a=b,c=d,...`. After updated - // this config, the old tags would be replaced by the new ones. - // Because special characters are not supported in "tags" configuration, "tags" support would be removed in a future release, - // please consider migrating the config to "tagsMap". - Tags string `json:"tags,omitempty" yaml:"tags,omitempty"` - // TagsMap is similar to Tags but holds tags with special characters such as `=` and `,`. - TagsMap map[string]string `json:"tagsMap,omitempty" yaml:"tagsMap,omitempty"` - // SystemTags determines the tag keys managed by cloud provider. If it is not set, no tags would be deleted if - // the `Tags` is changed. However, the old tags would be deleted if they are neither included in `Tags` nor - // in `SystemTags` after the update of `Tags`. - SystemTags string `json:"systemTags,omitempty" yaml:"systemTags,omitempty"` - // Sku of Load Balancer and Public IP. Candidate values are: basic and standard. - // If not set, it will be default to basic. - LoadBalancerSku string `json:"loadBalancerSku,omitempty" yaml:"loadBalancerSku,omitempty"` - // LoadBalancerName determines the specific name of the load balancer user want to use, working with - // LoadBalancerResourceGroup - LoadBalancerName string `json:"loadBalancerName,omitempty" yaml:"loadBalancerName,omitempty"` - // LoadBalancerResourceGroup determines the specific resource group of the load balancer user want to use, working - // with LoadBalancerName - LoadBalancerResourceGroup string `json:"loadBalancerResourceGroup,omitempty" yaml:"loadBalancerResourceGroup,omitempty"` - // PreConfiguredBackendPoolLoadBalancerTypes determines whether the LoadBalancer BackendPool has been preconfigured. - // Candidate values are: - // "": exactly with today (not pre-configured for any LBs) - // "internal": for internal LoadBalancer - // "external": for external LoadBalancer - // "all": for both internal and external LoadBalancer - PreConfiguredBackendPoolLoadBalancerTypes string `json:"preConfiguredBackendPoolLoadBalancerTypes,omitempty" yaml:"preConfiguredBackendPoolLoadBalancerTypes,omitempty"` - - // DisableAvailabilitySetNodes disables VMAS nodes support when "VMType" is set to "vmss". - DisableAvailabilitySetNodes bool `json:"disableAvailabilitySetNodes,omitempty" yaml:"disableAvailabilitySetNodes,omitempty"` - // EnableVmssFlexNodes enables vmss flex nodes support when "VMType" is set to "vmss". - EnableVmssFlexNodes bool `json:"enableVmssFlexNodes,omitempty" yaml:"enableVmssFlexNodes,omitempty"` - // DisableAzureStackCloud disables AzureStackCloud support. It should be used - // when setting AzureAuthConfig.Cloud with "AZURESTACKCLOUD" to customize ARM endpoints - // while the cluster is not running on AzureStack. - DisableAzureStackCloud bool `json:"disableAzureStackCloud,omitempty" yaml:"disableAzureStackCloud,omitempty"` - // Enable exponential backoff to manage resource request retries - CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty" yaml:"cloudProviderBackoff,omitempty"` - // Use instance metadata service where possible - UseInstanceMetadata bool `json:"useInstanceMetadata,omitempty" yaml:"useInstanceMetadata,omitempty"` - - // Backoff exponent - CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty" yaml:"cloudProviderBackoffExponent,omitempty"` - // Backoff jitter - CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty" yaml:"cloudProviderBackoffJitter,omitempty"` - - // ExcludeMasterFromStandardLB excludes master nodes from standard load balancer. - // If not set, it will be default to true. - ExcludeMasterFromStandardLB *bool `json:"excludeMasterFromStandardLB,omitempty" yaml:"excludeMasterFromStandardLB,omitempty"` - // DisableOutboundSNAT disables the outbound SNAT for public load balancer rules. - // It should only be set when loadBalancerSku is standard. If not set, it will be default to false. - DisableOutboundSNAT *bool `json:"disableOutboundSNAT,omitempty" yaml:"disableOutboundSNAT,omitempty"` - - // Maximum allowed LoadBalancer Rule Count is the limit enforced by Azure Load balancer - MaximumLoadBalancerRuleCount int `json:"maximumLoadBalancerRuleCount,omitempty" yaml:"maximumLoadBalancerRuleCount,omitempty"` - // Backoff retry limit - CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty" yaml:"cloudProviderBackoffRetries,omitempty"` - // Backoff duration - CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty" yaml:"cloudProviderBackoffDuration,omitempty"` - // NonVmssUniformNodesCacheTTLInSeconds sets the Cache TTL for NonVmssUniformNodesCacheTTLInSeconds - // if not set, will use default value - NonVmssUniformNodesCacheTTLInSeconds int `json:"nonVmssUniformNodesCacheTTLInSeconds,omitempty" yaml:"nonVmssUniformNodesCacheTTLInSeconds,omitempty"` - // VmssCacheTTLInSeconds sets the cache TTL for VMSS - VmssCacheTTLInSeconds int `json:"vmssCacheTTLInSeconds,omitempty" yaml:"vmssCacheTTLInSeconds,omitempty"` - // VmssVirtualMachinesCacheTTLInSeconds sets the cache TTL for vmssVirtualMachines - VmssVirtualMachinesCacheTTLInSeconds int `json:"vmssVirtualMachinesCacheTTLInSeconds,omitempty" yaml:"vmssVirtualMachinesCacheTTLInSeconds,omitempty"` - - // VmssFlexCacheTTLInSeconds sets the cache TTL for VMSS Flex - VmssFlexCacheTTLInSeconds int `json:"vmssFlexCacheTTLInSeconds,omitempty" yaml:"vmssFlexCacheTTLInSeconds,omitempty"` - // VmssFlexVMCacheTTLInSeconds sets the cache TTL for vmss flex vms - VmssFlexVMCacheTTLInSeconds int `json:"vmssFlexVMCacheTTLInSeconds,omitempty" yaml:"vmssFlexVMCacheTTLInSeconds,omitempty"` - - // VmCacheTTLInSeconds sets the cache TTL for vm - VMCacheTTLInSeconds int `json:"vmCacheTTLInSeconds,omitempty" yaml:"vmCacheTTLInSeconds,omitempty"` - // LoadBalancerCacheTTLInSeconds sets the cache TTL for load balancer - LoadBalancerCacheTTLInSeconds int `json:"loadBalancerCacheTTLInSeconds,omitempty" yaml:"loadBalancerCacheTTLInSeconds,omitempty"` - // NsgCacheTTLInSeconds sets the cache TTL for network security group - NsgCacheTTLInSeconds int `json:"nsgCacheTTLInSeconds,omitempty" yaml:"nsgCacheTTLInSeconds,omitempty"` - // RouteTableCacheTTLInSeconds sets the cache TTL for route table - RouteTableCacheTTLInSeconds int `json:"routeTableCacheTTLInSeconds,omitempty" yaml:"routeTableCacheTTLInSeconds,omitempty"` - // PlsCacheTTLInSeconds sets the cache TTL for private link service resource - PlsCacheTTLInSeconds int `json:"plsCacheTTLInSeconds,omitempty" yaml:"plsCacheTTLInSeconds,omitempty"` - // AvailabilitySetsCacheTTLInSeconds sets the cache TTL for VMAS - AvailabilitySetsCacheTTLInSeconds int `json:"availabilitySetsCacheTTLInSeconds,omitempty" yaml:"availabilitySetsCacheTTLInSeconds,omitempty"` - // PublicIPCacheTTLInSeconds sets the cache TTL for public ip - PublicIPCacheTTLInSeconds int `json:"publicIPCacheTTLInSeconds,omitempty" yaml:"publicIPCacheTTLInSeconds,omitempty"` - // RouteUpdateWaitingInSeconds is the delay time for waiting route updates to take effect. This waiting delay is added - // because the routes are not taken effect when the async route updating operation returns success. Default is 30 seconds. - RouteUpdateWaitingInSeconds int `json:"routeUpdateWaitingInSeconds,omitempty" yaml:"routeUpdateWaitingInSeconds,omitempty"` - // The user agent for Azure customer usage attribution - UserAgent string `json:"userAgent,omitempty" yaml:"userAgent,omitempty"` - // LoadBalancerBackendPoolConfigurationType defines how vms join the load balancer backend pools. Supported values - // are `nodeIPConfiguration`, `nodeIP` and `podIP`. - // `nodeIPConfiguration`: vm network interfaces will be attached to the inbound backend pool of the load balancer (default); - // `nodeIP`: vm private IPs will be attached to the inbound backend pool of the load balancer; - // `podIP`: pod IPs will be attached to the inbound backend pool of the load balancer (not supported yet). - LoadBalancerBackendPoolConfigurationType string `json:"loadBalancerBackendPoolConfigurationType,omitempty" yaml:"loadBalancerBackendPoolConfigurationType,omitempty"` - // PutVMSSVMBatchSize defines how many requests the client send concurrently when putting the VMSS VMs. - // If it is smaller than or equal to zero, the request will be sent one by one in sequence (default). - PutVMSSVMBatchSize int `json:"putVMSSVMBatchSize" yaml:"putVMSSVMBatchSize"` - // PrivateLinkServiceResourceGroup determines the specific resource group of the private link services user want to use - PrivateLinkServiceResourceGroup string `json:"privateLinkServiceResourceGroup,omitempty" yaml:"privateLinkServiceResourceGroup,omitempty"` - - // EnableMigrateToIPBasedBackendPoolAPI uses the migration API to migrate from NIC-based to IP-based backend pool. - // The migration API can provide a migration from NIC-based to IP-based backend pool without service downtime. - // If the API is not used, the migration will be done by decoupling all nodes on the backend pool and then re-attaching - // node IPs, which will introduce service downtime. The downtime increases with the number of nodes in the backend pool. - EnableMigrateToIPBasedBackendPoolAPI bool `json:"enableMigrateToIPBasedBackendPoolAPI" yaml:"enableMigrateToIPBasedBackendPoolAPI"` - - // MultipleStandardLoadBalancerConfigurations stores the properties regarding multiple standard load balancers. - // It will be ignored if LoadBalancerBackendPoolConfigurationType is nodeIPConfiguration. - // If the length is not 0, it is assumed the multiple standard load balancers mode is on. In this case, - // there must be one configuration named "" or an error will be reported. - MultipleStandardLoadBalancerConfigurations []MultipleStandardLoadBalancerConfiguration `json:"multipleStandardLoadBalancerConfigurations,omitempty" yaml:"multipleStandardLoadBalancerConfigurations,omitempty"` - - // DisableAPICallCache disables the cache for Azure API calls. It is for ARG support and not all resources will be disabled. - DisableAPICallCache bool `json:"disableAPICallCache,omitempty" yaml:"disableAPICallCache,omitempty"` - - // RouteUpdateIntervalInSeconds is the interval for updating routes. Default is 30 seconds. - RouteUpdateIntervalInSeconds int `json:"routeUpdateIntervalInSeconds,omitempty" yaml:"routeUpdateIntervalInSeconds,omitempty"` - // LoadBalancerBackendPoolUpdateIntervalInSeconds is the interval for updating load balancer backend pool of local services. Default is 30 seconds. - LoadBalancerBackendPoolUpdateIntervalInSeconds int `json:"loadBalancerBackendPoolUpdateIntervalInSeconds,omitempty" yaml:"loadBalancerBackendPoolUpdateIntervalInSeconds,omitempty"` - - // ClusterServiceLoadBalancerHealthProbeMode determines the health probe mode for cluster service load balancer. - // Supported values are `shared` and `servicenodeport`. - // `servicenodeport`: the health probe will be created against each port of each service by watching the backend application (default). - // `shared`: all cluster services shares one HTTP probe targeting the kube-proxy on the node (/healthz:10256). - ClusterServiceLoadBalancerHealthProbeMode string `json:"clusterServiceLoadBalancerHealthProbeMode,omitempty" yaml:"clusterServiceLoadBalancerHealthProbeMode,omitempty"` - // ClusterServiceSharedLoadBalancerHealthProbePort defines the target port of the shared health probe. Default to 10256. - ClusterServiceSharedLoadBalancerHealthProbePort int32 `json:"clusterServiceSharedLoadBalancerHealthProbePort,omitempty" yaml:"clusterServiceSharedLoadBalancerHealthProbePort,omitempty"` - // ClusterServiceSharedLoadBalancerHealthProbePath defines the target path of the shared health probe. Default to `/healthz`. - ClusterServiceSharedLoadBalancerHealthProbePath string `json:"clusterServiceSharedLoadBalancerHealthProbePath,omitempty" yaml:"clusterServiceSharedLoadBalancerHealthProbePath,omitempty"` -} - -// MultipleStandardLoadBalancerConfiguration stores the properties regarding multiple standard load balancers. -type MultipleStandardLoadBalancerConfiguration struct { - // Name of the public load balancer. There will be an internal load balancer - // created if needed, and the name will be `-internal`. The internal lb - // shares the same configurations as the external one. The internal lbs - // are not needed to be included in `MultipleStandardLoadBalancerConfigurations`. - // There must be a name of "" in the load balancer configuration list. - Name string `json:"name" yaml:"name"` - - MultipleStandardLoadBalancerConfigurationSpec - - MultipleStandardLoadBalancerConfigurationStatus -} - -// MultipleStandardLoadBalancerConfigurationSpec stores the properties regarding multiple standard load balancers. -type MultipleStandardLoadBalancerConfigurationSpec struct { - // This load balancer can have services placed on it. Defaults to true, - // can be set to false to drain and eventually remove a load balancer. - // This only affects services that will be using the LB. For services - // that is currently using the LB, they will not be affected. - AllowServicePlacement *bool `json:"allowServicePlacement" yaml:"allowServicePlacement"` - - // A string value that must specify the name of an existing vmSet. - // All nodes in the given vmSet will always be added to this load balancer. - // A vmSet can only be the primary vmSet for a single load balancer. - PrimaryVMSet string `json:"primaryVMSet" yaml:"primaryVMSet"` - - // Services that must match this selector can be placed on this load balancer. If not supplied, - // services with any labels can be created on the load balancer. - ServiceLabelSelector *metav1.LabelSelector `json:"serviceLabelSelector" yaml:"serviceLabelSelector"` - - // Services created in namespaces with the supplied label will be allowed to select that load balancer. - // If not supplied, services created in any namespaces can be created on that load balancer. - ServiceNamespaceSelector *metav1.LabelSelector `json:"serviceNamespaceSelector" yaml:"serviceNamespaceSelector"` - - // Nodes matching this selector will be preferentially added to the load balancers that - // they match selectors for. NodeSelector does not override primaryAgentPool for node allocation. - NodeSelector *metav1.LabelSelector `json:"nodeSelector" yaml:"nodeSelector"` -} - -// MultipleStandardLoadBalancerConfigurationStatus stores the properties regarding multiple standard load balancers. -type MultipleStandardLoadBalancerConfigurationStatus struct { - // ActiveServices stores the services that are supposed to use the load balancer. - ActiveServices *utilsets.IgnoreCaseSet `json:"activeServices" yaml:"activeServices"` - - // ActiveNodes stores the nodes that are supposed to be in the load balancer. - // It will be used in EnsureHostsInPool to make sure the given ones are in the backend pool. - ActiveNodes *utilsets.IgnoreCaseSet `json:"activeNodes" yaml:"activeNodes"` -} - -// HasExtendedLocation returns true if extendedlocation prop are specified. -func (config *Config) HasExtendedLocation() bool { - return config.ExtendedLocationName != "" && config.ExtendedLocationType != "" -} - var ( _ cloudprovider.Interface = (*Cloud)(nil) _ cloudprovider.Instances = (*Cloud)(nil) @@ -353,12 +108,11 @@ var ( // Cloud holds the config and clients type Cloud struct { - Config + azureconfig.Config Environment azure.Environment SubnetsClient subnetclient.Interface InterfacesClient interfaceclient.Interface - RouteTablesClient routetableclient.Interface LoadBalancerClient loadbalancerclient.Interface PublicIPAddressesClient publicipclient.Interface VirtualMachinesClient vmclient.Interface @@ -415,13 +169,13 @@ type Cloud struct { routeUpdater batchProcessor backendPoolUpdater batchProcessor - vmCache azcache.Resource - lbCache azcache.Resource - nsgRepo securitygroup.Repository - zoneRepo zone.Repository - plsRepo privatelinkservice.Repository - subnetRepo subnet.Repository - rtCache azcache.Resource + vmCache azcache.Resource + lbCache azcache.Resource + nsgRepo securitygroup.Repository + zoneRepo zone.Repository + plsRepo privatelinkservice.Repository + subnetRepo subnet.Repository + routeTableRepo routetable.Repository // public ip cache // key: [resourceGroupName] // Value: sync.Map of [pipName]*PublicIPAddress @@ -451,7 +205,7 @@ type Cloud struct { } // NewCloud returns a Cloud with initialized clients -func NewCloud(ctx context.Context, clientBuilder cloudprovider.ControllerClientBuilder, config *Config, callFromCCM bool) (cloudprovider.Interface, error) { +func NewCloud(ctx context.Context, clientBuilder cloudprovider.ControllerClientBuilder, config *azureconfig.Config, callFromCCM bool) (cloudprovider.Interface, error) { az := &Cloud{ nodeNames: utilsets.NewString(), nodeZones: map[string]*utilsets.IgnoreCaseSet{}, @@ -493,17 +247,17 @@ func NewCloudFromConfigFile(ctx context.Context, clientBuilder cloudprovider.Con err error ) - var configValue *Config + var configValue *azureconfig.Config if configFilePath != "" { - var config *os.File - config, err = os.Open(configFilePath) + var configFile *os.File + configFile, err = os.Open(configFilePath) if err != nil { klog.Fatalf("Couldn't open cloud provider configuration %s: %#v", configFilePath, err) } - defer config.Close() - configValue, err = ParseConfig(config) + defer configFile.Close() + configValue, err = config.ParseConfig(configFile) if err != nil { klog.Fatalf("Failed to parse Azure cloud provider config: %v", err) } @@ -520,7 +274,7 @@ func NewCloudFromConfigFile(ctx context.Context, clientBuilder cloudprovider.Con } func NewCloudFromSecret(ctx context.Context, clientBuilder cloudprovider.ControllerClientBuilder, secretName, secretNamespace, cloudConfigKey string) (cloudprovider.Interface, error) { - config, err := configloader.Load[Config](ctx, &configloader.K8sSecretLoaderConfig{ + config, err := configloader.Load[azureconfig.Config](ctx, &configloader.K8sSecretLoaderConfig{ K8sSecretConfig: configloader.K8sSecretConfig{ SecretName: secretName, SecretNamespace: secretNamespace, @@ -541,7 +295,7 @@ func NewCloudFromSecret(ctx context.Context, clientBuilder cloudprovider.Control } // InitializeCloudFromConfig initializes the Cloud from config. -func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, fromSecret, callFromCCM bool) error { +func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *config.Config, fromSecret, callFromCCM bool) error { if config == nil { // should not reach here return fmt.Errorf("InitializeCloudFromConfig: cannot initialize from nil config") @@ -617,13 +371,13 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, config.ClusterServiceSharedLoadBalancerHealthProbePath = consts.ClusterServiceLoadBalancerHealthProbeDefaultPath } - env, err := ratelimitconfig.ParseAzureEnvironment(config.Cloud, config.ResourceManagerEndpoint, config.IdentitySystem) + env, err := azureconfig.ParseAzureEnvironment(config.Cloud, config.ResourceManagerEndpoint, config.IdentitySystem) if err != nil { return err } // Initialize rate limiting config options. - ratelimitconfig.InitializeCloudProviderRateLimitConfig(&config.CloudProviderRateLimitConfig) + azureconfig.InitializeCloudProviderRateLimitConfig(&config.CloudProviderRateLimitConfig) resourceRequestBackoff := az.setCloudProviderBackoffDefaults(config) @@ -662,19 +416,19 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, } } - if az.isLBBackendPoolTypeNodeIPConfig() { + if az.IsLBBackendPoolTypeNodeIPConfig() { az.LoadBalancerBackendPool = newBackendPoolTypeNodeIPConfig(az) - } else if az.isLBBackendPoolTypeNodeIP() { + } else if az.IsLBBackendPoolTypeNodeIP() { az.LoadBalancerBackendPool = newBackendPoolTypeNodeIP(az) } - if az.useMultipleStandardLoadBalancers() { + if az.UseMultipleStandardLoadBalancers() { if err := az.checkEnableMultipleStandardLoadBalancers(); err != nil { return err } } - servicePrincipalToken, err := ratelimitconfig.GetServicePrincipalToken(&config.AzureAuthConfig, env, env.ServiceManagementEndpoint) - if errors.Is(err, ratelimitconfig.ErrorNoAuth) { + servicePrincipalToken, err := azureconfig.GetServicePrincipalToken(&config.AzureClientConfig, env, env.ServiceManagementEndpoint) + if errors.Is(err, azureconfig.ErrorNoAuth) { // Only controller-manager would lazy-initialize from secret, and credentials are required for such case. if fromSecret { err := fmt.Errorf("no credentials provided for Azure cloud provider") @@ -700,7 +454,7 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, } var authProvider *azclient.AuthProvider - authProvider, err = azclient.NewAuthProvider(&az.ARMClientConfig, &az.AzureAuthConfig.AzureAuthConfig) + authProvider, err = azclient.NewAuthProvider(&az.ARMClientConfig, &az.AzureClientConfig.AzureAuthConfig) if err != nil { return err } @@ -713,6 +467,8 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, az.configAzureClients(servicePrincipalToken, multiTenantServicePrincipalToken, networkResourceServicePrincipalToken) if az.ComputeClientFactory == nil { + k8sVersion := version.Get().GitVersion + az.ARMClientConfig.UserAgent = fmt.Sprintf("kubernetes-cloudprovider/%s; %s", k8sVersion, az.ARMClientConfig.UserAgent) var cred azcore.TokenCredential if authProvider.IsMultiTenantModeEnabled() { multiTenantCred := authProvider.GetMultiTenantIdentity() @@ -752,10 +508,16 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, if err != nil { return err } + az.subnetRepo, err = subnet.NewRepo(networkClientFactory.GetSubnetClient()) if err != nil { return err } + + az.routeTableRepo, err = routetable.NewRepo(networkClientFactory.GetRouteTableClient(), az.RouteTableResourceGroup, time.Duration(az.RouteTableCacheTTLInSeconds)*time.Second, az.DisableAPICallCache) + if err != nil { + return err + } } err = az.initCaches() if err != nil { @@ -764,8 +526,8 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, // Common controller contains the function // needed by both blob disk and managed disk controllers - qps := float32(ratelimitconfig.DefaultAtachDetachDiskQPS) - bucket := ratelimitconfig.DefaultAtachDetachDiskBucket + qps := float32(azureconfig.DefaultAtachDetachDiskQPS) + bucket := azureconfig.DefaultAtachDetachDiskBucket if az.Config.AttachDetachDiskRateLimit != nil { qps = az.Config.AttachDetachDiskRateLimit.CloudProviderRateLimitQPSWrite bucket = az.Config.AttachDetachDiskRateLimit.CloudProviderRateLimitBucketWrite @@ -782,14 +544,14 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, go az.routeUpdater.run(ctx) // start backend pool updater. - if az.useMultipleStandardLoadBalancers() { + if az.UseMultipleStandardLoadBalancers() { az.backendPoolUpdater = newLoadBalancerBackendPoolUpdater(az, time.Duration(az.LoadBalancerBackendPoolUpdateIntervalInSeconds)*time.Second) go az.backendPoolUpdater.run(ctx) } // Azure Stack does not support zone at the moment // https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-network-differences?view=azs-2102 - if !az.isStackCloud() { + if !az.IsStackCloud() { // wait for the success first time of syncing zones err = az.syncRegionZonesMap(ctx) if err != nil { @@ -804,17 +566,9 @@ func (az *Cloud) InitializeCloudFromConfig(ctx context.Context, config *Config, return nil } -func (az *Cloud) useMultipleStandardLoadBalancers() bool { - return az.useStandardLoadBalancer() && len(az.MultipleStandardLoadBalancerConfigurations) > 0 -} - -func (az *Cloud) useSingleStandardLoadBalancer() bool { - return az.useStandardLoadBalancer() && len(az.MultipleStandardLoadBalancerConfigurations) == 0 -} - // Multiple standard load balancer mode only supports IP-based load balancers. func (az *Cloud) checkEnableMultipleStandardLoadBalancers() error { - if az.isLBBackendPoolTypeNodeIPConfig() { + if az.IsLBBackendPoolTypeNodeIPConfig() { return fmt.Errorf("multiple standard load balancers cannot be used with backend pool type %s", consts.LoadBalancerBackendPoolConfigurationTypeNodeIPConfiguration) } @@ -842,18 +596,6 @@ func (az *Cloud) checkEnableMultipleStandardLoadBalancers() error { return nil } -func (az *Cloud) isLBBackendPoolTypeNodeIPConfig() bool { - return strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypeNodeIPConfiguration) -} - -func (az *Cloud) isLBBackendPoolTypeNodeIP() bool { - return strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypeNodeIP) -} - -func (az *Cloud) getPutVMSSVMBatchSize() int { - return az.PutVMSSVMBatchSize -} - func (az *Cloud) initCaches() (err error) { if az.Config.DisableAPICallCache { klog.Infof("API call cache is disabled, ignore logs about cache operations") @@ -869,11 +611,6 @@ func (az *Cloud) initCaches() (err error) { return err } - az.rtCache, err = az.newRouteTableCache() - if err != nil { - return err - } - az.pipCache, err = az.newPIPCache() if err != nil { return err @@ -889,7 +626,7 @@ func (az *Cloud) initCaches() (err error) { return nil } -func (az *Cloud) setLBDefaults(config *Config) error { +func (az *Cloud) setLBDefaults(config *azureconfig.Config) error { if config.LoadBalancerSku == "" { config.LoadBalancerSku = consts.LoadBalancerSkuStandard } @@ -917,11 +654,11 @@ func (az *Cloud) getAuthTokenInMultiTenantEnv(_ *adal.ServicePrincipalToken, aut var multiTenantOAuthToken adal.MultitenantOAuthTokenProvider var networkResourceServicePrincipalToken adal.OAuthTokenProvider if az.Config.UsesNetworkResourceInDifferentTenant() { - multiTenantOAuthToken, err = ratelimitconfig.GetMultiTenantServicePrincipalToken(&az.Config.AzureAuthConfig, &az.Environment, authProvider) + multiTenantOAuthToken, err = azureconfig.GetMultiTenantServicePrincipalToken(&az.Config.AzureClientConfig, &az.Environment, authProvider) if err != nil { return nil, nil, err } - networkResourceServicePrincipalToken, err = ratelimitconfig.GetNetworkResourceServicePrincipalToken(&az.Config.AzureAuthConfig, &az.Environment, authProvider) + networkResourceServicePrincipalToken, err = azureconfig.GetNetworkResourceServicePrincipalToken(&az.Config.AzureClientConfig, &az.Environment, authProvider) if err != nil { return nil, nil, err } @@ -929,7 +666,7 @@ func (az *Cloud) getAuthTokenInMultiTenantEnv(_ *adal.ServicePrincipalToken, aut return multiTenantOAuthToken, networkResourceServicePrincipalToken, nil } -func (az *Cloud) setCloudProviderBackoffDefaults(config *Config) wait.Backoff { +func (az *Cloud) setCloudProviderBackoffDefaults(config *azureconfig.Config) wait.Backoff { // Conditionally configure resource request backoff resourceRequestBackoff := wait.Backoff{ Steps: 1, @@ -1033,7 +770,6 @@ func (az *Cloud) configAzureClients( az.VirtualMachineScaleSetsClient = vmssclient.New(vmssClientConfig) az.VirtualMachineScaleSetVMsClient = vmssvmclient.New(vmssVMClientConfig) az.SubnetsClient = subnetclient.New(subnetClientConfig) - az.RouteTablesClient = routetableclient.New(routeTableClientConfig) az.LoadBalancerClient = loadbalancerclient.New(loadBalancerClientConfig) az.PublicIPAddressesClient = publicipclient.New(publicIPClientConfig) az.FileClient = fileclient.New(fileClientConfig) @@ -1074,45 +810,6 @@ func (az *Cloud) getAzureClientConfig(servicePrincipalToken *adal.ServicePrincip return azClientConfig } -// ParseConfig returns a parsed configuration for an Azure cloudprovider config file -func ParseConfig(configReader io.Reader) (*Config, error) { - var config Config - if configReader == nil { - return nil, nil - } - - configContents, err := io.ReadAll(configReader) - if err != nil { - return nil, err - } - - err = yaml.Unmarshal(configContents, &config) - if err != nil { - return nil, err - } - - // The resource group name may be in different cases from different Azure APIs, hence it is converted to lower here. - // See more context at https://github.com/kubernetes/kubernetes/issues/71994. - config.ResourceGroup = strings.ToLower(config.ResourceGroup) - - // these environment variables are injected by workload identity webhook - if tenantID := os.Getenv("AZURE_TENANT_ID"); tenantID != "" { - config.TenantID = tenantID - } - if clientID := os.Getenv("AZURE_CLIENT_ID"); clientID != "" { - config.AADClientID = clientID - } - if federatedTokenFile := os.Getenv("AZURE_FEDERATED_TOKEN_FILE"); federatedTokenFile != "" { - config.AADFederatedTokenFile = federatedTokenFile - config.UseFederatedWorkloadIdentityExtension = true - } - return &config, nil -} - -func (az *Cloud) isStackCloud() bool { - return strings.EqualFold(az.Config.Cloud, consts.AzureStackCloudName) && !az.Config.DisableAzureStackCloud -} - // Initialize passes a Kubernetes clientBuilder interface to the cloud provider func (az *Cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, _ <-chan struct{}) { az.KubeClient = clientBuilder.ClientOrDie("azure-cloud-provider") @@ -1143,7 +840,7 @@ func (az *Cloud) InstancesV2() (cloudprovider.InstancesV2, bool) { // DEPRECATED: Zones is deprecated in favor of retrieving zone/region information from InstancesV2. // This interface will not be called if InstancesV2 is enabled. func (az *Cloud) Zones() (cloudprovider.Zones, bool) { - if az.isStackCloud() { + if az.IsStackCloud() { // Azure stack does not support zones at this point // https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-network-differences?view=azs-2102 return nil, false diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_fakes.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_fakes.go index 030128a85b..c043746537 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_fakes.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_fakes.go @@ -36,7 +36,6 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/interfaceclient/mockinterfaceclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/loadbalancerclient/mockloadbalancerclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/publicipclient/mockpublicipclient" - "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/routetableclient/mockroutetableclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/subnetclient/mocksubnetclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmclient/mockvmclient" "sigs.k8s.io/cloud-provider-azure/pkg/azureclients/vmssclient/mockvmssclient" @@ -45,6 +44,7 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/consts" "sigs.k8s.io/cloud-provider-azure/pkg/provider/config" "sigs.k8s.io/cloud-provider-azure/pkg/provider/privatelinkservice" + "sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable" "sigs.k8s.io/cloud-provider-azure/pkg/provider/securitygroup" "sigs.k8s.io/cloud-provider-azure/pkg/provider/subnet" utilsets "sigs.k8s.io/cloud-provider-azure/pkg/util/sets" @@ -78,8 +78,8 @@ func NewTestFlexScaleSet(ctrl *gomock.Controller) (*FlexScaleSet, error) { // GetTestCloud returns a fake azure cloud for unit tests in Azure related CSI drivers func GetTestCloud(ctrl *gomock.Controller) (az *Cloud) { az = &Cloud{ - Config: Config{ - AzureAuthConfig: config.AzureAuthConfig{ + Config: config.Config{ + AzureClientConfig: config.AzureClientConfig{ ARMClientConfig: azclient.ARMClientConfig{ TenantID: "TenantID", }, @@ -116,7 +116,6 @@ func GetTestCloud(ctrl *gomock.Controller) (az *Cloud) { az.InterfacesClient = mockinterfaceclient.NewMockInterface(ctrl) az.LoadBalancerClient = mockloadbalancerclient.NewMockInterface(ctrl) az.PublicIPAddressesClient = mockpublicipclient.NewMockInterface(ctrl) - az.RouteTablesClient = mockroutetableclient.NewMockInterface(ctrl) az.SubnetsClient = mocksubnetclient.NewMockInterface(ctrl) az.VirtualMachineScaleSetsClient = mockvmssclient.NewMockInterface(ctrl) az.VirtualMachineScaleSetVMsClient = mockvmssvmclient.NewMockInterface(ctrl) @@ -140,11 +139,11 @@ func GetTestCloud(ctrl *gomock.Controller) (az *Cloud) { az.lbCache, _ = az.newLBCache() az.nsgRepo, _ = securitygroup.NewSecurityGroupRepo(az.SecurityGroupResourceGroup, az.SecurityGroupName, az.NsgCacheTTLInSeconds, az.Config.DisableAPICallCache, securtyGrouptrack2Client) az.subnetRepo = subnet.NewMockRepository(ctrl) - az.rtCache, _ = az.newRouteTableCache() az.pipCache, _ = az.newPIPCache() az.LoadBalancerBackendPool = NewMockBackendPool(ctrl) az.plsRepo = privatelinkservice.NewMockRepository(ctrl) + az.routeTableRepo = routetable.NewMockRepository(ctrl) getter := func(_ context.Context, _ string) (interface{}, error) { return nil, nil } az.storageAccountCache, _ = azcache.NewTimedCache(time.Minute, getter, az.Config.DisableAPICallCache) diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer.go index c846ff1785..88ce01229c 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer.go @@ -45,6 +45,7 @@ import ( "sigs.k8s.io/cloud-provider-azure/pkg/consts" "sigs.k8s.io/cloud-provider-azure/pkg/log" "sigs.k8s.io/cloud-provider-azure/pkg/metrics" + "sigs.k8s.io/cloud-provider-azure/pkg/provider/config" "sigs.k8s.io/cloud-provider-azure/pkg/provider/loadbalancer" "sigs.k8s.io/cloud-provider-azure/pkg/retry" "sigs.k8s.io/cloud-provider-azure/pkg/trace" @@ -177,11 +178,11 @@ func (az *Cloud) reconcileService(ctx context.Context, clusterName string, servi lbName := strings.ToLower(ptr.Deref(lb.Name, "")) key := strings.ToLower(getServiceName(service)) - if az.useMultipleStandardLoadBalancers() && isLocalService(service) { + if az.UseMultipleStandardLoadBalancers() && isLocalService(service) { az.localServiceNameToServiceInfoMap.Store(key, newServiceInfo(getServiceIPFamily(service), lbName)) // There are chances that the endpointslice changes after EnsureHostsInPool, so // need to check endpointslice for a second time. - if err := az.checkAndApplyLocalServiceBackendPoolUpdates(ctx, *lb, service); err != nil { + if err := az.checkAndApplyLocalServiceBackendPoolUpdates(*lb, service); err != nil { logger.Error(err, "Failed to checkAndApplyLocalServiceBackendPoolUpdates") return nil, err } @@ -488,7 +489,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(ctx context.Context, clusterName stri return err } - if az.useMultipleStandardLoadBalancers() && isLocalService(service) { + if az.UseMultipleStandardLoadBalancers() && isLocalService(service) { key := strings.ToLower(svcName) az.localServiceNameToServiceInfoMap.Delete(key) } @@ -519,7 +520,7 @@ func (az *Cloud) shouldChangeLoadBalancer(service *v1.Service, currLBName, clust // The load balancer can be changed in two cases: // 1. Using multiple standard load balancers. // 2. Migrate from multiple standard load balancers to single standard load balancer. - if az.useStandardLoadBalancer() { + if az.UseStandardLoadBalancer() { if currLBName != expectedLBName { klog.V(2).Infof("shouldChangeLoadBalancer(%s, %s, %s): change the LB to another one %s", service.Name, currLBName, clusterName, expectedLBName) return true @@ -711,15 +712,12 @@ func (az *Cloud) cleanOrphanedLoadBalancer(ctx context.Context, lb *network.Load } // safeDeleteLoadBalancer deletes the load balancer after decoupling it from the vmSet -func (az *Cloud) safeDeleteLoadBalancer(ctx context.Context, lb network.LoadBalancer, clusterName, vmSetName string, service *v1.Service) *retry.Error { - lbBackendPoolIDs := az.getBackendPoolIDs(clusterName, ptr.Deref(lb.Name, "")) +func (az *Cloud) safeDeleteLoadBalancer(ctx context.Context, lb network.LoadBalancer, _, vmSetName string, service *v1.Service) *retry.Error { lbBackendPoolIDsToDelete := []string{} - v4Enabled, v6Enabled := getIPFamiliesEnabled(service) - if v4Enabled { - lbBackendPoolIDsToDelete = append(lbBackendPoolIDsToDelete, lbBackendPoolIDs[consts.IPVersionIPv4]) - } - if v6Enabled { - lbBackendPoolIDsToDelete = append(lbBackendPoolIDsToDelete, lbBackendPoolIDs[consts.IPVersionIPv6]) + if lb.LoadBalancerPropertiesFormat != nil && lb.BackendAddressPools != nil { + for _, bp := range *lb.BackendAddressPools { + lbBackendPoolIDsToDelete = append(lbBackendPoolIDsToDelete, ptr.Deref(bp.ID, "")) + } } if _, err := az.VMSet.EnsureBackendPoolDeleted(ctx, service, lbBackendPoolIDsToDelete, vmSetName, lb.BackendAddressPools, true); err != nil { return retry.NewError(false, fmt.Errorf("safeDeleteLoadBalancer: failed to EnsureBackendPoolDeleted: %w", err)) @@ -829,7 +827,7 @@ func (az *Cloud) getServiceLoadBalancer( ptr.Deref(existingLB.Name, ""), ) - if isLocalService(service) && az.useMultipleStandardLoadBalancers() { + if isLocalService(service) && az.UseMultipleStandardLoadBalancers() { // No need for the endpoint slice informer to update the backend pool // for the service because the main loop will delete the old backend pool // and create a new one in the new load balancer. @@ -857,7 +855,7 @@ func (az *Cloud) getServiceLoadBalancer( // Service does not have a load balancer, select one. // Single standard load balancer doesn't need this because // all backends nodes should be added to same LB. - if wantLb && !az.useStandardLoadBalancer() { + if wantLb && !az.UseStandardLoadBalancer() { // select new load balancer for service selectedLB, exists, err := az.selectLoadBalancer(ctx, clusterName, service, existingLBs, nodes) if err != nil { @@ -884,7 +882,7 @@ func (az *Cloud) getServiceLoadBalancer( Location: &az.Location, LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{}, } - if az.useStandardLoadBalancer() { + if az.UseStandardLoadBalancer() { defaultLB.Sku = &network.LoadBalancerSku{ Name: network.LoadBalancerSkuNameStandard, } @@ -932,7 +930,7 @@ func (az *Cloud) selectLoadBalancer(ctx context.Context, clusterName string, ser // select this LB as this is a new LB and will have minimum rules // create tmp lb struct to hold metadata for the new load-balancer var loadBalancerSKU network.LoadBalancerSkuName - if az.useStandardLoadBalancer() { + if az.UseStandardLoadBalancer() { loadBalancerSKU = network.LoadBalancerSkuNameStandard } else { loadBalancerSKU = network.LoadBalancerSkuNameBasic @@ -1206,7 +1204,7 @@ func (az *Cloud) ensurePublicIPExists(ctx context.Context, service *v1.Service, return nil, err } - if az.useStandardLoadBalancer() { + if az.UseStandardLoadBalancer() { pip.Sku = &network.PublicIPAddressSku{ Name: network.PublicIPAddressSkuNameStandard, } @@ -1280,7 +1278,7 @@ func (az *Cloud) reconcileIPSettings(pip *network.PublicIPAddress, service *v1.S changed = true } - if az.useStandardLoadBalancer() { + if az.UseStandardLoadBalancer() { // standard sku must have static allocation method for ipv6 if !strings.EqualFold(string(pip.PublicIPAddressPropertiesFormat.PublicIPAllocationMethod), string(network.Static)) { pip.PublicIPAddressPropertiesFormat.PublicIPAllocationMethod = network.Static @@ -1507,7 +1505,7 @@ func (az *Cloud) isFrontendIPChanged( if fipIPVersion != "" { isIPv6 = fipIPVersion == network.IPv6 } else { - if isIPv6, err = az.isFIPIPv6(service, pipRG, &config); err != nil { + if isIPv6, err = az.isFIPIPv6(service, &config); err != nil { return false, err } } @@ -1657,7 +1655,6 @@ func (az *Cloud) findFrontendIPConfigsOfService( service *v1.Service, ) (map[bool]*network.FrontendIPConfiguration, error) { fipsOfServiceMap := map[bool]*network.FrontendIPConfiguration{} - pipRG := az.getPublicIPAddressResourceGroup(service) for _, config := range *fipConfigs { config := config owns, _, fipIPVersion := az.serviceOwnsFrontendIP(ctx, config, service) @@ -1667,7 +1664,7 @@ func (az *Cloud) findFrontendIPConfigsOfService( if fipIPVersion != "" { fipIsIPv6 = fipIPVersion == network.IPv6 } else { - if fipIsIPv6, err = az.isFIPIPv6(service, pipRG, &config); err != nil { + if fipIsIPv6, err = az.isFIPIPv6(service, &config); err != nil { return nil, err } } @@ -1692,7 +1689,7 @@ func (az *Cloud) reconcileMultipleStandardLoadBalancerConfigurations( existingLBs *[]network.LoadBalancer, nodes []*v1.Node, ) (err error) { - if !az.useMultipleStandardLoadBalancers() { + if !az.UseMultipleStandardLoadBalancers() { return nil } @@ -1781,7 +1778,7 @@ func (az *Cloud) reconcileLoadBalancer(ctx context.Context, clusterName string, // Delete backend pools for local service if: // 1. the cluster is migrating from multi-slb to single-slb, // 2. the service is changed from local to cluster. - if !az.useMultipleStandardLoadBalancers() || !isLocalService(service) { + if !az.UseMultipleStandardLoadBalancers() || !isLocalService(service) { existingLBs, err = az.cleanupLocalServiceBackendPool(ctx, service, nodes, existingLBs, clusterName) if err != nil { klog.Errorf("reconcileLoadBalancer: failed to cleanup local service backend pool for service %q, error: %s", serviceName, err.Error()) @@ -1843,7 +1840,6 @@ func (az *Cloud) reconcileLoadBalancer(ctx context.Context, clusterName string, } // update probes/rules - pipRG := az.getPublicIPAddressResourceGroup(service) for _, ownedFIPConfig := range ownedFIPConfigs { if ownedFIPConfig == nil { continue @@ -1858,7 +1854,7 @@ func (az *Cloud) reconcileLoadBalancer(ctx context.Context, clusterName string, if fipIPVersion != "" { isIPv6 = fipIPVersion == network.IPv6 } else { - if isIPv6, err = az.isFIPIPv6(service, pipRG, ownedFIPConfig); err != nil { + if isIPv6, err = az.isFIPIPv6(service, ownedFIPConfig); err != nil { return nil, err } } @@ -1962,7 +1958,7 @@ func (az *Cloud) reconcileLoadBalancer(ctx context.Context, clusterName string, _ = az.lbCache.Delete(lbName) }() - if az.useMultipleStandardLoadBalancers() { + if az.UseMultipleStandardLoadBalancers() { err := az.reconcileMultipleStandardLoadBalancerBackendNodes(ctx, clusterName, lbName, existingLBs, service, nodes, false) if err != nil { return nil, err @@ -1975,7 +1971,7 @@ func (az *Cloud) reconcileLoadBalancer(ctx context.Context, clusterName string, // change in one reconciliation loop. var lbToReconcile []network.LoadBalancer lbToReconcile = append(lbToReconcile, *lb) - if az.useMultipleStandardLoadBalancers() { + if az.UseMultipleStandardLoadBalancers() { lbToReconcile = *existingLBs } lb, err = az.reconcileBackendPoolHosts(ctx, lb, lbToReconcile, service, nodes, clusterName, vmSetName, lbBackendPoolIDs) @@ -2519,8 +2515,6 @@ func (az *Cloud) reconcileFrontendIPConfigs( } } - pipRG := az.getPublicIPAddressResourceGroup(service) - for i := len(newConfigs) - 1; i >= 0; i-- { config := newConfigs[i] isServiceOwnsFrontendIP, _, fipIPVersion := az.serviceOwnsFrontendIP(ctx, config, service) @@ -2534,7 +2528,7 @@ func (az *Cloud) reconcileFrontendIPConfigs( if fipIPVersion != "" { isIPv6 = fipIPVersion == network.IPv6 } else { - if isIPv6, err = az.isFIPIPv6(service, pipRG, &config); err != nil { + if isIPv6, err = az.isFIPIPv6(service, &config); err != nil { return nil, toDeleteConfigs, false, err } } @@ -2669,7 +2663,7 @@ func (az *Cloud) getFrontendZones( if err != nil { return err } - if az.useStandardLoadBalancer() && len(zones) > 0 && !az.HasExtendedLocation() { + if az.UseStandardLoadBalancer() && len(zones) > 0 && !az.HasExtendedLocation() { fipConfig.Zones = &zones } } else { @@ -2833,7 +2827,7 @@ func (az *Cloud) getExpectedLBRules( // In HA mode, lb forward traffic of all port to backend // HA mode is only supported on standard loadbalancer SKU in internal mode if consts.IsK8sServiceUsingInternalLoadBalancer(service) && - az.useStandardLoadBalancer() && + az.UseStandardLoadBalancer() && consts.IsK8sServiceHasHAModeEnabled(service) { lbRuleName := az.getloadbalancerHAmodeRuleName(service, isIPv6) @@ -2889,7 +2883,7 @@ func (az *Cloud) getExpectedLBRules( klog.V(2).Infof("getExpectedLBRules lb name (%s) rule name (%s) no lb rule required", lbName, lbRuleName) continue } - if port.Protocol == v1.ProtocolSCTP && !(az.useStandardLoadBalancer() && consts.IsK8sServiceUsingInternalLoadBalancer(service)) { + if port.Protocol == v1.ProtocolSCTP && !(az.UseStandardLoadBalancer() && consts.IsK8sServiceUsingInternalLoadBalancer(service)) { return expectedProbes, expectedRules, fmt.Errorf("SCTP is only supported on standard loadbalancer in internal mode") } @@ -2977,7 +2971,7 @@ func (az *Cloud) getExpectedLoadBalancingRulePropertiesForPort( Protocol: transportProto, FrontendPort: ptr.To(servicePort.Port), BackendPort: ptr.To(servicePort.Port), - DisableOutboundSnat: ptr.To(az.disableLoadBalancerOutboundSNAT()), + DisableOutboundSnat: ptr.To(az.DisableLoadBalancerOutboundSNAT()), EnableFloatingIP: ptr.To(true), LoadDistribution: loadDistribution, FrontendIPConfiguration: &network.SubResource{ @@ -2988,7 +2982,7 @@ func (az *Cloud) getExpectedLoadBalancingRulePropertiesForPort( }, IdleTimeoutInMinutes: lbIdleTimeout, } - if strings.EqualFold(string(transportProto), string(network.TransportProtocolTCP)) && az.useStandardLoadBalancer() { + if strings.EqualFold(string(transportProto), string(network.TransportProtocolTCP)) && az.UseStandardLoadBalancer() { props.EnableTCPReset = ptr.To(!consts.IsTCPResetDisabled(service.Annotations)) } @@ -3670,7 +3664,7 @@ func ipInSubnet(ip string, subnet *network.Subnet) bool { // if anything else it returns the unique VM set names after trimming spaces. func (az *Cloud) getServiceLoadBalancerMode(service *v1.Service) (bool, bool, string) { mode, hasMode := service.Annotations[consts.ServiceAnnotationLoadBalancerMode] - if az.useStandardLoadBalancer() && hasMode { + if az.UseStandardLoadBalancer() && hasMode { klog.Warningf("single standard load balancer doesn't work with annotation %q, would ignore it", consts.ServiceAnnotationLoadBalancerMode) } mode = strings.TrimSpace(mode) @@ -3916,14 +3910,14 @@ func (az *Cloud) getAzureLoadBalancerName( // The LB name prefix is set to the name of the cluster when: // 1. the LB belongs to the primary agent pool. // 2. using the single SLB. - if strings.EqualFold(vmSetName, az.VMSet.GetPrimaryVMSetName()) || az.useSingleStandardLoadBalancer() { + if strings.EqualFold(vmSetName, az.VMSet.GetPrimaryVMSetName()) || az.UseSingleStandardLoadBalancer() { lbNamePrefix = clusterName } // For multiple standard load balancers scenario: // 1. Filter out the eligible load balancers. // 2. Choose the most eligible load balancer. - if az.useMultipleStandardLoadBalancers() { + if az.UseMultipleStandardLoadBalancers() { eligibleLBs, err := az.getEligibleLoadBalancersForService(ctx, service) if err != nil { return "", err @@ -4015,7 +4009,7 @@ func (az *Cloud) getServiceCurrentLoadBalancerName(service *v1.Service) string { // 5. If there is no label/namespace selector on the LB, it can be a valid placement target if and only if the service has no other choice. func (az *Cloud) getEligibleLoadBalancersForService(ctx context.Context, service *v1.Service) ([]string, error) { var ( - eligibleLBs []MultipleStandardLoadBalancerConfiguration + eligibleLBs []config.MultipleStandardLoadBalancerConfiguration eligibleLBNames []string lbSelectedByAnnotation []string lbFailedLabelSelector []string @@ -4166,7 +4160,7 @@ func (az *Cloud) getEligibleLoadBalancersForService(ctx context.Context, service return eligibleLBNames, nil } -func (az *Cloud) isLoadBalancerInUseByService(service *v1.Service, lbConfig MultipleStandardLoadBalancerConfiguration) bool { +func (az *Cloud) isLoadBalancerInUseByService(service *v1.Service, lbConfig config.MultipleStandardLoadBalancerConfiguration) bool { az.multipleStandardLoadBalancersActiveServicesLock.Lock() defer az.multipleStandardLoadBalancersActiveServicesLock.Unlock() diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_backendpool.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_backendpool.go index d0f6f09f95..38364f0f64 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_backendpool.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_backendpool.go @@ -202,7 +202,7 @@ func (bc *backendPoolTypeNodeIPConfig) ReconcileBackendPools( if bp.BackendAddressPoolPropertiesFormat != nil && bp.LoadBalancerBackendAddresses != nil && len(*bp.LoadBalancerBackendAddresses) > 0 { - if removeNodeIPAddressesFromBackendPool(bp, []string{}, true, false) { + if removeNodeIPAddressesFromBackendPool(bp, []string{}, true, false, false) { isMigration = true bp.VirtualNetwork = nil if err := bc.CreateOrUpdateLBBackendPool(ctx, lbName, bp); err != nil { @@ -410,9 +410,8 @@ func (bi *backendPoolTypeNodeIP) EnsureHostsInPool(ctx context.Context, service changed bool numOfAdd, numOfDelete int activeNodes *utilsets.IgnoreCaseSet - err error ) - if bi.useMultipleStandardLoadBalancers() { + if bi.UseMultipleStandardLoadBalancers() { if !isLocalService(service) { activeNodes = bi.getActiveNodesByLoadBalancerName(lbName) } else { @@ -425,10 +424,12 @@ func (bi *backendPoolTypeNodeIP) EnsureHostsInPool(ctx context.Context, service "current load balancer", si.lbName) return nil } - activeNodes, err = bi.getLocalServiceEndpointsNodeNames(ctx, service) - if err != nil { - return err - } + activeNodes = bi.getLocalServiceEndpointsNodeNames(service) + } + + if isNICPool(backendPool) { + klog.V(4).InfoS("EnsureHostsInPool: skipping NIC-based backend pool", "backendPoolName", ptr.Deref(backendPool.Name, "")) + return nil } } @@ -462,8 +463,8 @@ func (bi *backendPoolTypeNodeIP) EnsureHostsInPool(ctx context.Context, service nodePrivateIPsSet.Insert(privateIP) } - if bi.useMultipleStandardLoadBalancers() { - if !activeNodes.Has(node.Name) { + if bi.UseMultipleStandardLoadBalancers() { + if activeNodes != nil && !activeNodes.Has(node.Name) { klog.V(4).Infof("bi.EnsureHostsInPool: node %s should not be in load balancer %q", node.Name, lbName) continue } @@ -486,7 +487,7 @@ func (bi *backendPoolTypeNodeIP) EnsureHostsInPool(ctx context.Context, service nodeIPsToBeDeleted = append(nodeIPsToBeDeleted, ip) changed = true numOfDelete++ - } else if bi.useMultipleStandardLoadBalancers() && activeNodes != nil { + } else if bi.UseMultipleStandardLoadBalancers() && activeNodes != nil { nodeName, ok := bi.nodePrivateIPToNodeNameMap[ip] if !ok { klog.Warningf("bi.EnsureHostsInPool: cannot find node name for private IP %s", ip) @@ -500,7 +501,7 @@ func (bi *backendPoolTypeNodeIP) EnsureHostsInPool(ctx context.Context, service } } } - removeNodeIPAddressesFromBackendPool(backendPool, nodeIPsToBeDeleted, false, bi.useMultipleStandardLoadBalancers()) + removeNodeIPAddressesFromBackendPool(backendPool, nodeIPsToBeDeleted, false, bi.UseMultipleStandardLoadBalancers(), true) } if changed { klog.V(2).Infof("bi.EnsureHostsInPool: updating backend pool %s of load balancer %s to add %d nodes and remove %d nodes", lbBackendPoolName, lbName, numOfAdd, numOfDelete) @@ -633,7 +634,7 @@ func (bi *backendPoolTypeNodeIP) ReconcileBackendPools(ctx context.Context, clus if isMigration && bi.EnableMigrateToIPBasedBackendPoolAPI { var backendPoolNames []string for _, id := range lbBackendPoolIDsSlice { - name, err := getLBNameFromBackendPoolID(id) + name, err := getBackendPoolNameFromBackendPoolID(id) if err != nil { klog.Errorf("bi.ReconcileBackendPools for service (%s): failed to get LB name from backend pool ID: %s", serviceName, err.Error()) return false, false, nil, err @@ -674,7 +675,7 @@ func (bi *backendPoolTypeNodeIP) ReconcileBackendPools(ctx context.Context, clus } } if len(nodeIPAddressesToBeDeleted) > 0 { - if removeNodeIPAddressesFromBackendPool(bp, nodeIPAddressesToBeDeleted, false, false) { + if removeNodeIPAddressesFromBackendPool(bp, nodeIPAddressesToBeDeleted, false, false, true) { updated = true } } @@ -871,11 +872,13 @@ func hasIPAddressInBackendPool(backendPool *network.BackendAddressPool, ipAddres func removeNodeIPAddressesFromBackendPool( backendPool network.BackendAddressPool, nodeIPAddresses []string, - removeAll, useMultipleStandardLoadBalancers bool, + removeAll, UseMultipleStandardLoadBalancers, isNodeIP bool, ) bool { changed := false nodeIPsSet := utilsets.NewString(nodeIPAddresses...) + logger := klog.Background().WithName("removeNodeIPAddressFromBackendPool") + if backendPool.BackendAddressPoolPropertiesFormat == nil || backendPool.LoadBalancerBackendAddresses == nil { return false @@ -886,7 +889,13 @@ func removeNodeIPAddressesFromBackendPool( if addresses[i].LoadBalancerBackendAddressPropertiesFormat != nil { ipAddress := ptr.Deref((*backendPool.LoadBalancerBackendAddresses)[i].IPAddress, "") if ipAddress == "" { - klog.V(4).Infof("removeNodeIPAddressFromBackendPool: LoadBalancerBackendAddress %s is not IP-based, skipping", ptr.Deref(addresses[i].Name, "")) + if isNodeIP { + logger.V(4).Info("LoadBalancerBackendAddress is not IP-based, removing", "LoadBalancerBackendAddress", ptr.Deref(addresses[i].Name, "")) + addresses = append(addresses[:i], addresses[i+1:]...) + changed = true + } else { + logger.V(4).Info("LoadBalancerBackendAddress is not IP-based, skipping", "LoadBalancerBackendAddress", ptr.Deref(addresses[i].Name, "")) + } continue } if removeAll || nodeIPsSet.Has(ipAddress) { @@ -904,7 +913,7 @@ func removeNodeIPAddressesFromBackendPool( // Allow the pool to be empty when EnsureHostsInPool for multiple standard load balancers clusters, // or one node could occur in multiple backend pools. - if len(addresses) == 0 && !useMultipleStandardLoadBalancers { + if len(addresses) == 0 && !UseMultipleStandardLoadBalancers { klog.V(2).Info("removeNodeIPAddressFromBackendPool: the pool is empty or will be empty after removing the unwanted IP addresses, skipping the removal") changed = false } else if changed { diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_healthprobe.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_healthprobe.go index ee32812940..281a8d94d9 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_healthprobe.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_healthprobe.go @@ -160,7 +160,7 @@ func (az *Cloud) buildHealthProbeRulesForPort(serviceManifest *v1.Service, port case strings.EqualFold(*protocol, string(network.ProtocolHTTPS)): //HTTPS probe is only supported in standard loadbalancer //For backward compatibility,when unsupported protocol is used, fall back to tcp protocol in basic lb mode instead - if !az.useStandardLoadBalancer() { + if !az.UseStandardLoadBalancer() { properties.Protocol = network.ProbeProtocolTCP } else { properties.Protocol = network.ProbeProtocolHTTPS diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_repo.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_repo.go index 15775bebab..9141db1ffc 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_repo.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_loadbalancer_repo.go @@ -109,7 +109,7 @@ func (az *Cloud) ListManagedLBs(ctx context.Context, service *v1.Service, nodes } } - if az.useMultipleStandardLoadBalancers() { + if az.UseMultipleStandardLoadBalancers() { for _, multiSLBConfig := range az.MultipleStandardLoadBalancerConfigurations { managedLBNames.Insert(multiSLBConfig.Name, fmt.Sprintf("%s%s", multiSLBConfig.Name, consts.InternalLoadBalancerNameSuffix)) } @@ -297,7 +297,6 @@ func (az *Cloud) MigrateToIPBasedBackendPoolAndWaitForCompletion( } return true, nil }) - if err != nil { if errors.Is(err, wait.ErrWaitTimeout) { klog.Warningf("MigrateToIPBasedBackendPoolAndWaitForCompletion: Timeout waiting for migration to IP based backend pool for lb %s, backend pool %s", lbName, strings.Join(backendPoolNames, ",")) @@ -351,7 +350,7 @@ func (az *Cloud) getAzureLoadBalancer(ctx context.Context, name string, crt azca // If not same, the lbName for existingBackendPools would also be returned. func isBackendPoolOnSameLB(newBackendPoolID string, existingBackendPools []string) (bool, string, error) { matches := backendPoolIDRE.FindStringSubmatch(newBackendPoolID) - if len(matches) != 2 { + if len(matches) != 3 { return false, "", fmt.Errorf("new backendPoolID %q is in wrong format", newBackendPoolID) } @@ -359,7 +358,7 @@ func isBackendPoolOnSameLB(newBackendPoolID string, existingBackendPools []strin newLBNameTrimmed := trimSuffixIgnoreCase(newLBName, consts.InternalLoadBalancerNameSuffix) for _, backendPool := range existingBackendPools { matches := backendPoolIDRE.FindStringSubmatch(backendPool) - if len(matches) != 2 { + if len(matches) != 3 { return false, "", fmt.Errorf("existing backendPoolID %q is in wrong format", backendPool) } @@ -380,3 +379,18 @@ func (az *Cloud) serviceOwnsRule(service *v1.Service, rule string) bool { prefix := az.getRulePrefix(service) return strings.HasPrefix(strings.ToUpper(rule), strings.ToUpper(prefix)) } + +func isNICPool(bp network.BackendAddressPool) bool { + logger := klog.Background().WithName("isNICPool").WithValues("backendPoolName", ptr.Deref(bp.Name, "")) + if bp.BackendAddressPoolPropertiesFormat != nil && + bp.LoadBalancerBackendAddresses != nil { + for _, addr := range *bp.LoadBalancerBackendAddresses { + if ptr.Deref(addr.IPAddress, "") == "" { + logger.V(4).Info("The load balancer backend address has empty ip address, assuming it is a NIC pool", + "loadBalancerBackendAddress", ptr.Deref(addr.Name, "")) + return true + } + } + } + return false +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_local_services.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_local_services.go index ce92248659..0febc94edb 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_local_services.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_local_services.go @@ -27,7 +27,6 @@ import ( v1 "k8s.io/api/core/v1" discovery_v1 "k8s.io/api/discovery/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" @@ -210,7 +209,7 @@ func (updater *loadBalancerBackendPoolUpdater) process(ctx context.Context) { lbOp := op.(*loadBalancerBackendPoolUpdateOperation) switch lbOp.kind { case consts.LoadBalancerBackendPoolUpdateOperationRemove: - removed := removeNodeIPAddressesFromBackendPool(bp, lbOp.nodeIPs, false, true) + removed := removeNodeIPAddressesFromBackendPool(bp, lbOp.nodeIPs, false, true, true) changed = changed || removed case consts.LoadBalancerBackendPoolUpdateOperationAdd: added := updater.az.addNodeIPAddressesToBackendPool(&bp, lbOp.nodeIPs) @@ -409,7 +408,7 @@ func getLocalServiceBackendPoolName(serviceName string, ipv6 bool) string { // getBackendPoolNameForService determine the expected backend pool name // by checking the external traffic policy of the service. func (az *Cloud) getBackendPoolNameForService(service *v1.Service, clusterName string, ipv6 bool) string { - if !isLocalService(service) || !az.useMultipleStandardLoadBalancers() { + if !isLocalService(service) || !az.UseMultipleStandardLoadBalancers() { return getBackendPoolName(clusterName, ipv6) } return getLocalServiceBackendPoolName(getServiceName(service), ipv6) @@ -418,7 +417,7 @@ func (az *Cloud) getBackendPoolNameForService(service *v1.Service, clusterName s // getBackendPoolNamesForService determine the expected backend pool names // by checking the external traffic policy of the service. func (az *Cloud) getBackendPoolNamesForService(service *v1.Service, clusterName string) map[bool]string { - if !isLocalService(service) || !az.useMultipleStandardLoadBalancers() { + if !isLocalService(service) || !az.UseMultipleStandardLoadBalancers() { return getBackendPoolNames(clusterName) } return map[bool]string{ @@ -430,7 +429,7 @@ func (az *Cloud) getBackendPoolNamesForService(service *v1.Service, clusterName // getBackendPoolIDsForService determine the expected backend pool IDs // by checking the external traffic policy of the service. func (az *Cloud) getBackendPoolIDsForService(service *v1.Service, clusterName, lbName string) map[bool]string { - if !isLocalService(service) || !az.useMultipleStandardLoadBalancers() { + if !isLocalService(service) || !az.UseMultipleStandardLoadBalancers() { return az.getBackendPoolIDs(clusterName, lbName) } return map[bool]string{ @@ -446,8 +445,10 @@ func (az *Cloud) getLocalServiceBackendPoolID(serviceName string, lbName string, // localServiceOwnsBackendPool checks if a backend pool is owned by a local service. func localServiceOwnsBackendPool(serviceName, bpName string) bool { - prefix := strings.Replace(serviceName, "/", "-", -1) - return strings.HasPrefix(strings.ToLower(bpName), strings.ToLower(prefix)) + if strings.HasSuffix(strings.ToLower(bpName), consts.IPVersionIPv6StringLower) { + return strings.EqualFold(getLocalServiceBackendPoolName(serviceName, true), bpName) + } + return strings.EqualFold(getLocalServiceBackendPoolName(serviceName, false), bpName) } type serviceInfo struct { @@ -463,50 +464,30 @@ func newServiceInfo(ipFamily, lbName string) *serviceInfo { } // getLocalServiceEndpointsNodeNames gets the node names that host all endpoints of the local service. -func (az *Cloud) getLocalServiceEndpointsNodeNames(ctx context.Context, service *v1.Service) (*utilsets.IgnoreCaseSet, error) { - var ( - ep *discovery_v1.EndpointSlice - foundInCache bool - ) +func (az *Cloud) getLocalServiceEndpointsNodeNames(service *v1.Service) *utilsets.IgnoreCaseSet { + var eps []*discovery_v1.EndpointSlice az.endpointSlicesCache.Range(func(_, value interface{}) bool { endpointSlice := value.(*discovery_v1.EndpointSlice) if strings.EqualFold(getServiceNameOfEndpointSlice(endpointSlice), service.Name) && strings.EqualFold(endpointSlice.Namespace, service.Namespace) { - ep = endpointSlice - foundInCache = true - return false + eps = append(eps, endpointSlice) } return true }) - if ep == nil { - klog.Infof("EndpointSlice for service %s/%s not found, try to list EndpointSlices", service.Namespace, service.Name) - eps, err := az.KubeClient.DiscoveryV1().EndpointSlices(service.Namespace).List(ctx, metav1.ListOptions{}) - if err != nil { - klog.Errorf("Failed to list EndpointSlices for service %s/%s: %s", service.Namespace, service.Name, err.Error()) - return nil, err - } - for _, endpointSlice := range eps.Items { - endpointSlice := endpointSlice - if strings.EqualFold(getServiceNameOfEndpointSlice(&endpointSlice), service.Name) { - ep = &endpointSlice - break - } - } - } - if ep == nil { - return nil, fmt.Errorf("failed to find EndpointSlice for service %s/%s", service.Namespace, service.Name) - } - if !foundInCache { - az.endpointSlicesCache.Store(strings.ToLower(fmt.Sprintf("%s/%s", ep.Namespace, ep.Name)), ep) + if len(eps) == 0 { + klog.Warningf("getLocalServiceEndpointsNodeNames: failed to find EndpointSlice for service %s/%s", service.Namespace, service.Name) + return nil } var nodeNames []string - for _, endpoint := range ep.Endpoints { - klog.V(4).Infof("EndpointSlice %s/%s has endpoint %s on node %s", ep.Namespace, ep.Name, endpoint.Addresses, ptr.Deref(endpoint.NodeName, "")) - nodeNames = append(nodeNames, ptr.Deref(endpoint.NodeName, "")) + for _, ep := range eps { + for _, endpoint := range ep.Endpoints { + klog.V(4).Infof("EndpointSlice %s/%s has endpoint %s on node %s", ep.Namespace, ep.Name, endpoint.Addresses, ptr.Deref(endpoint.NodeName, "")) + nodeNames = append(nodeNames, ptr.Deref(endpoint.NodeName, "")) + } } - return utilsets.NewString(nodeNames...), nil + return utilsets.NewString(nodeNames...) } // cleanupLocalServiceBackendPool cleans up the backend pool of @@ -548,12 +529,13 @@ func (az *Cloud) cleanupLocalServiceBackendPool( // checkAndApplyLocalServiceBackendPoolUpdates if the IPs in the backend pool are aligned // with the corresponding endpointslice, and update the backend pool if necessary. -func (az *Cloud) checkAndApplyLocalServiceBackendPoolUpdates(ctx context.Context, lb network.LoadBalancer, service *v1.Service) error { +func (az *Cloud) checkAndApplyLocalServiceBackendPoolUpdates(lb network.LoadBalancer, service *v1.Service) error { serviceName := getServiceName(service) - endpointsNodeNames, err := az.getLocalServiceEndpointsNodeNames(ctx, service) - if err != nil { - return err + endpointsNodeNames := az.getLocalServiceEndpointsNodeNames(service) + if endpointsNodeNames == nil { + return nil } + var expectedIPs []string for _, nodeName := range endpointsNodeNames.UnsortedList() { ips := az.nodePrivateIPs[strings.ToLower(nodeName)] diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_privatelinkservice.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_privatelinkservice.go index bc9a586077..a4c386268e 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_privatelinkservice.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_privatelinkservice.go @@ -49,7 +49,6 @@ func (az *Cloud) reconcilePrivateLinkService( wantPLS bool, ) error { isinternal := requiresInternalLoadBalancer(service) - pipRG := az.getPublicIPAddressResourceGroup(service) _, _, fipIPVersion := az.serviceOwnsFrontendIP(ctx, *fipConfig, service) serviceName := getServiceName(service) var isIPv6 bool @@ -57,7 +56,7 @@ func (az *Cloud) reconcilePrivateLinkService( if fipIPVersion != "" { isIPv6 = fipIPVersion == network.IPv6 } else { - if isIPv6, err = az.isFIPIPv6(service, pipRG, fipConfig); err != nil { + if isIPv6, err = az.isFIPIPv6(service, fipConfig); err != nil { klog.Errorf("reconcilePrivateLinkService for service(%s): failed to get FIP IP family: %v", serviceName, err) return err } diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_routes.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_routes.go index c32c7a3cc7..4527908ef8 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_routes.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_routes.go @@ -23,8 +23,7 @@ import ( "sync" "time" - "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network" - + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" cloudprovider "k8s.io/cloud-provider" @@ -53,7 +52,7 @@ const ( // delayedRouteOperation defines a delayed route operation which is used in delayedRouteUpdater. type delayedRouteOperation struct { - route network.Route + route *armnetwork.Route routeTableTags map[string]*string operation routeOperation result chan batchOperationResult @@ -119,24 +118,23 @@ func (d *delayedRouteUpdater) updateRoutes(ctx context.Context) { }() var ( - routeTable network.RouteTable - existsRouteTable bool + routeTable *armnetwork.RouteTable ) - routeTable, existsRouteTable, err = d.az.getRouteTable(ctx, azcache.CacheReadTypeDefault) + routeTable, err = d.az.routeTableRepo.Get(ctx, d.az.RouteTableName, azcache.CacheReadTypeDefault) if err != nil { klog.Errorf("getRouteTable() failed with error: %v", err) return } // create route table if it doesn't exists yet. - if !existsRouteTable { - err = d.az.createRouteTable() + if routeTable == nil { + err = d.az.createRouteTable(ctx) if err != nil { klog.Errorf("createRouteTable() failed with error: %v", err) return } - routeTable, _, err = d.az.getRouteTable(ctx, azcache.CacheReadTypeDefault) + routeTable, err = d.az.routeTableRepo.Get(ctx, d.az.RouteTableName, azcache.CacheReadTypeDefault) if err != nil { klog.Errorf("getRouteTable() failed with error: %v", err) return @@ -145,9 +143,9 @@ func (d *delayedRouteUpdater) updateRoutes(ctx context.Context) { // reconcile routes. dirty, onlyUpdateTags := false, true - routes := []network.Route{} - if routeTable.RouteTablePropertiesFormat != nil && routeTable.RouteTablePropertiesFormat.Routes != nil { - routes = *routeTable.Routes + var routes []*armnetwork.Route + if routeTable.Properties != nil { + routes = routeTable.Properties.Routes } routes, dirty = d.cleanupOutdatedRoutes(routes) @@ -169,10 +167,10 @@ func (d *delayedRouteUpdater) updateRoutes(ctx context.Context) { if strings.EqualFold(ptr.Deref(existingRoute.Name, ""), ptr.Deref(rt.route.Name, "")) { // delete the name-matched routes here (missing routes would be added later if the operation is add). routes = append(routes[:i], routes[i+1:]...) - if existingRoute.RoutePropertiesFormat != nil && - rt.route.RoutePropertiesFormat != nil && - strings.EqualFold(ptr.Deref(existingRoute.AddressPrefix, ""), ptr.Deref(rt.route.AddressPrefix, "")) && - strings.EqualFold(ptr.Deref(existingRoute.NextHopIPAddress, ""), ptr.Deref(rt.route.NextHopIPAddress, "")) { + if existingRoute.Properties != nil && + rt.route.Properties != nil && + strings.EqualFold(ptr.Deref(existingRoute.Properties.AddressPrefix, ""), ptr.Deref(rt.route.Properties.AddressPrefix, "")) && + strings.EqualFold(ptr.Deref(existingRoute.Properties.NextHopIPAddress, ""), ptr.Deref(rt.route.Properties.NextHopIPAddress, "")) { routeMatch = true } if rt.operation == routeOperationDelete { @@ -198,9 +196,9 @@ func (d *delayedRouteUpdater) updateRoutes(ctx context.Context) { if dirty { if !onlyUpdateTags { klog.V(2).Infof("updateRoutes: updating routes") - routeTable.Routes = &routes + routeTable.Properties.Routes = routes } - err = d.az.CreateOrUpdateRouteTable(routeTable) + _, err := d.az.routeTableRepo.CreateOrUpdate(ctx, *routeTable) if err != nil { klog.Errorf("CreateOrUpdateRouteTable() failed with error: %v", err) return @@ -213,7 +211,7 @@ func (d *delayedRouteUpdater) updateRoutes(ctx context.Context) { // cleanupOutdatedRoutes deletes all non-dualstack routes when dualstack is enabled, // and deletes all dualstack routes when dualstack is not enabled. -func (d *delayedRouteUpdater) cleanupOutdatedRoutes(existingRoutes []network.Route) (routes []network.Route, changed bool) { +func (d *delayedRouteUpdater) cleanupOutdatedRoutes(existingRoutes []*armnetwork.Route) (routes []*armnetwork.Route, changed bool) { for i := len(existingRoutes) - 1; i >= 0; i-- { existingRouteName := ptr.Deref(existingRoutes[i].Name, "") split := strings.Split(existingRouteName, consts.RouteNameSeparator) @@ -241,7 +239,7 @@ func (d *delayedRouteUpdater) cleanupOutdatedRoutes(existingRoutes []network.Rou return existingRoutes, changed } -func getAddRouteOperation(route network.Route) batchOperation { +func getAddRouteOperation(route *armnetwork.Route) batchOperation { return &delayedRouteOperation{ route: route, operation: routeOperationAdd, @@ -249,7 +247,7 @@ func getAddRouteOperation(route network.Route) batchOperation { } } -func getDeleteRouteOperation(route network.Route) batchOperation { +func getDeleteRouteOperation(route *armnetwork.Route) batchOperation { return &delayedRouteOperation{ route: route, operation: routeOperationDelete, @@ -280,8 +278,8 @@ func (d *delayedRouteUpdater) removeOperation(_ string) {} // implements cloudprovider.Routes.ListRoutes func (az *Cloud) ListRoutes(ctx context.Context, clusterName string) ([]*cloudprovider.Route, error) { klog.V(10).Infof("ListRoutes: START clusterName=%q", clusterName) - routeTable, existsRouteTable, err := az.getRouteTable(ctx, azcache.CacheReadTypeDefault) - routes, err := processRoutes(az.ipv6DualStackEnabled, routeTable, existsRouteTable, err) + routeTable, err := az.routeTableRepo.Get(ctx, az.RouteTableName, azcache.CacheReadTypeDefault) + routes, err := processRoutes(az.ipv6DualStackEnabled, routeTable, err) if err != nil { return nil, err } @@ -304,7 +302,7 @@ func (az *Cloud) ListRoutes(ctx context.Context, clusterName string) ([]*cloudpr } // ensure the route table is tagged as configured - tags, changed := az.ensureRouteTableTagged(&routeTable) + tags, changed := az.ensureRouteTableTagged(routeTable) if changed { klog.V(2).Infof("ListRoutes: updating tags on route table %s", ptr.Deref(routeTable.Name, "")) op := az.routeUpdater.addOperation(getUpdateRouteTableTagsOperation(tags)) @@ -321,20 +319,20 @@ func (az *Cloud) ListRoutes(ctx context.Context, clusterName string) ([]*cloudpr } // Injectable for testing -func processRoutes(ipv6DualStackEnabled bool, routeTable network.RouteTable, exists bool, err error) ([]*cloudprovider.Route, error) { +func processRoutes(ipv6DualStackEnabled bool, routeTable *armnetwork.RouteTable, err error) ([]*cloudprovider.Route, error) { if err != nil { return nil, err } - if !exists { + if routeTable == nil { return []*cloudprovider.Route{}, nil } var kubeRoutes []*cloudprovider.Route - if routeTable.RouteTablePropertiesFormat != nil && routeTable.Routes != nil { - kubeRoutes = make([]*cloudprovider.Route, len(*routeTable.Routes)) - for i, route := range *routeTable.Routes { + if routeTable.Properties != nil { + kubeRoutes = make([]*cloudprovider.Route, len(routeTable.Properties.Routes)) + for i, route := range routeTable.Properties.Routes { instance := MapRouteNameToNodeName(ipv6DualStackEnabled, *route.Name) - cidr := *route.AddressPrefix + cidr := *route.Properties.AddressPrefix klog.V(10).Infof("ListRoutes: * instance=%q, cidr=%q", instance, cidr) kubeRoutes[i] = &cloudprovider.Route{ @@ -349,22 +347,16 @@ func processRoutes(ipv6DualStackEnabled bool, routeTable network.RouteTable, exi return kubeRoutes, nil } -func (az *Cloud) createRouteTable() error { - routeTable := network.RouteTable{ - Name: ptr.To(az.RouteTableName), - Location: ptr.To(az.Location), - RouteTablePropertiesFormat: &network.RouteTablePropertiesFormat{}, +func (az *Cloud) createRouteTable(ctx context.Context) error { + routeTable := armnetwork.RouteTable{ + Name: ptr.To(az.RouteTableName), + Location: ptr.To(az.Location), + Properties: &armnetwork.RouteTablePropertiesFormat{}, } klog.V(3).Infof("createRouteTableIfNotExists: creating routetable. routeTableName=%q", az.RouteTableName) - err := az.CreateOrUpdateRouteTable(routeTable) - if err != nil { - return err - } - - // Invalidate the cache right after updating - _ = az.rtCache.Delete(az.RouteTableName) - return nil + _, err := az.routeTableRepo.CreateOrUpdate(ctx, routeTable) + return err } // CreateRoute creates the described managed route @@ -419,11 +411,11 @@ func (az *Cloud) CreateRoute(ctx context.Context, clusterName string, _ string, } } routeName := mapNodeNameToRouteName(az.ipv6DualStackEnabled, kubeRoute.TargetNode, kubeRoute.DestinationCIDR) - route := network.Route{ + route := &armnetwork.Route{ Name: ptr.To(routeName), - RoutePropertiesFormat: &network.RoutePropertiesFormat{ + Properties: &armnetwork.RoutePropertiesFormat{ AddressPrefix: ptr.To(kubeRoute.DestinationCIDR), - NextHopType: network.RouteNextHopTypeVirtualAppliance, + NextHopType: ptr.To(armnetwork.RouteNextHopTypeVirtualAppliance), NextHopIPAddress: ptr.To(targetIP), }, } @@ -470,9 +462,9 @@ func (az *Cloud) DeleteRoute(_ context.Context, clusterName string, kubeRoute *c routeName := mapNodeNameToRouteName(az.ipv6DualStackEnabled, kubeRoute.TargetNode, kubeRoute.DestinationCIDR) klog.V(2).Infof("DeleteRoute: deleting route. clusterName=%q instance=%q cidr=%q routeName=%q", clusterName, kubeRoute.TargetNode, kubeRoute.DestinationCIDR, routeName) - route := network.Route{ - Name: ptr.To(routeName), - RoutePropertiesFormat: &network.RoutePropertiesFormat{}, + route := &armnetwork.Route{ + Name: ptr.To(routeName), + Properties: &armnetwork.RoutePropertiesFormat{}, } op := az.routeUpdater.addOperation(getDeleteRouteOperation(route)) @@ -487,9 +479,9 @@ func (az *Cloud) DeleteRoute(_ context.Context, clusterName string, kubeRoute *c if az.ipv6DualStackEnabled { routeNameWithoutIPV6Suffix := strings.Split(routeName, consts.RouteNameSeparator)[0] klog.V(2).Infof("DeleteRoute: deleting route. clusterName=%q instance=%q cidr=%q routeName=%q", clusterName, kubeRoute.TargetNode, kubeRoute.DestinationCIDR, routeNameWithoutIPV6Suffix) - route := network.Route{ - Name: ptr.To(routeNameWithoutIPV6Suffix), - RoutePropertiesFormat: &network.RoutePropertiesFormat{}, + route := &armnetwork.Route{ + Name: ptr.To(routeNameWithoutIPV6Suffix), + Properties: &armnetwork.RoutePropertiesFormat{}, } op := az.routeUpdater.addOperation(getDeleteRouteOperation(route)) @@ -553,7 +545,7 @@ func cidrtoRfc1035(cidr string) string { } // ensureRouteTableTagged ensures the route table is tagged as configured -func (az *Cloud) ensureRouteTableTagged(rt *network.RouteTable) (map[string]*string, bool) { +func (az *Cloud) ensureRouteTableTagged(rt *armnetwork.RouteTable) (map[string]*string, bool) { if !strings.EqualFold(az.RouteTableResourceGroup, az.ResourceGroup) { return nil, false } diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_routetable_repo.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_routetable_repo.go deleted file mode 100644 index 116c9138f9..0000000000 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_routetable_repo.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2023 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package provider - -import ( - "context" - "encoding/json" - "net/http" - "strings" - "time" - - "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network" - - "k8s.io/klog/v2" - "k8s.io/utils/ptr" - - azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache" - "sigs.k8s.io/cloud-provider-azure/pkg/consts" -) - -// CreateOrUpdateRouteTable invokes az.RouteTablesClient.CreateOrUpdate with exponential backoff retry -func (az *Cloud) CreateOrUpdateRouteTable(routeTable network.RouteTable) error { - ctx, cancel := getContextWithCancel() - defer cancel() - - rerr := az.RouteTablesClient.CreateOrUpdate(ctx, az.RouteTableResourceGroup, az.RouteTableName, routeTable, ptr.Deref(routeTable.Etag, "")) - if rerr == nil { - // Invalidate the cache right after updating - _ = az.rtCache.Delete(*routeTable.Name) - return nil - } - - rtJSON, _ := json.Marshal(routeTable) - klog.Warningf("RouteTablesClient.CreateOrUpdate(%s) failed: %v, RouteTable request: %s", ptr.Deref(routeTable.Name, ""), rerr.Error(), string(rtJSON)) - - // Invalidate the cache because etag mismatch. - if rerr.HTTPStatusCode == http.StatusPreconditionFailed { - klog.V(3).Infof("Route table cache for %s is cleanup because of http.StatusPreconditionFailed", *routeTable.Name) - _ = az.rtCache.Delete(*routeTable.Name) - } - // Invalidate the cache because another new operation has canceled the current request. - if strings.Contains(strings.ToLower(rerr.Error().Error()), consts.OperationCanceledErrorMessage) { - klog.V(3).Infof("Route table cache for %s is cleanup because CreateOrUpdateRouteTable is canceled by another operation", *routeTable.Name) - _ = az.rtCache.Delete(*routeTable.Name) - } - klog.Errorf("RouteTablesClient.CreateOrUpdate(%s) failed: %v", az.RouteTableName, rerr.Error()) - return rerr.Error() -} - -func (az *Cloud) newRouteTableCache() (azcache.Resource, error) { - getter := func(ctx context.Context, key string) (interface{}, error) { - rt, err := az.RouteTablesClient.Get(ctx, az.RouteTableResourceGroup, key, "") - exists, rerr := checkResourceExistsFromError(err) - if rerr != nil { - return nil, rerr.Error() - } - - if !exists { - klog.V(2).Infof("Route table %q not found", key) - return nil, nil - } - - return &rt, nil - } - - if az.RouteTableCacheTTLInSeconds == 0 { - az.RouteTableCacheTTLInSeconds = routeTableCacheTTLDefaultInSeconds - } - return azcache.NewTimedCache(time.Duration(az.RouteTableCacheTTLInSeconds)*time.Second, getter, az.Config.DisableAPICallCache) -} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_standard.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_standard.go index fdfbd99333..79b13824c9 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_standard.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_standard.go @@ -48,7 +48,7 @@ import ( var ( errNotInVMSet = errors.New("vm is not in the vmset") providerIDRE = regexp.MustCompile(`.*/subscriptions/(?:.*)/Microsoft.Compute/virtualMachines/(.+)$`) - backendPoolIDRE = regexp.MustCompile(`^/subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Network/loadBalancers/(.+)/backendAddressPools/(?:.*)`) + backendPoolIDRE = regexp.MustCompile(`^/subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Network/loadBalancers/(.+)/backendAddressPools/(.+)`) nicResourceGroupRE = regexp.MustCompile(`.*/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Network/networkInterfaces/(?:.*)`) nicIDRE = regexp.MustCompile(`(?i)/subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Network/networkInterfaces/(.+)/ipConfigurations/(?:.*)`) vmIDRE = regexp.MustCompile(`(?i)/subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/virtualMachines/(.+)`) @@ -694,7 +694,7 @@ func (as *availabilitySet) getAgentPoolAvailabilitySets(vms []compute.VirtualMac // annotation would be ignored when using one SLB per cluster. func (as *availabilitySet) GetVMSetNames(ctx context.Context, service *v1.Service, nodes []*v1.Node) (availabilitySetNames *[]string, err error) { hasMode, isAuto, serviceAvailabilitySetName := as.getServiceLoadBalancerMode(service) - if !hasMode || as.useStandardLoadBalancer() { + if !hasMode || as.UseStandardLoadBalancer() { // no mode specified in service annotation or use single SLB mode // default to PrimaryAvailabilitySetName availabilitySetNames = &[]string{as.Config.PrimaryAvailabilitySetName} @@ -825,7 +825,7 @@ func (as *availabilitySet) getPrimaryInterfaceWithVMSet(ctx context.Context, nod // don't check vmSet for it. // - For multiple standard SKU load balancers, the behavior is similar to the basic LB. needCheck := false - if !as.useStandardLoadBalancer() { + if !as.UseStandardLoadBalancer() { // need to check the vmSet name when using the basic LB needCheck = true } @@ -904,7 +904,7 @@ func (as *availabilitySet) EnsureHostInPool(ctx context.Context, service *v1.Ser } } if !foundPool { - if as.useStandardLoadBalancer() && len(newBackendPools) > 0 { + if as.UseStandardLoadBalancer() && len(newBackendPools) > 0 { // Although standard load balancer supports backends from multiple availability // sets, the same network interface couldn't be added to more than one load balancer of // the same type. Omit those nodes (e.g. masters) so Azure ARM won't complain @@ -954,7 +954,7 @@ func (as *availabilitySet) EnsureHostsInPool(ctx context.Context, service *v1.Se hostUpdates := make([]func() error, 0, len(nodes)) for _, node := range nodes { localNodeName := node.Name - if as.useStandardLoadBalancer() && as.excludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { + if as.UseStandardLoadBalancer() && as.ExcludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { klog.V(4).Infof("Excluding master node %q from load balancer backendpool %q", localNodeName, backendPoolID) continue } diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_storageaccount.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_storageaccount.go index fa9341bc00..bd4bcf9ef5 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_storageaccount.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_storageaccount.go @@ -87,6 +87,8 @@ type AccountOptions struct { SoftDeleteContainers int32 // indicate whether to get a random matching account, if false, will get the first matching account PickRandomMatchingAccount bool + // provide the source account name in snapshot restore and volume clone scenarios + SourceAccountName string } type accountWithLocation struct { @@ -341,6 +343,15 @@ func (az *Cloud) EnsureStorageAccount(ctx context.Context, accountOptions *Accou } accountName = accounts[index].Name createNewAccount = false + if accountOptions.SourceAccountName != "" { + for _, acct := range accounts { + if acct.Name == accountOptions.SourceAccountName { + klog.V(2).Infof("found a matching account %s type %s location %s with source account name", acct.Name, acct.StorageType, acct.Location) + accountName = acct.Name + break + } + } + } klog.V(4).Infof("found a matching account %s type %s location %s", accounts[index].Name, accounts[index].StorageType, accounts[index].Location) } } diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_utils.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_utils.go index 65fef0f218..c81e314673 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_utils.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_utils.go @@ -438,9 +438,12 @@ func getResourceByIPFamily(resource string, isDualStack, isIPv6 bool) string { // isFIPIPv6 checks if the frontend IP configuration is of IPv6. // NOTICE: isFIPIPv6 assumes the FIP is owned by the Service and it is the primary Service. -func (az *Cloud) isFIPIPv6(service *v1.Service, _ string, fip *network.FrontendIPConfiguration) (bool, error) { +func (az *Cloud) isFIPIPv6(service *v1.Service, fip *network.FrontendIPConfiguration) (bool, error) { isDualStack := isServiceDualStack(service) if !isDualStack { + if len(service.Spec.IPFamilies) == 0 { + return false, nil + } return service.Spec.IPFamilies[0] == v1.IPv6Protocol, nil } return managedResourceHasIPv6Suffix(ptr.Deref(fip.Name, "")), nil @@ -455,13 +458,13 @@ func getResourceIDPrefix(id string) string { return id[:idx] } -func getLBNameFromBackendPoolID(backendPoolID string) (string, error) { +func getBackendPoolNameFromBackendPoolID(backendPoolID string) (string, error) { matches := backendPoolIDRE.FindStringSubmatch(backendPoolID) - if len(matches) != 2 { + if len(matches) != 3 { return "", fmt.Errorf("backendPoolID %q is in wrong format", backendPoolID) } - return matches[1], nil + return matches[2], nil } func countNICsOnBackendPool(backendPool network.BackendAddressPool) int { diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmsets_repo.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmsets_repo.go index ec7106c954..00c13e6a66 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmsets_repo.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmsets_repo.go @@ -19,13 +19,10 @@ package provider import ( "context" "errors" - "fmt" "strings" "time" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-08-01/compute" - "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network" - "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" cloudprovider "k8s.io/cloud-provider" @@ -171,20 +168,3 @@ func (az *Cloud) getVirtualMachine(ctx context.Context, nodeName types.NodeName, return *(cachedVM.(*compute.VirtualMachine)), nil } - -func (az *Cloud) getRouteTable(ctx context.Context, crt azcache.AzureCacheReadType) (routeTable network.RouteTable, exists bool, err error) { - if len(az.RouteTableName) == 0 { - return routeTable, false, fmt.Errorf("route table name is not configured") - } - - cachedRt, err := az.rtCache.GetWithDeepCopy(ctx, az.RouteTableName, crt) - if err != nil { - return routeTable, false, err - } - - if cachedRt == nil { - return routeTable, false, nil - } - - return *(cachedRt.(*network.RouteTable)), true, nil -} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmss.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmss.go index 10be642012..0db63e3e14 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmss.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmss.go @@ -872,7 +872,7 @@ func (ss *ScaleSet) getAgentPoolScaleSets(ctx context.Context, nodes []*v1.Node) // for loadbalancer exists then return the eligible VMSet. func (ss *ScaleSet) GetVMSetNames(ctx context.Context, service *v1.Service, nodes []*v1.Node) (*[]string, error) { hasMode, isAuto, serviceVMSetName := ss.getServiceLoadBalancerMode(service) - if !hasMode || ss.useStandardLoadBalancer() { + if !hasMode || ss.UseStandardLoadBalancer() { // no mode specified in service annotation or use single SLB mode // default to PrimaryScaleSetName scaleSetNames := &[]string{ss.Config.PrimaryScaleSetName} @@ -1069,7 +1069,7 @@ func (ss *ScaleSet) EnsureHostInPool(ctx context.Context, _ *v1.Service, nodeNam // don't check vmSet for it. // - For multiple standard SKU load balancers, the behavior is similar to the basic load balancer needCheck := false - if !ss.useStandardLoadBalancer() { + if !ss.UseStandardLoadBalancer() { // need to check the vmSet name when using the basic LB needCheck = true } @@ -1115,7 +1115,7 @@ func (ss *ScaleSet) EnsureHostInPool(ctx context.Context, _ *v1.Service, nodeNam return "", "", "", nil, nil } - if ss.useStandardLoadBalancer() && len(newBackendPools) > 0 { + if ss.UseStandardLoadBalancer() && len(newBackendPools) > 0 { // Although standard load balancer supports backends from multiple scale // sets, the same network interface couldn't be added to more than one load balancer of // the same type. Omit those nodes (e.g. masters) so Azure ARM won't complain @@ -1183,9 +1183,9 @@ func (ss *ScaleSet) ensureVMSSInPool(ctx context.Context, _ *v1.Service, nodes [ // the single standard load balancer supports multiple vmss in its backend while // multiple standard load balancers and the basic load balancer doesn't - if ss.useStandardLoadBalancer() { + if ss.UseStandardLoadBalancer() { for _, node := range nodes { - if ss.excludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { + if ss.ExcludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { continue } @@ -1282,7 +1282,7 @@ func (ss *ScaleSet) ensureVMSSInPool(ctx context.Context, _ *v1.Service, nodes [ continue } - if ss.useStandardLoadBalancer() && len(loadBalancerBackendAddressPools) > 0 { + if ss.UseStandardLoadBalancer() && len(loadBalancerBackendAddressPools) > 0 { // Although standard load balancer supports backends from multiple scale // sets, the same network interface couldn't be added to more than one load balancer of // the same type. Omit those nodes (e.g. masters) so Azure ARM won't complain @@ -1377,13 +1377,20 @@ func (ss *ScaleSet) ensureHostsInPool(ctx context.Context, service *v1.Service, mc.ObserveOperationWithResult(isOperationSucceeded) }() + // Ensure the backendPoolID is also added on VMSS itself. + // Refer to issue kubernetes/kubernetes#80365 for detailed information + err := ss.ensureVMSSInPool(ctx, service, nodes, backendPoolID, vmSetNameOfLB) + if err != nil { + return err + } + hostUpdates := make([]func() error, 0, len(nodes)) nodeUpdates := make(map[vmssMetaInfo]map[string]compute.VirtualMachineScaleSetVM) errors := make([]error, 0) for _, node := range nodes { localNodeName := node.Name - if ss.useStandardLoadBalancer() && ss.excludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { + if ss.UseStandardLoadBalancer() && ss.ExcludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { klog.V(4).Infof("Excluding master node %q from load balancer backendpool %q", localNodeName, backendPoolID) continue } @@ -1467,13 +1474,6 @@ func (ss *ScaleSet) ensureHostsInPool(ctx context.Context, service *v1.Service, return utilerrors.Flatten(utilerrors.NewAggregate(errors)) } - // Ensure the backendPoolID is also added on VMSS itself. - // Refer to issue kubernetes/kubernetes#80365 for detailed information - err := ss.ensureVMSSInPool(ctx, service, nodes, backendPoolID, vmSetNameOfLB) - if err != nil { - return err - } - isOperationSucceeded = true return nil } @@ -1491,7 +1491,7 @@ func (ss *ScaleSet) EnsureHostsInPool(ctx context.Context, service *v1.Service, for _, node := range nodes { localNodeName := node.Name - if ss.useStandardLoadBalancer() && ss.excludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { + if ss.UseStandardLoadBalancer() && ss.ExcludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { klog.V(4).Infof("Excluding master node %q from load balancer backendpool %q", localNodeName, backendPoolID) continue } @@ -1516,7 +1516,7 @@ func (ss *ScaleSet) EnsureHostsInPool(ctx context.Context, service *v1.Service, if vmManagementType == ManagedByAvSet { // vm is managed by availability set. // VMAS nodes should also be added to the SLB backends. - if ss.useStandardLoadBalancer() { + if ss.UseStandardLoadBalancer() { vmasNodes = append(vmasNodes, node) continue } @@ -1525,7 +1525,7 @@ func (ss *ScaleSet) EnsureHostsInPool(ctx context.Context, service *v1.Service, } if vmManagementType == ManagedByVmssFlex { // vm is managed by vmss flex. - if ss.useStandardLoadBalancer() { + if ss.UseStandardLoadBalancer() { vmssFlexNodes = append(vmssFlexNodes, node) continue } @@ -1674,7 +1674,7 @@ func getScaleSetAndResourceGroupNameByIPConfigurationID(ipConfigurationID string } func (ss *ScaleSet) ensureBackendPoolDeletedFromVMSS(ctx context.Context, backendPoolIDs []string, vmSetName string) error { - if !ss.useStandardLoadBalancer() { + if !ss.UseStandardLoadBalancer() { found := false cachedUniform, err := ss.vmssCache.Get(ctx, consts.VMSSKey, azcache.CacheReadTypeDefault) @@ -1733,7 +1733,7 @@ func (ss *ScaleSet) ensureBackendPoolDeletedFromVMSS(ctx context.Context, backen func (ss *ScaleSet) ensureBackendPoolDeletedFromVmssUniform(ctx context.Context, backendPoolIDs []string, vmSetName string) error { vmssNamesMap := make(map[string]bool) // the standard load balancer supports multiple vmss in its backend while the basic sku doesn't - if ss.useStandardLoadBalancer() { + if ss.UseStandardLoadBalancer() { cachedUniform, err := ss.vmssCache.Get(ctx, consts.VMSSKey, azcache.CacheReadTypeDefault) if err != nil { klog.Errorf("ensureBackendPoolDeletedFromVMSS: failed to get vmss uniform from cache: %v", err) @@ -1860,7 +1860,7 @@ func (ss *ScaleSet) ensureBackendPoolDeleted(ctx context.Context, service *v1.Se var err error if scaleSetName, err = extractScaleSetNameByProviderID(ipConfigurationID); err == nil { // Only remove nodes belonging to specified vmSet to basic LB backends. - if !ss.useStandardLoadBalancer() && !strings.EqualFold(scaleSetName, vmSetName) { + if !ss.UseStandardLoadBalancer() && !strings.EqualFold(scaleSetName, vmSetName) { continue } } @@ -1967,7 +1967,9 @@ func (ss *ScaleSet) EnsureBackendPoolDeleted(ctx context.Context, service *v1.Se for _, backendPool := range *backendAddressPools { for _, backendPoolID := range backendPoolIDs { - if strings.EqualFold(*backendPool.ID, backendPoolID) && backendPool.BackendIPConfigurations != nil { + if strings.EqualFold(*backendPool.ID, backendPoolID) && + backendPool.BackendAddressPoolPropertiesFormat != nil && + backendPool.BackendIPConfigurations != nil { for _, ipConf := range *backendPool.BackendIPConfigurations { if ipConf.ID == nil { continue @@ -2311,7 +2313,7 @@ func (ss *ScaleSet) VMSSBatchSize(ctx context.Context, vmssName string) (int, er return 0, fmt.Errorf("get vmss batch size: %w", err) } if _, ok := vmss.Tags[consts.VMSSTagForBatchOperation]; ok { - batchSize = ss.getPutVMSSVMBatchSize() + batchSize = ss.GetPutVMSSVMBatchSize() } klog.V(2).InfoS("Fetch VMSS batch size", "vmss", vmssName, "size", batchSize) return batchSize, nil diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmssflex.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmssflex.go index d2b779768a..662eded7be 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmssflex.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_vmssflex.go @@ -135,7 +135,7 @@ func (fs *FlexScaleSet) GetAgentPoolVMSetNames(ctx context.Context, nodes []*v1. // annotation would be ignored when using one SLB per cluster. func (fs *FlexScaleSet) GetVMSetNames(ctx context.Context, service *v1.Service, nodes []*v1.Node) (*[]string, error) { hasMode, isAuto, serviceVMSetName := fs.getServiceLoadBalancerMode(service) - if !hasMode || fs.useStandardLoadBalancer() { + if !hasMode || fs.UseStandardLoadBalancer() { // no mode specified in service annotation or use single SLB mode // default to PrimaryScaleSetName vmssFlexNames := &[]string{fs.Config.PrimaryScaleSetName} @@ -459,7 +459,7 @@ func (fs *FlexScaleSet) EnsureHostInPool(ctx context.Context, service *v1.Servic // don't check vmSet for it. // - For multiple standard SKU load balancers, return nil if the node's scale set is mismatched with vmSetNameOfLB needCheck := false - if !fs.useStandardLoadBalancer() { + if !fs.UseStandardLoadBalancer() { return "", "", "", nil, fmt.Errorf("EnsureHostInPool: VMSS Flex does not support Basic Load Balancer") } if vmSetNameOfLB != "" && needCheck && !strings.EqualFold(vmSetNameOfLB, vmssFlexName) { @@ -508,7 +508,7 @@ func (fs *FlexScaleSet) EnsureHostInPool(ctx context.Context, service *v1.Servic return "", "", "", nil, nil } - if fs.useStandardLoadBalancer() && len(newBackendPools) > 0 { + if fs.UseStandardLoadBalancer() && len(newBackendPools) > 0 { // Although standard load balancer supports backends from multiple availability // sets, the same network interface couldn't be added to more than one load balancer of // the same type. Omit those nodes (e.g. masters) so Azure ARM won't complain @@ -556,15 +556,15 @@ func (fs *FlexScaleSet) ensureVMSSFlexInPool(ctx context.Context, _ *v1.Service, klog.V(2).Infof("ensureVMSSFlexInPool: ensuring VMSS Flex with backendPoolID %s", backendPoolID) vmssFlexIDsMap := make(map[string]bool) - if !fs.useStandardLoadBalancer() { + if !fs.UseStandardLoadBalancer() { return fmt.Errorf("ensureVMSSFlexInPool: VMSS Flex does not support Basic Load Balancer") } // the single standard load balancer supports multiple vmss in its backend while // multiple standard load balancers doesn't - if fs.useStandardLoadBalancer() { + if fs.UseStandardLoadBalancer() { for _, node := range nodes { - if fs.excludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { + if fs.ExcludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { continue } @@ -649,7 +649,7 @@ func (fs *FlexScaleSet) ensureVMSSFlexInPool(ctx context.Context, _ *v1.Service, continue } - if fs.useStandardLoadBalancer() && len(loadBalancerBackendAddressPools) > 0 { + if fs.UseStandardLoadBalancer() && len(loadBalancerBackendAddressPools) > 0 { // Although standard load balancer supports backends from multiple scale // sets, the same network interface couldn't be added to more than one load balancer of // the same type. Omit those nodes (e.g. masters) so Azure ARM won't complain @@ -710,11 +710,16 @@ func (fs *FlexScaleSet) EnsureHostsInPool(ctx context.Context, service *v1.Servi defer func() { mc.ObserveOperationWithResult(isOperationSucceeded) }() - hostUpdates := make([]func() error, 0, len(nodes)) + err := fs.ensureVMSSFlexInPool(ctx, service, nodes, backendPoolID, vmSetNameOfLB) + if err != nil { + return err + } + + hostUpdates := make([]func() error, 0, len(nodes)) for _, node := range nodes { localNodeName := node.Name - if fs.useStandardLoadBalancer() && fs.excludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { + if fs.UseStandardLoadBalancer() && fs.ExcludeMasterNodesFromStandardLB() && isControlPlaneNode(node) { klog.V(4).Infof("Excluding master node %q from load balancer backendpool %q", localNodeName, backendPoolID) continue } @@ -744,18 +749,13 @@ func (fs *FlexScaleSet) EnsureHostsInPool(ctx context.Context, service *v1.Servi return utilerrors.Flatten(errs) } - err := fs.ensureVMSSFlexInPool(ctx, service, nodes, backendPoolID, vmSetNameOfLB) - if err != nil { - return err - } - isOperationSucceeded = true return nil } func (fs *FlexScaleSet) ensureBackendPoolDeletedFromVmssFlex(ctx context.Context, backendPoolIDs []string, vmSetName string) error { vmssNamesMap := make(map[string]bool) - if fs.useStandardLoadBalancer() { + if fs.UseStandardLoadBalancer() { cached, err := fs.vmssFlexCache.Get(ctx, consts.VmssFlexKey, azcache.CacheReadTypeDefault) if err != nil { klog.Errorf("ensureBackendPoolDeletedFromVmssFlex: failed to get vmss flex from cache: %v", err) @@ -904,7 +904,7 @@ func (fs *FlexScaleSet) EnsureBackendPoolDeleted(ctx context.Context, service *v } // only vmsses in the resource group same as it's in azure config are included if strings.EqualFold(resourceGroupName, fs.ResourceGroup) { - if fs.useStandardLoadBalancer() { + if fs.UseStandardLoadBalancer() { vmssFlexVMNameMap[nodeName] = nicName } else { if strings.EqualFold(vmssFlexName, vmSetName) { diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_wrap.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_wrap.go index d599ddbd22..054fd24faf 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_wrap.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_wrap.go @@ -29,7 +29,6 @@ import ( var ( vmCacheTTLDefaultInSeconds = 60 loadBalancerCacheTTLDefaultInSeconds = 120 - routeTableCacheTTLDefaultInSeconds = 120 publicIPCacheTTLDefaultInSeconds = 120 azureNodeProviderIDRE = regexp.MustCompile(`^azure:///subscriptions/(?:.*)/resourceGroups/(?:.*)/providers/Microsoft.Compute/(?:.*)`) @@ -51,22 +50,6 @@ func checkResourceExistsFromError(err *retry.Error) (bool, *retry.Error) { return false, err } -func (az *Cloud) useStandardLoadBalancer() bool { - return strings.EqualFold(az.LoadBalancerSku, consts.LoadBalancerSkuStandard) -} - -func (az *Cloud) excludeMasterNodesFromStandardLB() bool { - return az.ExcludeMasterFromStandardLB != nil && *az.ExcludeMasterFromStandardLB -} - -func (az *Cloud) disableLoadBalancerOutboundSNAT() bool { - if !az.useStandardLoadBalancer() || az.DisableOutboundSNAT == nil { - return false - } - - return *az.DisableOutboundSNAT -} - // IsNodeUnmanaged returns true if the node is not managed by Azure cloud provider. // Those nodes includes on-prem or VMs from other clouds. They will not be added to load balancer // backends. Azure routes and managed disks are also not supported for them. diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_zones.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_zones.go index 8e05dd9443..b5f0306138 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_zones.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/azure_zones.go @@ -73,7 +73,7 @@ func (az *Cloud) updateRegionZonesMap(zones map[string][]string) { } func (az *Cloud) getRegionZonesBackoff(ctx context.Context, region string) ([]string, error) { - if az.isStackCloud() { + if az.IsStackCloud() { // Azure Stack does not support zone at the moment // https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-network-differences?view=azs-2102 klog.V(3).Infof("getRegionZonesMapWrapper: Azure Stack does not support Zones at the moment, skipping") diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure.go new file mode 100644 index 0000000000..c643234da7 --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure.go @@ -0,0 +1,216 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +import ( + "strings" + + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader" + "sigs.k8s.io/cloud-provider-azure/pkg/consts" +) + +// Config holds the configuration parsed from the --cloud-config flag +// All fields are required unless otherwise specified +// NOTE: Cloud config files should follow the same Kubernetes deprecation policy as +// flags or CLIs. Config fields should not change behavior in incompatible ways and +// should be deprecated for at least 2 release prior to removing. +// See https://kubernetes.io/docs/reference/using-api/deprecation-policy/#deprecating-a-flag-or-cli +// for more details. +type Config struct { + AzureClientConfig `json:",inline" yaml:",inline"` + + // The cloud configure type for Azure cloud provider. Supported values are file, secret and merge. + CloudConfigType configloader.CloudConfigType `json:"cloudConfigType,omitempty" yaml:"cloudConfigType,omitempty"` + + // The name of the resource group that the cluster is deployed in + ResourceGroup string `json:"resourceGroup,omitempty" yaml:"resourceGroup,omitempty"` + // The location of the resource group that the cluster is deployed in + Location string `json:"location,omitempty" yaml:"location,omitempty"` + // The name of site where the cluster will be deployed to that is more granular than the region specified by the "location" field. + // Currently only public ip, load balancer and managed disks support this. + ExtendedLocationName string `json:"extendedLocationName,omitempty" yaml:"extendedLocationName,omitempty"` + // The type of site that is being targeted. + // Currently only public ip, load balancer and managed disks support this. + ExtendedLocationType string `json:"extendedLocationType,omitempty" yaml:"extendedLocationType,omitempty"` + // The name of the VNet that the cluster is deployed in + VnetName string `json:"vnetName,omitempty" yaml:"vnetName,omitempty"` + // The name of the resource group that the Vnet is deployed in + VnetResourceGroup string `json:"vnetResourceGroup,omitempty" yaml:"vnetResourceGroup,omitempty"` + // The name of the subnet that the cluster is deployed in + SubnetName string `json:"subnetName,omitempty" yaml:"subnetName,omitempty"` + // The name of the security group attached to the cluster's subnet + SecurityGroupName string `json:"securityGroupName,omitempty" yaml:"securityGroupName,omitempty"` + // The name of the resource group that the security group is deployed in + SecurityGroupResourceGroup string `json:"securityGroupResourceGroup,omitempty" yaml:"securityGroupResourceGroup,omitempty"` + // (Optional in 1.6) The name of the route table attached to the subnet that the cluster is deployed in + RouteTableName string `json:"routeTableName,omitempty" yaml:"routeTableName,omitempty"` + // The name of the resource group that the RouteTable is deployed in + RouteTableResourceGroup string `json:"routeTableResourceGroup,omitempty" yaml:"routeTableResourceGroup,omitempty"` + // (Optional) The name of the availability set that should be used as the load balancer backend + // If this is set, the Azure cloudprovider will only add nodes from that availability set to the load + // balancer backend pool. If this is not set, and multiple agent pools (availability sets) are used, then + // the cloudprovider will try to add all nodes to a single backend pool which is forbidden. + // In other words, if you use multiple agent pools (availability sets), you MUST set this field. + PrimaryAvailabilitySetName string `json:"primaryAvailabilitySetName,omitempty" yaml:"primaryAvailabilitySetName,omitempty"` + // The type of azure nodes. Candidate values are: vmss, standard and vmssflex. + // If not set, it will be default to vmss. + VMType string `json:"vmType,omitempty" yaml:"vmType,omitempty"` + // The name of the scale set that should be used as the load balancer backend. + // If this is set, the Azure cloudprovider will only add nodes from that scale set to the load + // balancer backend pool. If this is not set, and multiple agent pools (scale sets) are used, then + // the cloudprovider will try to add all nodes to a single backend pool which is forbidden in the basic sku. + // In other words, if you use multiple agent pools (scale sets), and loadBalancerSku is set to basic, you MUST set this field. + PrimaryScaleSetName string `json:"primaryScaleSetName,omitempty" yaml:"primaryScaleSetName,omitempty"` + // Tags determines what tags shall be applied to the shared resources managed by controller manager, which + // includes load balancer, security group and route table. The supported format is `a=b,c=d,...`. After updated + // this config, the old tags would be replaced by the new ones. + // Because special characters are not supported in "tags" configuration, "tags" support would be removed in a future release, + // please consider migrating the config to "tagsMap". + Tags string `json:"tags,omitempty" yaml:"tags,omitempty"` + // TagsMap is similar to Tags but holds tags with special characters such as `=` and `,`. + TagsMap map[string]string `json:"tagsMap,omitempty" yaml:"tagsMap,omitempty"` + // SystemTags determines the tag keys managed by cloud provider. If it is not set, no tags would be deleted if + // the `Tags` is changed. However, the old tags would be deleted if they are neither included in `Tags` nor + // in `SystemTags` after the update of `Tags`. + SystemTags string `json:"systemTags,omitempty" yaml:"systemTags,omitempty"` + // Sku of Load Balancer and Public IP. Candidate values are: basic and standard. + // If not set, it will be default to basic. + LoadBalancerSku string `json:"loadBalancerSku,omitempty" yaml:"loadBalancerSku,omitempty"` + // LoadBalancerName determines the specific name of the load balancer user want to use, working with + // LoadBalancerResourceGroup + LoadBalancerName string `json:"loadBalancerName,omitempty" yaml:"loadBalancerName,omitempty"` + // LoadBalancerResourceGroup determines the specific resource group of the load balancer user want to use, working + // with LoadBalancerName + LoadBalancerResourceGroup string `json:"loadBalancerResourceGroup,omitempty" yaml:"loadBalancerResourceGroup,omitempty"` + // PreConfiguredBackendPoolLoadBalancerTypes determines whether the LoadBalancer BackendPool has been preconfigured. + // Candidate values are: + // "": exactly with today (not pre-configured for any LBs) + // "internal": for internal LoadBalancer + // "external": for external LoadBalancer + // "all": for both internal and external LoadBalancer + PreConfiguredBackendPoolLoadBalancerTypes string `json:"preConfiguredBackendPoolLoadBalancerTypes,omitempty" yaml:"preConfiguredBackendPoolLoadBalancerTypes,omitempty"` + + // DisableAvailabilitySetNodes disables VMAS nodes support when "VMType" is set to "vmss". + DisableAvailabilitySetNodes bool `json:"disableAvailabilitySetNodes,omitempty" yaml:"disableAvailabilitySetNodes,omitempty"` + // EnableVmssFlexNodes enables vmss flex nodes support when "VMType" is set to "vmss". + EnableVmssFlexNodes bool `json:"enableVmssFlexNodes,omitempty" yaml:"enableVmssFlexNodes,omitempty"` + // DisableAzureStackCloud disables AzureStackCloud support. It should be used + // when setting AzureAuthConfig.Cloud with "AZURESTACKCLOUD" to customize ARM endpoints + // while the cluster is not running on AzureStack. + DisableAzureStackCloud bool `json:"disableAzureStackCloud,omitempty" yaml:"disableAzureStackCloud,omitempty"` + // Use instance metadata service where possible + UseInstanceMetadata bool `json:"useInstanceMetadata,omitempty" yaml:"useInstanceMetadata,omitempty"` + + // Backoff exponent + CloudProviderBackoffExponent float64 `json:"cloudProviderBackoffExponent,omitempty" yaml:"cloudProviderBackoffExponent,omitempty"` + // Backoff jitter + CloudProviderBackoffJitter float64 `json:"cloudProviderBackoffJitter,omitempty" yaml:"cloudProviderBackoffJitter,omitempty"` + + // ExcludeMasterFromStandardLB excludes master nodes from standard load balancer. + // If not set, it will be default to true. + ExcludeMasterFromStandardLB *bool `json:"excludeMasterFromStandardLB,omitempty" yaml:"excludeMasterFromStandardLB,omitempty"` + // DisableOutboundSNAT disables the outbound SNAT for public load balancer rules. + // It should only be set when loadBalancerSku is standard. If not set, it will be default to false. + DisableOutboundSNAT *bool `json:"disableOutboundSNAT,omitempty" yaml:"disableOutboundSNAT,omitempty"` + + // Maximum allowed LoadBalancer Rule Count is the limit enforced by Azure Load balancer + MaximumLoadBalancerRuleCount int `json:"maximumLoadBalancerRuleCount,omitempty" yaml:"maximumLoadBalancerRuleCount,omitempty"` + + // LoadBalancerBackendPoolConfigurationType defines how vms join the load balancer backend pools. Supported values + // are `nodeIPConfiguration`, `nodeIP` and `podIP`. + // `nodeIPConfiguration`: vm network interfaces will be attached to the inbound backend pool of the load balancer (default); + // `nodeIP`: vm private IPs will be attached to the inbound backend pool of the load balancer; + // `podIP`: pod IPs will be attached to the inbound backend pool of the load balancer (not supported yet). + LoadBalancerBackendPoolConfigurationType string `json:"loadBalancerBackendPoolConfigurationType,omitempty" yaml:"loadBalancerBackendPoolConfigurationType,omitempty"` + // PutVMSSVMBatchSize defines how many requests the client send concurrently when putting the VMSS VMs. + // If it is smaller than or equal to zero, the request will be sent one by one in sequence (default). + PutVMSSVMBatchSize int `json:"putVMSSVMBatchSize" yaml:"putVMSSVMBatchSize"` + // PrivateLinkServiceResourceGroup determines the specific resource group of the private link services user want to use + PrivateLinkServiceResourceGroup string `json:"privateLinkServiceResourceGroup,omitempty" yaml:"privateLinkServiceResourceGroup,omitempty"` + + // EnableMigrateToIPBasedBackendPoolAPI uses the migration API to migrate from NIC-based to IP-based backend pool. + // The migration API can provide a migration from NIC-based to IP-based backend pool without service downtime. + // If the API is not used, the migration will be done by decoupling all nodes on the backend pool and then re-attaching + // node IPs, which will introduce service downtime. The downtime increases with the number of nodes in the backend pool. + EnableMigrateToIPBasedBackendPoolAPI bool `json:"enableMigrateToIPBasedBackendPoolAPI" yaml:"enableMigrateToIPBasedBackendPoolAPI"` + + // MultipleStandardLoadBalancerConfigurations stores the properties regarding multiple standard load balancers. + // It will be ignored if LoadBalancerBackendPoolConfigurationType is nodeIPConfiguration. + // If the length is not 0, it is assumed the multiple standard load balancers mode is on. In this case, + // there must be one configuration named "" or an error will be reported. + MultipleStandardLoadBalancerConfigurations []MultipleStandardLoadBalancerConfiguration `json:"multipleStandardLoadBalancerConfigurations,omitempty" yaml:"multipleStandardLoadBalancerConfigurations,omitempty"` + + // RouteUpdateIntervalInSeconds is the interval for updating routes. Default is 30 seconds. + RouteUpdateIntervalInSeconds int `json:"routeUpdateIntervalInSeconds,omitempty" yaml:"routeUpdateIntervalInSeconds,omitempty"` + // LoadBalancerBackendPoolUpdateIntervalInSeconds is the interval for updating load balancer backend pool of local services. Default is 30 seconds. + LoadBalancerBackendPoolUpdateIntervalInSeconds int `json:"loadBalancerBackendPoolUpdateIntervalInSeconds,omitempty" yaml:"loadBalancerBackendPoolUpdateIntervalInSeconds,omitempty"` + + // ClusterServiceLoadBalancerHealthProbeMode determines the health probe mode for cluster service load balancer. + // Supported values are `shared` and `servicenodeport`. + // `servicenodeport`: the health probe will be created against each port of each service by watching the backend application (default). + // `shared`: all cluster services shares one HTTP probe targeting the kube-proxy on the node (/healthz:10256). + ClusterServiceLoadBalancerHealthProbeMode string `json:"clusterServiceLoadBalancerHealthProbeMode,omitempty" yaml:"clusterServiceLoadBalancerHealthProbeMode,omitempty"` + // ClusterServiceSharedLoadBalancerHealthProbePort defines the target port of the shared health probe. Default to 10256. + ClusterServiceSharedLoadBalancerHealthProbePort int32 `json:"clusterServiceSharedLoadBalancerHealthProbePort,omitempty" yaml:"clusterServiceSharedLoadBalancerHealthProbePort,omitempty"` + // ClusterServiceSharedLoadBalancerHealthProbePath defines the target path of the shared health probe. Default to `/healthz`. + ClusterServiceSharedLoadBalancerHealthProbePath string `json:"clusterServiceSharedLoadBalancerHealthProbePath,omitempty" yaml:"clusterServiceSharedLoadBalancerHealthProbePath,omitempty"` +} + +// HasExtendedLocation returns true if extendedlocation prop are specified. +func (az *Config) HasExtendedLocation() bool { + return az.ExtendedLocationName != "" && az.ExtendedLocationType != "" +} + +func (az *Config) IsLBBackendPoolTypeNodeIPConfig() bool { + return strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypeNodeIPConfiguration) +} + +func (az *Config) IsLBBackendPoolTypeNodeIP() bool { + return strings.EqualFold(az.LoadBalancerBackendPoolConfigurationType, consts.LoadBalancerBackendPoolConfigurationTypeNodeIP) +} + +func (az *Config) GetPutVMSSVMBatchSize() int { + return az.PutVMSSVMBatchSize +} + +func (az *Config) UseStandardLoadBalancer() bool { + return strings.EqualFold(az.LoadBalancerSku, consts.LoadBalancerSkuStandard) +} + +func (az *Config) ExcludeMasterNodesFromStandardLB() bool { + return az.ExcludeMasterFromStandardLB != nil && *az.ExcludeMasterFromStandardLB +} + +func (az *Config) DisableLoadBalancerOutboundSNAT() bool { + if !az.UseStandardLoadBalancer() || az.DisableOutboundSNAT == nil { + return false + } + + return *az.DisableOutboundSNAT +} + +func (az *Config) UseMultipleStandardLoadBalancers() bool { + return az.UseStandardLoadBalancer() && len(az.MultipleStandardLoadBalancerConfigurations) > 0 +} + +func (az *Config) UseSingleStandardLoadBalancer() bool { + return az.UseStandardLoadBalancer() && len(az.MultipleStandardLoadBalancerConfigurations) == 0 +} + +func (az *Config) IsStackCloud() bool { + return strings.EqualFold(az.Cloud, consts.AzureStackCloudName) && !az.DisableAzureStackCloud +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure_auth.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure_auth.go index 84858ba975..8ad090e0cb 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure_auth.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure_auth.go @@ -47,10 +47,16 @@ const ( maxReadLength = 10 * 1 << 20 // 10MB ) -// AzureAuthConfig holds auth related part of cloud config -type AzureAuthConfig struct { - azclient.ARMClientConfig `json:",inline" yaml:",inline"` - azclient.AzureAuthConfig `json:",inline" yaml:",inline"` +// AzureClientConfig holds azure client related part of cloud config +type AzureClientConfig struct { + azclient.ARMClientConfig `json:",inline" yaml:",inline"` + azclient.AzureAuthConfig `json:",inline" yaml:",inline"` + CloudProviderRateLimitConfig `json:",inline" yaml:",inline"` + CloudProviderCacheConfig `json:",inline" yaml:",inline"` + // Backoff retry limit + CloudProviderBackoffRetries int `json:"cloudProviderBackoffRetries,omitempty" yaml:"cloudProviderBackoffRetries,omitempty"` + // Backoff duration + CloudProviderBackoffDuration int `json:"cloudProviderBackoffDuration,omitempty" yaml:"cloudProviderBackoffDuration,omitempty"` // The ID of the Azure Subscription that the cluster is deployed in SubscriptionID string `json:"subscriptionId,omitempty" yaml:"subscriptionId,omitempty"` @@ -70,7 +76,7 @@ type AzureAuthConfig struct { // If NetworkResourceTenantID and NetworkResourceSubscriptionID are specified to have different values than TenantID and SubscriptionID, network resources are deployed in different AAD Tenant and Subscription than those for the cluster, // than only azure clients except VM/VMSS and network resource ones use this method to fetch Token. // For tokens for VM/VMSS and network resource ones, please check GetMultiTenantServicePrincipalToken and GetNetworkResourceServicePrincipalToken. -func GetServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment, resource string) (*adal.ServicePrincipalToken, error) { +func GetServicePrincipalToken(config *AzureClientConfig, env *azure.Environment, resource string) (*adal.ServicePrincipalToken, error) { logger := klog.Background().WithName("GetServicePrincipalToken") var tenantID string if strings.EqualFold(config.IdentitySystem, consts.ADFSIdentitySystem) { @@ -179,7 +185,7 @@ func GetServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment, r // PrimaryToken of the returned multi-tenant token is for the AAD Tenant specified by TenantID, and AuxiliaryToken of the returned multi-tenant token is for the AAD Tenant specified by NetworkResourceTenantID. // // Azure VM/VMSS clients use this multi-tenant token, in order to operate those VM/VMSS in AAD Tenant specified by TenantID, and meanwhile in their payload they are referencing network resources (e.g. Load Balancer, Network Security Group, etc.) in AAD Tenant specified by NetworkResourceTenantID. -func GetMultiTenantServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment, authProvider *azclient.AuthProvider) (adal.MultitenantOAuthTokenProvider, error) { +func GetMultiTenantServicePrincipalToken(config *AzureClientConfig, env *azure.Environment, authProvider *azclient.AuthProvider) (adal.MultitenantOAuthTokenProvider, error) { logger := klog.Background().WithName("GetMultiTenantServicePrincipalToken") err := config.ValidateForMultiTenant() @@ -241,7 +247,7 @@ func GetMultiTenantServicePrincipalToken(config *AzureAuthConfig, env *azure.Env // and this method creates a new service principal token for network resources tenant based on the configuration. // // Azure network resource (Load Balancer, Public IP, Route Table, Network Security Group and their sub level resources) clients use this multi-tenant token, in order to operate resources in AAD Tenant specified by NetworkResourceTenantID. -func GetNetworkResourceServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment, authProvider *azclient.AuthProvider) (adal.OAuthTokenProvider, error) { +func GetNetworkResourceServicePrincipalToken(config *AzureClientConfig, env *azure.Environment, authProvider *azclient.AuthProvider) (adal.OAuthTokenProvider, error) { logger := klog.Background().WithName("GetNetworkResourceServicePrincipalToken") err := config.ValidateForMultiTenant() @@ -320,8 +326,8 @@ func ParseAzureEnvironment(cloudName, resourceManagerEndpoint, identitySystem st } // ParseAzureAuthConfig returns a parsed configuration for an Azure cloudprovider config file -func ParseAzureAuthConfig(configReader io.Reader) (*AzureAuthConfig, *azure.Environment, error) { - var config AzureAuthConfig +func ParseAzureAuthConfig(configReader io.Reader) (*AzureClientConfig, *azure.Environment, error) { + var config AzureClientConfig if configReader == nil { return nil, nil, errors.New("nil config is provided") @@ -351,14 +357,14 @@ func ParseAzureAuthConfig(configReader io.Reader) (*AzureAuthConfig, *azure.Envi // UsesNetworkResourceInDifferentTenant determines whether the AzureAuthConfig indicates to use network resources in // different AAD Tenant than those for the cluster. Return true when NetworkResourceTenantID is specified and not equal // to one defined in global configs -func (config *AzureAuthConfig) UsesNetworkResourceInDifferentTenant() bool { +func (config *AzureClientConfig) UsesNetworkResourceInDifferentTenant() bool { return len(config.NetworkResourceTenantID) > 0 && !strings.EqualFold(config.NetworkResourceTenantID, config.TenantID) } // UsesNetworkResourceInDifferentSubscription determines whether the AzureAuthConfig indicates to use network resources // in different Subscription than those for the cluster. Return true when NetworkResourceSubscriptionID is specified // and not equal to one defined in global configs -func (config *AzureAuthConfig) UsesNetworkResourceInDifferentSubscription() bool { +func (config *AzureClientConfig) UsesNetworkResourceInDifferentSubscription() bool { return len(config.NetworkResourceSubscriptionID) > 0 && !strings.EqualFold(config.NetworkResourceSubscriptionID, config.SubscriptionID) } @@ -375,7 +381,7 @@ func azureStackOverrides(env *azure.Environment, resourceManagerEndpoint, identi } // ValidateForMultiTenant checks configuration for the scenario of using network resource in different tenant -func (config *AzureAuthConfig) ValidateForMultiTenant() error { +func (config *AzureClientConfig) ValidateForMultiTenant() error { if !config.UsesNetworkResourceInDifferentTenant() { return fmt.Errorf("NetworkResourceTenantID must be configured") } diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure_cache.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure_cache.go new file mode 100644 index 0000000000..68d150d093 --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/azure_cache.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +type CloudProviderCacheConfig struct { + // DisableAPICallCache disables the cache for Azure API calls. It is for ARG support and not all resources will be disabled. + DisableAPICallCache bool `json:"disableAPICallCache,omitempty" yaml:"disableAPICallCache,omitempty"` + // NonVmssUniformNodesCacheTTLInSeconds sets the Cache TTL for NonVmssUniformNodesCacheTTLInSeconds + // if not set, will use default value + NonVmssUniformNodesCacheTTLInSeconds int `json:"nonVmssUniformNodesCacheTTLInSeconds,omitempty" yaml:"nonVmssUniformNodesCacheTTLInSeconds,omitempty"` + // VmssCacheTTLInSeconds sets the cache TTL for VMSS + VmssCacheTTLInSeconds int `json:"vmssCacheTTLInSeconds,omitempty" yaml:"vmssCacheTTLInSeconds,omitempty"` + // VmssVirtualMachinesCacheTTLInSeconds sets the cache TTL for vmssVirtualMachines + VmssVirtualMachinesCacheTTLInSeconds int `json:"vmssVirtualMachinesCacheTTLInSeconds,omitempty" yaml:"vmssVirtualMachinesCacheTTLInSeconds,omitempty"` + + // VmssFlexCacheTTLInSeconds sets the cache TTL for VMSS Flex + VmssFlexCacheTTLInSeconds int `json:"vmssFlexCacheTTLInSeconds,omitempty" yaml:"vmssFlexCacheTTLInSeconds,omitempty"` + // VmssFlexVMCacheTTLInSeconds sets the cache TTL for vmss flex vms + VmssFlexVMCacheTTLInSeconds int `json:"vmssFlexVMCacheTTLInSeconds,omitempty" yaml:"vmssFlexVMCacheTTLInSeconds,omitempty"` + + // VmCacheTTLInSeconds sets the cache TTL for vm + VMCacheTTLInSeconds int `json:"vmCacheTTLInSeconds,omitempty" yaml:"vmCacheTTLInSeconds,omitempty"` + // LoadBalancerCacheTTLInSeconds sets the cache TTL for load balancer + LoadBalancerCacheTTLInSeconds int `json:"loadBalancerCacheTTLInSeconds,omitempty" yaml:"loadBalancerCacheTTLInSeconds,omitempty"` + // NsgCacheTTLInSeconds sets the cache TTL for network security group + NsgCacheTTLInSeconds int `json:"nsgCacheTTLInSeconds,omitempty" yaml:"nsgCacheTTLInSeconds,omitempty"` + // RouteTableCacheTTLInSeconds sets the cache TTL for route table + RouteTableCacheTTLInSeconds int `json:"routeTableCacheTTLInSeconds,omitempty" yaml:"routeTableCacheTTLInSeconds,omitempty"` + // PlsCacheTTLInSeconds sets the cache TTL for private link service resource + PlsCacheTTLInSeconds int `json:"plsCacheTTLInSeconds,omitempty" yaml:"plsCacheTTLInSeconds,omitempty"` + // AvailabilitySetsCacheTTLInSeconds sets the cache TTL for VMAS + AvailabilitySetsCacheTTLInSeconds int `json:"availabilitySetsCacheTTLInSeconds,omitempty" yaml:"availabilitySetsCacheTTLInSeconds,omitempty"` + // PublicIPCacheTTLInSeconds sets the cache TTL for public ip + PublicIPCacheTTLInSeconds int `json:"publicIPCacheTTLInSeconds,omitempty" yaml:"publicIPCacheTTLInSeconds,omitempty"` + // RouteUpdateWaitingInSeconds is the delay time for waiting route updates to take effect. This waiting delay is added + // because the routes are not taken effect when the async route updating operation returns success. Default is 30 seconds. + RouteUpdateWaitingInSeconds int `json:"routeUpdateWaitingInSeconds,omitempty" yaml:"routeUpdateWaitingInSeconds,omitempty"` +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/env.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/env.go new file mode 100644 index 0000000000..e57f3d6f2d --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/env.go @@ -0,0 +1,60 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +import ( + "io" + "os" + "strings" + + "sigs.k8s.io/yaml" +) + +// ParseConfig returns a parsed configuration for an Azure cloudprovider config file +func ParseConfig(configReader io.Reader) (*Config, error) { + var config Config + if configReader == nil { + return nil, nil + } + + configContents, err := io.ReadAll(configReader) + if err != nil { + return nil, err + } + + err = yaml.Unmarshal(configContents, &config) + if err != nil { + return nil, err + } + + // The resource group name may be in different cases from different Azure APIs, hence it is converted to lower here. + // See more context at https://github.com/kubernetes/kubernetes/issues/71994. + config.ResourceGroup = strings.ToLower(config.ResourceGroup) + + // these environment variables are injected by workload identity webhook + if tenantID := os.Getenv("AZURE_TENANT_ID"); tenantID != "" { + config.TenantID = tenantID + } + if clientID := os.Getenv("AZURE_CLIENT_ID"); clientID != "" { + config.AADClientID = clientID + } + if federatedTokenFile := os.Getenv("AZURE_FEDERATED_TOKEN_FILE"); federatedTokenFile != "" { + config.AADFederatedTokenFile = federatedTokenFile + config.UseFederatedWorkloadIdentityExtension = true + } + return &config, nil +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/multi_slb.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/multi_slb.go new file mode 100644 index 0000000000..079d4afb15 --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/config/multi_slb.go @@ -0,0 +1,73 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + utilsets "sigs.k8s.io/cloud-provider-azure/pkg/util/sets" +) + +// MultipleStandardLoadBalancerConfiguration stores the properties regarding multiple standard load balancers. +type MultipleStandardLoadBalancerConfiguration struct { + // Name of the public load balancer. There will be an internal load balancer + // created if needed, and the name will be `-internal`. The internal lb + // shares the same configurations as the external one. The internal lbs + // are not needed to be included in `MultipleStandardLoadBalancerConfigurations`. + // There must be a name of "" in the load balancer configuration list. + Name string `json:"name" yaml:"name"` + + MultipleStandardLoadBalancerConfigurationSpec + + MultipleStandardLoadBalancerConfigurationStatus +} + +// MultipleStandardLoadBalancerConfigurationSpec stores the properties regarding multiple standard load balancers. +type MultipleStandardLoadBalancerConfigurationSpec struct { + // This load balancer can have services placed on it. Defaults to true, + // can be set to false to drain and eventually remove a load balancer. + // This only affects services that will be using the LB. For services + // that is currently using the LB, they will not be affected. + AllowServicePlacement *bool `json:"allowServicePlacement" yaml:"allowServicePlacement"` + + // A string value that must specify the name of an existing vmSet. + // All nodes in the given vmSet will always be added to this load balancer. + // A vmSet can only be the primary vmSet for a single load balancer. + PrimaryVMSet string `json:"primaryVMSet" yaml:"primaryVMSet"` + + // Services that must match this selector can be placed on this load balancer. If not supplied, + // services with any labels can be created on the load balancer. + ServiceLabelSelector *metav1.LabelSelector `json:"serviceLabelSelector" yaml:"serviceLabelSelector"` + + // Services created in namespaces with the supplied label will be allowed to select that load balancer. + // If not supplied, services created in any namespaces can be created on that load balancer. + ServiceNamespaceSelector *metav1.LabelSelector `json:"serviceNamespaceSelector" yaml:"serviceNamespaceSelector"` + + // Nodes matching this selector will be preferentially added to the load balancers that + // they match selectors for. NodeSelector does not override primaryAgentPool for node allocation. + NodeSelector *metav1.LabelSelector `json:"nodeSelector" yaml:"nodeSelector"` +} + +// MultipleStandardLoadBalancerConfigurationStatus stores the properties regarding multiple standard load balancers. +type MultipleStandardLoadBalancerConfigurationStatus struct { + // ActiveServices stores the services that are supposed to use the load balancer. + ActiveServices *utilsets.IgnoreCaseSet `json:"activeServices" yaml:"activeServices"` + + // ActiveNodes stores the nodes that are supposed to be in the load balancer. + // It will be used in EnsureHostsInPool to make sure the given ones are in the backend pool. + ActiveNodes *utilsets.IgnoreCaseSet `json:"activeNodes" yaml:"activeNodes"` +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/cache.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/cache.go new file mode 100644 index 0000000000..96927a51c6 --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/cache.go @@ -0,0 +1,55 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package routetable + +import ( + "context" + "time" + + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/routetableclient" + "sigs.k8s.io/cloud-provider-azure/pkg/cache" + "sigs.k8s.io/cloud-provider-azure/pkg/util/errutils" +) + +const ( + DefaultCacheTTL = 120 * time.Second +) + +func NewCache( + client routetableclient.Interface, + resourceGroup string, + cacheTTL time.Duration, + disableAPICallCache bool, +) (cache.Resource, error) { + getter := func(ctx context.Context, key string) (interface{}, error) { + rt, err := client.Get(ctx, resourceGroup, key) + found, err := errutils.CheckResourceExistsFromAzcoreError(err) + if err != nil { + return nil, err + } + if !found { + return nil, nil + } + + return rt, nil + } + + if cacheTTL == 0 { + cacheTTL = DefaultCacheTTL + } + return cache.NewTimedCache(cacheTTL, getter, disableAPICallCache) +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/mock_repo.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/mock_repo.go new file mode 100644 index 0000000000..76988b62cd --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/mock_repo.go @@ -0,0 +1,88 @@ +// /* +// Copyright The Kubernetes Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// */ +// + +// Code generated by MockGen. DO NOT EDIT. +// Source: repo.go +// +// Generated by this command: +// +// mockgen -destination=./mock_repo.go -package=routetable -copyright_file ../../../hack/boilerplate/boilerplate.generatego.txt -source=repo.go Repository +// +// Package routetable is a generated GoMock package. +package routetable + +import ( + context "context" + reflect "reflect" + + armnetwork "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6" + gomock "go.uber.org/mock/gomock" + cache "sigs.k8s.io/cloud-provider-azure/pkg/cache" +) + +// MockRepository is a mock of Repository interface. +type MockRepository struct { + ctrl *gomock.Controller + recorder *MockRepositoryMockRecorder +} + +// MockRepositoryMockRecorder is the mock recorder for MockRepository. +type MockRepositoryMockRecorder struct { + mock *MockRepository +} + +// NewMockRepository creates a new mock instance. +func NewMockRepository(ctrl *gomock.Controller) *MockRepository { + mock := &MockRepository{ctrl: ctrl} + mock.recorder = &MockRepositoryMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockRepository) EXPECT() *MockRepositoryMockRecorder { + return m.recorder +} + +// CreateOrUpdate mocks base method. +func (m *MockRepository) CreateOrUpdate(ctx context.Context, routeTable armnetwork.RouteTable) (*armnetwork.RouteTable, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateOrUpdate", ctx, routeTable) + ret0, _ := ret[0].(*armnetwork.RouteTable) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateOrUpdate indicates an expected call of CreateOrUpdate. +func (mr *MockRepositoryMockRecorder) CreateOrUpdate(ctx, routeTable any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdate", reflect.TypeOf((*MockRepository)(nil).CreateOrUpdate), ctx, routeTable) +} + +// Get mocks base method. +func (m *MockRepository) Get(ctx context.Context, routeTableName string, crt cache.AzureCacheReadType) (*armnetwork.RouteTable, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Get", ctx, routeTableName, crt) + ret0, _ := ret[0].(*armnetwork.RouteTable) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockRepositoryMockRecorder) Get(ctx, routeTableName, crt any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockRepository)(nil).Get), ctx, routeTableName, crt) +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/repo.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/repo.go new file mode 100644 index 0000000000..fb5400df1b --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/provider/routetable/repo.go @@ -0,0 +1,87 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package routetable + +import ( + "context" + "fmt" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v6" + + "sigs.k8s.io/cloud-provider-azure/pkg/azclient/routetableclient" + "sigs.k8s.io/cloud-provider-azure/pkg/cache" +) + +// Generate mocks for the repository interface +//go:generate mockgen -destination=./mock_repo.go -package=routetable -copyright_file ../../../hack/boilerplate/boilerplate.generatego.txt -source=repo.go Repository + +var ( + ErrMissingRouteTableName = fmt.Errorf("missing RouteTable name") +) + +type Repository interface { + Get(ctx context.Context, routeTableName string, crt cache.AzureCacheReadType) (*armnetwork.RouteTable, error) + CreateOrUpdate(ctx context.Context, routeTable armnetwork.RouteTable) (*armnetwork.RouteTable, error) +} + +type repo struct { + resourceGroup string + client routetableclient.Interface + cache cache.Resource +} + +func NewRepo( + client routetableclient.Interface, + resourceGroup string, + cacheTTL time.Duration, + disableAPICallCache bool, +) (Repository, error) { + c, err := NewCache(client, resourceGroup, cacheTTL, disableAPICallCache) + if err != nil { + return nil, fmt.Errorf("new RouteTable cache: %w", err) + } + + return &repo{ + resourceGroup: resourceGroup, + client: client, + cache: c, + }, nil +} + +func (r *repo) Get(ctx context.Context, routeTableName string, crt cache.AzureCacheReadType) (*armnetwork.RouteTable, error) { + rt, err := r.cache.GetWithDeepCopy(ctx, routeTableName, crt) + if err != nil { + return nil, fmt.Errorf("get RouteTable: %w", err) + } + + return rt.(*armnetwork.RouteTable), nil +} + +func (r *repo) CreateOrUpdate(ctx context.Context, routeTable armnetwork.RouteTable) (*armnetwork.RouteTable, error) { + if routeTable.Name == nil { + return nil, ErrMissingRouteTableName + } + + rv, err := r.client.CreateOrUpdate(ctx, r.resourceGroup, *routeTable.Name, routeTable) + if err != nil { + return nil, fmt.Errorf("create or update RouteTable: %w", err) + } + _ = r.cache.Delete(*routeTable.Name) + + return rv, nil +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/collectionutil/map.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/collectionutil/map.go index 0d55042f58..d214844920 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/collectionutil/map.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/collectionutil/map.go @@ -16,6 +16,14 @@ limitations under the License. package fnutil +func Keys[K comparable, V any](m map[K]V) []K { + rv := make([]K, 0, len(m)) + for k := range m { + rv = append(rv, k) + } + return rv +} + func Values[K comparable, V any](m map[K]V) []V { rv := make([]V, 0, len(m)) for _, v := range m { diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/bits.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/bits.go new file mode 100644 index 0000000000..dbad47343d --- /dev/null +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/bits.go @@ -0,0 +1,37 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package iputil + +// setBitAt sets the bit at the i-th position in the byte slice to the given value. +// Panics if the index is out of bounds. +// For example, +// - setBitAt([0x00, 0x00], 8, 1) returns [0x00, 0b1000_0000]. +// - setBitAt([0xff, 0xff], 0, 0) returns [0b0111_1111, 0xff]. +func setBitAt(bytes []byte, i int, bit uint8) { + if bit == 1 { + bytes[i/8] |= 1 << (7 - i%8) + } else { + bytes[i/8] &^= 1 << (7 - i%8) + } +} + +// bitAt returns the bit at the i-th position in the byte slice. +// The return value is either 0 or 1 as uint8. +// Panics if the index is out of bounds. +func bitAt(bytes []byte, i int) uint8 { + return bytes[i/8] >> (7 - i%8) & 1 +} diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix.go index 77395c37a8..2c4a8e0298 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix.go @@ -17,8 +17,10 @@ limitations under the License. package iputil import ( + "bytes" "fmt" "net/netip" + "sort" ) // IsPrefixesAllowAll returns true if one of the prefixes allows all addresses. @@ -61,9 +63,108 @@ func GroupPrefixesByFamily(vs []netip.Prefix) ([]netip.Prefix, []netip.Prefix) { return v4, v6 } -// AggregatePrefixes aggregates prefixes. -// Overlapping prefixes are merged. +// ContainsPrefix checks if prefix p fully contains prefix o. +// It returns true if o is a subset of p, meaning all addresses in o are also in p. +// This is true when p overlaps with o and p has fewer or equal number of bits than o. +func ContainsPrefix(p netip.Prefix, o netip.Prefix) bool { + return p.Bits() <= o.Bits() && p.Overlaps(o) +} + +// mergeAdjacentPrefixes attempts to merge two adjacent prefixes into a single prefix. +// It returns the merged prefix and a boolean indicating success. +// Note: This function only merges adjacent prefixes, not overlapping ones. +func mergeAdjacentPrefixes(p1, p2 netip.Prefix) (netip.Prefix, bool) { + // Merge neighboring prefixes if possible + if p1.Bits() != p2.Bits() || p1.Bits() == 0 { + return netip.Prefix{}, false + } + + var ( + bits = p1.Bits() + p1Bytes = p1.Addr().AsSlice() + p2Bytes = p2.Addr().AsSlice() + ) + if bitAt(p1Bytes, bits-1) == 0 { + setBitAt(p1Bytes, bits-1, 1) + } else { + setBitAt(p2Bytes, bits-1, 1) + } + if !bytes.Equal(p1Bytes, p2Bytes) { + return netip.Prefix{}, false + } + + rv, _ := p1.Addr().Prefix(bits - 1) + return rv, true +} + +// aggregatePrefixesForSingleIPFamily merges overlapping or adjacent prefixes into a single prefix. +// The input prefixes must be the same IP family (IPv4 or IPv6). +// For example, +// - [192.168.0.0/32, 192.168.0.1/32] -> [192.168.0.0/31] (adjacent) +// - [192.168.0.0/24, 192.168.0.1/32] -> [192.168.1.0/24] (overlapping) +func aggregatePrefixesForSingleIPFamily(prefixes []netip.Prefix) []netip.Prefix { + if len(prefixes) <= 1 { + return prefixes + } + + sort.Slice(prefixes, func(i, j int) bool { + addrCmp := prefixes[i].Addr().Compare(prefixes[j].Addr()) + if addrCmp == 0 { + return prefixes[i].Bits() < prefixes[j].Bits() + } + return addrCmp < 0 + }) + + var rv = []netip.Prefix{prefixes[0]} + + for i := 1; i < len(prefixes); i++ { + last, p := rv[len(rv)-1], prefixes[i] + if ContainsPrefix(last, p) { + // Skip overlapping prefixes + continue + } + rv = append(rv, p) + + // Merge adjacent prefixes if possible + for len(rv) >= 2 { + // Merge the last two prefixes if they are adjacent + p, ok := mergeAdjacentPrefixes(rv[len(rv)-2], rv[len(rv)-1]) + if !ok { + break + } + + // Replace the last two prefixes with the merged prefix + rv = rv[:len(rv)-2] + rv = append(rv, p) + } + } + return rv +} + +// AggregatePrefixes merges overlapping or adjacent prefixes into a single prefix. +// It combines prefixes that can be represented by a larger, more inclusive prefix. +// +// Examples: +// - Adjacent: [192.168.0.0/32, 192.168.0.1/32] -> [192.168.0.0/31] +// - Overlapping: [192.168.0.0/24, 192.168.0.1/32] -> [192.168.0.0/24] func AggregatePrefixes(prefixes []netip.Prefix) []netip.Prefix { + var ( + v4, v6 = GroupPrefixesByFamily(prefixes) + ) + + return append(aggregatePrefixesForSingleIPFamily(v4), aggregatePrefixesForSingleIPFamily(v6)...) +} + +// AggregatePrefixesWithPrefixTree merges overlapping or adjacent prefixes into a single prefix. +// +// This function uses a prefix tree to aggregate the input prefixes. While it achieves +// the same result as AggregatePrefixes, it is less efficient. For better performance, +// use AggregatePrefixes instead. +// +// Examples: +// - Adjacent: [192.168.0.0/32, 192.168.0.1/32] -> [192.168.0.0/31] +// - Overlapping: [192.168.0.0/24, 192.168.0.1/32] -> [192.168.0.0/24] +func AggregatePrefixesWithPrefixTree(prefixes []netip.Prefix) []netip.Prefix { var ( v4, v6 = GroupPrefixesByFamily(prefixes) v4Tree = newPrefixTreeForIPv4() diff --git a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix_tree.go b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix_tree.go index 2399c09ebd..a7515b42fe 100644 --- a/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix_tree.go +++ b/vendor/sigs.k8s.io/cloud-provider-azure/pkg/util/iputil/prefix_tree.go @@ -29,10 +29,26 @@ type prefixTreeNode struct { r *prefixTreeNode // right child node } -// pruneToRoot prunes the tree to the root. -// If a node's left and right children are both masked, -// it is masked and its children are pruned. -// This is done recursively up to the root. +// pruneToRoot checks if the current node and its sibling are masked, +// and if so, marks their parent as masked and removes both children. +// This process is repeated up the tree until a node with an unmasked sibling is found. +// +// The process can be visualized as follows: +// +// Before: After: +// P P (masked) +// / \ / \ +// A B -> X X +// (M) (M) +// +// Where: +// +// P: Parent node +// A, B: Child nodes +// M: Masked +// X: Removed +// +// This method helps to optimize the tree structure by condensing fully masked subtrees. func (n *prefixTreeNode) pruneToRoot() { var node = n for node.p != nil { @@ -49,6 +65,31 @@ func (n *prefixTreeNode) pruneToRoot() { } } +// prefixTree represents a tree structure for storing and managing IP prefixes. +// It efficiently handles prefix aggregation, merging of overlapping prefixes, +// and collapsing of neighboring prefixes. +// +// The tree is structured as follows: +// - Each node represents a bit in the IP address +// - Left child represents a 0 bit, right child represents a 1 bit +// - Masked nodes indicate the end of a prefix +// - Unused branches are represented by nil pointers +// +// Example tree for 128.0.0.0/4 (binary 1000 0000): +// +// 0 (0.0.0.0/0) +// / \ +// X 1 (128.0.0.0/1) +// / \ +// 0 X +// / \ +// 0 X +// / \ +// 0* X +// +// Where: +// * denotes a masked node (prefix end) +// X denotes an unused branch (nil pointer) type prefixTree struct { maxBits int root *prefixTreeNode