From c3679c209226135c4dbd1e04fc0abd8b332de41a Mon Sep 17 00:00:00 2001 From: Britania Rodriguez Reyes Date: Fri, 1 Nov 2024 15:15:49 -0500 Subject: [PATCH] address comments --- charts/member-agent/README.md | 73 +++- charts/member-agent/values.yaml | 4 + cmd/memberagent/main.go | 16 +- go.mod | 25 +- go.sum | 64 ---- .../azure/cloudconfig/config.go | 155 -------- .../azure/cloudconfig/config_test.go | 348 ------------------ .../test/azure_invalid_config.yaml | 1 - .../cloudconfig/test/azure_valid_config.yaml | 12 - pkg/propertyprovider/azure/provider.go | 12 +- pkg/propertyprovider/azure/suite_test.go | 6 +- pkg/scheduler/queue/queue.go | 2 +- pkg/utils/controller/controller.go | 2 +- 13 files changed, 75 insertions(+), 645 deletions(-) delete mode 100644 pkg/propertyprovider/azure/cloudconfig/config.go delete mode 100644 pkg/propertyprovider/azure/cloudconfig/config_test.go delete mode 100644 pkg/propertyprovider/azure/cloudconfig/test/azure_invalid_config.yaml delete mode 100644 pkg/propertyprovider/azure/cloudconfig/test/azure_valid_config.yaml diff --git a/charts/member-agent/README.md b/charts/member-agent/README.md index e1a1d69a5..9d81083e5 100644 --- a/charts/member-agent/README.md +++ b/charts/member-agent/README.md @@ -29,18 +29,65 @@ helm upgrade member-agent member-agent/ --namespace fleet-system ## Parameters -| Parameter | Description | Default | -|:-------------------------|:------------------------------------------------------|:------------------------------------------------| -| replicaCount | The number of member-agent replicas to deploy | `1` | -| image.repository | Image repository | `ghcr.io/azure/azure/fleet/member-agent` | -| image.pullPolicy | Image pullPolicy | `IfNotPresent` | -| image.tag | The image tag to use | `v0.1.0` | -| affinity | The node affinity to use for pod scheduling | `{}` | -| tolerations | The toleration to use for pod scheduling | `[]` | -| resources | The resource request/limits for the container image | limits: "2" CPU, 4Gi, requests: 100m CPU, 128Mi | -| namespace | Namespace that this Helm chart is installed on. | `fleet-system` | -| logVerbosity | Log level. Uses V logs (klog) | `3` | -| propertyProvider | The property provider to use with the member agent; if none is specified, the Fleet member agent will start with no property provider (i.e., the agent will expose no cluster properties, and collect only limited resource usage information) | `` | -| region | The region where the member cluster resides | `` | +| Parameter | Description | Default | +|:-------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------| +| replicaCount | The number of member-agent replicas to deploy | `1` | +| image.repository | Image repository | `ghcr.io/azure/azure/fleet/member-agent` | +| image.pullPolicy | Image pullPolicy | `IfNotPresent` | +| image.tag | The image tag to use | `v0.1.0` | +| affinity | The node affinity to use for pod scheduling | `{}` | +| tolerations | The toleration to use for pod scheduling | `[]` | +| resources | The resource request/limits for the container image | limits: "2" CPU, 4Gi, requests: 100m CPU, 128Mi | +| namespace | Namespace that this Helm chart is installed on. | `fleet-system` | +| logVerbosity | Log level. Uses V logs (klog) | `3` | +| propertyProvider | The property provider to use with the member agent; if none is specified, the Fleet member agent will start with no property provider (i.e., the agent will expose no cluster properties, and collect only limited resource usage information) | `` | +| region | The region where the member cluster resides | `` | +| config.cloudConfig | The cloud provider configuration | **required if property provider is enabled** | + +## Override Azure cloud config + +**If PropertyProvider feature is enabled, then a cloud configuration is required.** +Cloud configuration provides resource metadata and credentials for `fleet-member-agent` to manipulate Azure resources. +It's embedded into a Kubernetes secret and mounted to the pods. +The values can be modified under `config.cloudConfig` section in values.yaml or can be provided as a separate file. + + +| configuration value | description | Remark | +|-------------------------------------------------------| --- |---------------------------------------------------------------------------| +| `cloud` | The cloud where resources belong. | Required. | +| `tenantId` | The AAD Tenant ID for the subscription where the Azure resources are deployed. | | +| `subscriptionId` | The ID of the subscription where resources are deployed. | | +| `useManagedIdentityExtension` | Boolean indicating whether or not to use a managed identity. | `true` or `false` | +| `userAssignedIdentityID` | ClientID of the user-assigned managed identity with RBAC access to resources. | Required for UserAssignedIdentity and omitted for SystemAssignedIdentity. | +| `aadClientId` | The ClientID for an AAD application with RBAC access to resources. | Required if `useManagedIdentityExtension` is set to `false`. | +| `aadClientSecret` | The ClientSecret for an AAD application with RBAC access to resources. | Required if `useManagedIdentityExtension` is set to `false`. | +| `resourceGroup` | The name of the resource group where cluster resources are deployed. | | +| `userAgent` | The userAgent provided when accessing resources. | | +| `location` | The region where resource group and its resources is deployed. | | +| `clusterName` | The name of the cluster where the agent is running. | | +| `clusterResourceGroup` | The resource group where the cluster is deployed. | | +| `vnetName` | The name of the virtual network where the cluster is deployed. | | +| `vnetResourceGroup` | The resource group where the virtual network is deployed. | | + +You can create a file `azure.yaml` with the following content, and pass it to `helm install` command: `helm install -f azure.yaml` + +```yaml +config: + cloudConfig: + cloud: "AzurePublicCloud" + tenantId: "00000000-0000-0000-0000-000000000000" + subscriptionId: "00000000-0000-0000-0000-000000000000" + useManagedIdentityExtension: false + userAssignedIdentityID: "00000000-0000-0000-0000-000000000000" + aadClientId: "00000000-0000-0000-0000-000000000000" + aadClientSecret: "" + userAgent: "fleet-member-agent" + resourceGroup: "" + location: "" + clusterName: "" + clusterResourceGroup: "" + vnetName: "" + vnetResourceGroup: "" +``` ## Contributing Changes diff --git a/charts/member-agent/values.yaml b/charts/member-agent/values.yaml index a4d35ba0d..72e155596 100644 --- a/charts/member-agent/values.yaml +++ b/charts/member-agent/values.yaml @@ -40,6 +40,10 @@ config: tenantId: "" subscriptionId: "" useManagedIdentityExtension: false + userAssignedIdentityID: "" + aadClientId: "" + aadClientSecret: "" + resourceGroup: "" userAgent: "" location: "" vnetName: "" diff --git a/cmd/memberagent/main.go b/cmd/memberagent/main.go index 5d5dec0da..5dbf7bfc5 100644 --- a/cmd/memberagent/main.go +++ b/cmd/memberagent/main.go @@ -21,7 +21,6 @@ import ( "time" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" utilrand "k8s.io/apimachinery/pkg/util/rand" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/client-go/discovery" @@ -49,7 +48,6 @@ import ( fleetmetrics "go.goms.io/fleet/pkg/metrics" "go.goms.io/fleet/pkg/propertyprovider" "go.goms.io/fleet/pkg/propertyprovider/azure" - "go.goms.io/fleet/pkg/propertyprovider/azure/cloudconfig" "go.goms.io/fleet/pkg/utils" "go.goms.io/fleet/pkg/utils/httpclient" //+kubebuilder:scaffold:imports @@ -320,7 +318,7 @@ func Start(ctx context.Context, hubCfg, memberConfig *rest.Config, hubOpts, memb discoverClient := discovery.NewDiscoveryClientForConfigOrDie(memberConfig) if *enableV1Alpha1APIs { - gvk := schema.GroupVersionKind{Group: workv1alpha1.GroupVersion.Group, Version: workv1alpha1.GroupVersion.Version, Kind: workv1alpha1.AppliedWorkKind} + gvk := workv1alpha1.SchemeGroupVersion.WithKind(workv1alpha1.AppliedWorkKind) if err = utils.CheckCRDInstalled(discoverClient, gvk); err != nil { klog.ErrorS(err, "unable to find the required CRD", "GVK", gvk) return err @@ -368,17 +366,11 @@ func Start(ctx context.Context, hubCfg, memberConfig *rest.Config, hubOpts, memb switch { case propertyProvider != nil && *propertyProvider == azurePropertyProvider: klog.V(2).Info("setting up the Azure property provider") - // Set cloud configuration. - cloudConfiguration, err := cloudconfig.LoadCloudConfigFromFile(*cloudConfigFile) - if err != nil { - klog.ErrorS(err, "Unable to load cloud config from file", "file", *cloudConfigFile) - return err - } - klog.V(2).Info("Cloud config loaded successfully") - + // TODO: Set cloud configuration. // Note that the property provider, though initialized here, is not started until // the specific instance wins the leader election. - pp = azure.New(region, *cloudConfiguration) + klog.V(1).InfoS("Cloud config loaded successfully", "config", cloudConfigFile) + pp = azure.New(region) default: // Fall back to not using any property provider if the provided type is none or // not recognizable. diff --git a/go.mod b/go.mod index 34e8cef46..b2a5c829f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module go.goms.io/fleet -go 1.22.7 +go 1.22.2 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 @@ -31,35 +31,14 @@ require ( k8s.io/klog/v2 v2.130.1 k8s.io/metrics v0.25.2 k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 - sigs.k8s.io/cloud-provider-azure v1.28.2 - sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.0.50 sigs.k8s.io/controller-runtime v0.18.5 sigs.k8s.io/work-api v0.0.0-20220407021756-586d707fdb2c ) require ( dario.cat/mergo v1.0.0 // indirect - github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect 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/compute/armcompute/v5 v5.7.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/v4 v4.8.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/network/armnetwork/v4 v4.3.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.3.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.2.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0 // indirect - github.com/Azure/go-autorest v14.2.0+incompatible // indirect - github.com/Azure/go-autorest/autorest v0.11.29 // indirect - github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect - github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect - github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect - github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect - github.com/Azure/go-autorest/logger v0.2.1 // indirect - github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/aws/karpenter-core v0.32.2-0.20231109191441-e32aafc81fb5 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -75,7 +54,6 @@ require ( github.com/go-openapi/swag v0.23.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect @@ -101,7 +79,6 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/samber/lo v1.38.1 // indirect go.opentelemetry.io/otel v1.31.0 // indirect - go.opentelemetry.io/otel/metric v1.31.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.28.0 // indirect golang.org/x/net v0.30.0 // indirect diff --git a/go.sum b/go.sum index b54ca7840..39431e930 100644 --- a/go.sum +++ b/go.sum @@ -14,52 +14,24 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.0 h1:+m0M/LFxN43KvUL github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.0/go.mod h1:PwOyop78lveYMRs6oCxjiVyBdyCgIYH6XHIVZO9/SFQ= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2 v2.2.0 h1:Hp+EScFOu9HeCbeW8WU2yQPJd4gGwhMgKxWe+G6jNzw= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v2 v2.2.0/go.mod h1:/pz8dyNQe+Ey3yBp/XuYz7oqX8YDNWVpPB0hH3XWfbc= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0 h1:/Di3vB4sNeQ+7A8efjUVENvyB945Wruvstucqp7ZArg= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute v1.0.0/go.mod h1:gM3K25LQlsET3QR+4V74zxCsFAy0r6xMNN9n80SZn+4= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.7.0 h1:LkHbJbgF3YyvC53aqYGR+wWQDn2Rdp9AQdGndf9QvY4= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.7.0/go.mod h1:QyiQdW4f4/BIfB8ZutZ2s+28RAgfa/pT+zS++ZHyM1I= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerregistry/armcontainerregistry v1.2.0 h1:DWlwvVV5r/Wy1561nZ3wrpI1/vDIBRY/Wd1HWaRBZWA= -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/v4 v4.8.0 h1:0nGmzwBv5ougvzfGPCO2ljFRHvun57KpNrVCMrlk0ns= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4 v4.8.0/go.mod h1:gYq8wyDgv6JLhGbAU6gg8amCPgQWRE+aCvrV2gyzdfs= -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= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0/go.mod h1:AW8VEadnhw9xox+VaVd9sP7NjzOAnaZBLRH6Tq3cJ38= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.4.0 h1:HlZMUZW8S4P9oob1nCHxCCKrytxyLc+24nUJGssoEto= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault v1.4.0/go.mod h1:StGsLbuJh06Bd8IBfnAlIFV3fLb+gkczONWf15hpX2E= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0/go.mod h1:mLfWfj8v3jfWKsL9G4eoBoXVcsqcIUTapmdKy7uGOp0= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0 h1:QM6sE5k2ZT/vI5BEe0r7mqjsUSnhVBFbOsVkEuaEfiA= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork v1.1.0/go.mod h1:243D9iHbcQXoFUtgHJwL7gl2zx1aDuDMjvBZVGr2uW0= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4 v4.3.0 h1:bXwSugBiSbgtz7rOtbfGf+woewp4f06orW9OP5BjHLA= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v4 v4.3.0/go.mod h1:Y/HgrePTmGy9HjdSGTqZNa+apUpTVIEVKXJyARP2lrk= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.3.0 h1:yzrctSl9GMIQ5lHu7jc8olOsGjWDCsBpJhWqfGa/YIM= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.3.0/go.mod h1:GE4m0rnnfwLGX0Y9A9A25Zx5N/90jneT5ABevqzhuFQ= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.8.1 h1:nGiU2ovpbtkcC3x+g/wNHV4S9TOIYe2/yOVAj3wiGHI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.8.1/go.mod h1:T3ZgvD1aRKu12mEA0fU3PPvI7V0Nh0wzIdK0QMBhf0Y= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 h1:Dd+RhdJn0OTtVGaeDLZpcumkIVCtA/3/Fo42+eoYvVM= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0/go.mod h1:5kakwfW5CjC9KK+Q4wjXAg+ShuIm2mBMua0ZFj2C8PE= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0 h1:PiSrjRPpkQNjrM8H0WwKMnZUdu1RGMtd/LdGKUrOo+c= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.6.0/go.mod h1:oDrbWx4ewMylP7xHivfgixbfGBT6APAwsSoHRKotnIc= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.2.0 h1:TkNl6WlpHdZSMt0Zngw8y0c9ZMi3GwmYl0kKNbW9PvU= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.2.0/go.mod h1:ukmL56lWl275SgNFijuwx0Wv6n6HmzzpPWW4kMoy/wY= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0 h1:eXnN9kaS8TiDwXjoie3hMRLuwdUBUMW9KRgOqB3mCaw= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.1.0/go.mod h1:XIpam8wumeZ5rVMuhdDQLMfIPDf1WO3IzrCRO3e3e3o= github.com/Azure/go-armbalancer v0.0.2 h1:NVnxsTWHI5/fEzL6k6TjxPUfcB/3Si3+HFOZXOu0QtA= github.com/Azure/go-armbalancer v0.0.2/go.mod h1:yTg7MA/8YnfKQc9o97tzAJ7fbdVkod1xGsIvKmhYPRE= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/Azure/go-autorest/autorest v0.11.29 h1:I4+HL/JDvErx2LjyzaVxllw2lRDB5/BT2Bm4g20iqYw= github.com/Azure/go-autorest/autorest v0.11.29/go.mod h1:ZtEzC4Jy2JDrZLxvWs8LrBWEBycl1hbT1eknI8MtfAs= -github.com/Azure/go-autorest/autorest/adal v0.9.22/go.mod h1:XuAbAEUv2Tta//+voMI038TrJBqjKam0me7qR+L8Cmk= github.com/Azure/go-autorest/autorest/adal v0.9.23 h1:Yepx8CvFxwNKpH6ja7RZ+sKX+DWYNldbLiALMC3BTz8= github.com/Azure/go-autorest/autorest/adal v0.9.23/go.mod h1:5pcMqFkdPhviJdlEy3kC/v1ZLnQl0MH6XA5YCcMhy4c= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/autorest/mocks v0.4.2 h1:PGN4EDXnuQbojHbU0UWoNvmu9AGVwYHG9/fkDYhtAfw= github.com/Azure/go-autorest/autorest/mocks v0.4.2/go.mod h1:Vy7OitM9Kei0i1Oj+LvyAWMXJHeKH1MVlzFugfVrmyU= github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk= @@ -133,7 +105,6 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= @@ -223,17 +194,11 @@ github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3k github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.goms.io/fleet-networking v0.2.7 h1:lVs2/GiCjo18BRgACib+VPnENUMh+2YbYXoeNtcAvw0= go.goms.io/fleet-networking v0.2.7/go.mod h1:JoWG82La5nV29mooOnPpIhy6/Pi4oGXQk21CPF1UStg= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 h1:x8Z78aZx8cOF0+Kkazoc7lwUNMGy0LrzEMxTm4BbTxg= @@ -249,8 +214,6 @@ go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= @@ -260,26 +223,18 @@ go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 h1:1wqE9dj9NpSm04INVsJhhEUzhuDVjbcyKH91sVyPATw= golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= @@ -287,31 +242,18 @@ golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= @@ -320,7 +262,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -334,14 +275,11 @@ google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojt gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/dnaeon/go-vcr.v3 v3.2.0 h1:Rltp0Vf+Aq0u4rQXgmXgtgoRDStTnFN83cWgSGSoRzM= -gopkg.in/dnaeon/go-vcr.v3 v3.2.0/go.mod h1:2IMOnnlx9I6u9x+YBsM3tAMx6AlOxnJ0pWxQAzZ79Ag= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI= @@ -372,8 +310,6 @@ knative.dev/pkg v0.0.0-20231010144348-ca8c009405dd h1:KJXBX9dOmRTUWduHg1gnWtPGIE knative.dev/pkg v0.0.0-20231010144348-ca8c009405dd/go.mod h1:36cYnaOVHkzmhgybmYX6zDaTl3PakFeJQJl7wi6/RLE= sigs.k8s.io/cloud-provider-azure v1.28.2 h1:KKrWdC1+p2xXdT1VRmSkT57MhKNzPXk3yPcrwUDIr5I= sigs.k8s.io/cloud-provider-azure v1.28.2/go.mod h1:vDsaFOrvDDEUg0mLF2eoUeneCK+ROlRf4zACA91iwHs= -sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.0.50 h1:l9igMANNptVwYmZrqGS51oW0zvfSxBGmlOaDPe407FI= -sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.0.50/go.mod h1:1M90A+akyTabHVnveSKlvIO/Kk9kEr1LjRx+08twKVU= sigs.k8s.io/controller-runtime v0.18.5 h1:nTHio/W+Q4aBlQMgbnC5hZb4IjIidyrizMai9P6n4Rk= sigs.k8s.io/controller-runtime v0.18.5/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= diff --git a/pkg/propertyprovider/azure/cloudconfig/config.go b/pkg/propertyprovider/azure/cloudconfig/config.go deleted file mode 100644 index dbefada09..000000000 --- a/pkg/propertyprovider/azure/cloudconfig/config.go +++ /dev/null @@ -1,155 +0,0 @@ -package cloudconfig - -import ( - "fmt" - "io" - "os" - "strings" - - "k8s.io/apimachinery/pkg/util/yaml" - "sigs.k8s.io/cloud-provider-azure/pkg/azclient" - "sigs.k8s.io/cloud-provider-azure/pkg/azclient/policy/ratelimit" - "sigs.k8s.io/cloud-provider-azure/pkg/consts" -) - -const ( - // DefaultUserAgent is the default user agent string to access Azure resources. - DefaultUserAgent = "fleet-member-agent" -) - -// CloudConfig holds the configuration parsed from the --cloud-config flag -type RateLimitConfig ratelimit.Config -type CloudConfig struct { - azclient.ARMClientConfig `json:",inline" mapstructure:",squash"` - azclient.AzureAuthConfig `json:",inline" mapstructure:",squash"` - *RateLimitConfig `json:",inline" mapstructure:",squash"` - // name of cluster - ClusterName string `json:"clusterName,omitempty" mapstructure:"clusterName,omitempty"` - // azure resource location - Location string `json:"location,omitempty" mapstructure:"location,omitempty"` - // subscription ID - SubscriptionID string `json:"subscriptionID,omitempty" mapstructure:"subscriptionID,omitempty"` - // default resource group where the cluster is deployed - ClusterResourceGroup string `json:"clusterResourceGroup,omitempty" mapstructure:"resourceGroup,omitempty"` - // name of the virtual network of cluster - VnetName string `json:"vnetName,omitempty" mapstructure:"vnetName,omitempty"` - // name of the resource group where the virtual network is deployed - VnetResourceGroup string `json:"vnetResourceGroup,omitempty" mapstructure:"vnetResourceGroup,omitempty"` - // Enable exponential backoff to manage resource request retries - CloudProviderBackoff bool `json:"cloudProviderBackoff,omitempty" mapstructure:"cloudProviderBackoff,omitempty"` -} - -// LoadCloudConfigFromFile loads the cloud config from the specified file -func LoadCloudConfigFromFile(filePath string) (*CloudConfig, error) { - if filePath == "" { - return nil, fmt.Errorf("failed to load cloud cloudconfig: file path is empty") - } - - var config *CloudConfig - configReader, err := os.Open(filePath) - if err != nil { - return nil, fmt.Errorf("failed to open cloud cloudconfig file: %w, file path: %s", err, filePath) - } - defer configReader.Close() - - contents, err := io.ReadAll(configReader) - if err != nil { - return nil, fmt.Errorf("failed to read cloud cloudconfig file: %w, file path: %s", err, filePath) - } - - if err := yaml.Unmarshal(contents, &config); err != nil { - return nil, fmt.Errorf("failed to unmarshal cloud cloudconfig: %w, file path: %s", err, filePath) - } - - if err := config.defaultAndValidate(); err != nil { - return nil, fmt.Errorf("failed to validate cloud cloudconfig: %w, file contents: `%s`", err, string(contents)) - } - - return config, nil -} - -// defaultAndValidate validates the cloud config and sets default values -func (cfg *CloudConfig) defaultAndValidate() error { - cfg.trimSpace() - - if cfg.Cloud == "" { - return fmt.Errorf("cloud is empty") - } - - if cfg.Location == "" { - return fmt.Errorf("location is empty") - } - - if cfg.SubscriptionID == "" { - return fmt.Errorf("subscription ID is empty") - } - - if cfg.ClusterResourceGroup == "" { - return fmt.Errorf("cluster resource group is empty") - } - - if cfg.VnetName == "" { - return fmt.Errorf("virtual network name is empty") - } - - if cfg.ClusterName == "" { - return fmt.Errorf("cluster name is empty") - } - - if cfg.VnetResourceGroup == "" { - cfg.VnetResourceGroup = cfg.ClusterResourceGroup - } - - if !cfg.UseManagedIdentityExtension { - if cfg.UserAssignedIdentityID != "" { - return fmt.Errorf("useManagedIdentityExtension needs to be true when userAssignedIdentityID is provided") - } - if cfg.AADClientID == "" || cfg.AADClientSecret == "" { - return fmt.Errorf("AAD client ID or AAD client secret is empty") - } - } - - // default values - if cfg.UserAgent == "" { - cfg.UserAgent = DefaultUserAgent - } - - // if not specified, apply default rate limit cloudconfig - if cfg.RateLimitConfig == nil { - cfg.RateLimitConfig = &RateLimitConfig{CloudProviderRateLimit: false} - } - - if cfg.CloudProviderRateLimit { - // Assign read rate limit defaults if no configuration was passed in. - if cfg.CloudProviderRateLimitQPS == 0 { - cfg.CloudProviderRateLimitQPS = consts.RateLimitQPSDefault - } - if cfg.CloudProviderRateLimitBucket == 0 { - cfg.CloudProviderRateLimitBucket = consts.RateLimitBucketDefault - } - // Assign write rate limit defaults if no configuration was passed in. - if cfg.CloudProviderRateLimitQPSWrite == 0 { - cfg.CloudProviderRateLimitQPSWrite = cfg.CloudProviderRateLimitQPS - } - if cfg.CloudProviderRateLimitBucketWrite == 0 { - cfg.CloudProviderRateLimitBucketWrite = cfg.CloudProviderRateLimitBucket - } - } - return nil -} - -// trimSpace trims the leading and trailing spaces of the cloud config fields -func (cfg *CloudConfig) trimSpace() { - cfg.Cloud = strings.TrimSpace(cfg.Cloud) - cfg.Location = strings.TrimSpace(cfg.Location) - cfg.SubscriptionID = strings.TrimSpace(cfg.SubscriptionID) - cfg.TenantID = strings.TrimSpace(cfg.TenantID) - cfg.UserAssignedIdentityID = strings.TrimSpace(cfg.UserAssignedIdentityID) - cfg.AADClientID = strings.TrimSpace(cfg.AADClientID) - cfg.AADClientSecret = strings.TrimSpace(cfg.AADClientSecret) - cfg.UserAgent = strings.TrimSpace(cfg.UserAgent) - cfg.ClusterResourceGroup = strings.TrimSpace(cfg.ClusterResourceGroup) - cfg.VnetName = strings.TrimSpace(cfg.VnetName) - cfg.VnetResourceGroup = strings.TrimSpace(cfg.VnetResourceGroup) - cfg.ClusterName = strings.TrimSpace(cfg.ClusterName) -} diff --git a/pkg/propertyprovider/azure/cloudconfig/config_test.go b/pkg/propertyprovider/azure/cloudconfig/config_test.go deleted file mode 100644 index 42a04378b..000000000 --- a/pkg/propertyprovider/azure/cloudconfig/config_test.go +++ /dev/null @@ -1,348 +0,0 @@ -package cloudconfig - -import ( - "fmt" - "testing" - - "github.com/google/go-cmp/cmp" - "sigs.k8s.io/cloud-provider-azure/pkg/azclient" -) - -func TestTrimSpace(t *testing.T) { - t.Run("test spaces are trimmed", func(t *testing.T) { - config := CloudConfig{ - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: " test \n", - UserAgent: " test \n", - TenantID: " test \t \n", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UserAssignedIdentityID: " test \n", - UseManagedIdentityExtension: true, - AADClientID: "\n test \n", - AADClientSecret: " test \n", - }, - ClusterName: " test \n", - Location: " test \n", - SubscriptionID: " test \n", - ClusterResourceGroup: "\r\n test \n", - VnetName: " test ", - VnetResourceGroup: " \t test ", - } - - expected := CloudConfig{ - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "test", - TenantID: "test", - UserAgent: "test", - }, - ClusterName: "test", - Location: "test", - SubscriptionID: "test", - ClusterResourceGroup: "test", - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "test", - AADClientID: "test", - AADClientSecret: "test", - }, - VnetName: "test", - VnetResourceGroup: "test", - } - config.trimSpace() - if diff := cmp.Diff(config, expected); diff != "" { - t.Fatalf("trimSpace(), expect cloudconfig fields are trimmed, got: %v", config) - } - }) -} - -func TestDefaultAndValidate(t *testing.T) { - tests := map[string]struct { - config CloudConfig - wantError error - }{ - "Cloud empty": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: " ", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "a", - }, - }, - wantError: fmt.Errorf("cloud is empty"), - }, - "ClusterName empty": { - config: CloudConfig{ - ClusterName: "", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "a", - }, - }, - wantError: fmt.Errorf("cluster name is empty"), - }, - "Location empty": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "a", - }, - }, - wantError: fmt.Errorf("location is empty"), - }, - "SubscriptionID empty": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "a", - }, - }, - wantError: fmt.Errorf("subscription ID is empty"), - }, - "ClusterResourceGroup empty": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "a", - }, - }, - wantError: fmt.Errorf("cluster resource group is empty"), - }, - "VnetName empty": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "a", - }, - }, - wantError: fmt.Errorf("virtual network name is empty"), - }, - "UserAssignedIdentityID not empty when UseManagedIdentityExtension is false": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: false, - UserAssignedIdentityID: "aaaa", - }, - }, - wantError: fmt.Errorf("useManagedIdentityExtension needs to be true when userAssignedIdentityID is provided"), - }, - "AADClientID empty": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: false, - AADClientID: "", - AADClientSecret: "2", - }, - }, - wantError: fmt.Errorf("AAD client ID or AAD client secret is empty"), - }, - "AADClientSecret empty": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: false, - AADClientID: "1", - AADClientSecret: "", - }, - }, - wantError: fmt.Errorf("AAD client ID or AAD client secret is empty"), - }, - "has all required properties": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - UserAgent: "fleet-member-agent", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - }, - }, - wantError: nil, - }, - "has all required properties with msi and specified values": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - UserAgent: "user-agent", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "u", - }, - }, - wantError: nil, - }, - "has all required properties with msi and disabled ratelimiter": { - config: CloudConfig{ - ClusterName: "cluster1", - Location: "westus", - SubscriptionID: "123456789", - ClusterResourceGroup: "group", - VnetName: "vnet", - VnetResourceGroup: "vrg", - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzureCloud", - UserAgent: "user-agent", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "u", - }, - RateLimitConfig: &RateLimitConfig{ - CloudProviderRateLimit: false, - }, - }, - wantError: nil, - }, - } - - for name, test := range tests { - t.Run(name, func(t *testing.T) { - err := test.config.defaultAndValidate() - if test.wantError != nil { - if diff := cmp.Diff(err.Error(), test.wantError.Error()); diff != "" { - t.Fatalf("defaultAndValidate() got %v, wantError %v", err, test.wantError) - } - } else { - if err != nil { - t.Fatalf("defaultAndValidate() got %v, wantError %v", err, test.wantError) - } - } - }) - } -} - -func TestLoadCloudConfigFromFile(t *testing.T) { - tests := map[string]struct { - filePath string - wantErr bool - wantConfig *CloudConfig - }{ - "file path is empty": { - filePath: "", - wantErr: true, - }, - "failed to open file": { - filePath: "./test/not_exist.yaml", - wantErr: true, - }, - "failed to unmarshal file": { - filePath: "./test/azure_invalid_config.yaml", - wantErr: true, - }, - "succeeded to load config": { - filePath: "./test/azure_valid_config.yaml", - wantConfig: &CloudConfig{ - ARMClientConfig: azclient.ARMClientConfig{ - Cloud: "AzurePublicCloud", - TenantID: "00000000-0000-0000-0000-000000000000", - UserAgent: "fleet-member-agent", - }, - AzureAuthConfig: azclient.AzureAuthConfig{ - UseManagedIdentityExtension: true, - UserAssignedIdentityID: "", - AADClientID: "", - AADClientSecret: "", - }, - RateLimitConfig: &RateLimitConfig{CloudProviderRateLimit: false}, - Location: "westus", - SubscriptionID: "00000000-0000-0000-0000-000000000000", - VnetName: "test-vnet", - VnetResourceGroup: "test-rg", - ClusterName: "test-cluster", - ClusterResourceGroup: "test-rg", - CloudProviderBackoff: false, - }, - }, - } - for name, test := range tests { - t.Run(name, func(t *testing.T) { - config, err := LoadCloudConfigFromFile(test.filePath) - if got := err != nil; got != test.wantErr { - t.Fatalf("LoadCloudConfigFromFile() got %v, wantErr %v", err, test.wantErr) - } - if diff := cmp.Diff(config, test.wantConfig); diff != "" { - t.Errorf("LoadCloudConfigFromFile() cloud config mismatch got %v, want %v", config, test.wantConfig) - } - }) - } -} diff --git a/pkg/propertyprovider/azure/cloudconfig/test/azure_invalid_config.yaml b/pkg/propertyprovider/azure/cloudconfig/test/azure_invalid_config.yaml deleted file mode 100644 index 6454f8825..000000000 --- a/pkg/propertyprovider/azure/cloudconfig/test/azure_invalid_config.yaml +++ /dev/null @@ -1 +0,0 @@ -This is an invalid json file for testing purposes. \ No newline at end of file diff --git a/pkg/propertyprovider/azure/cloudconfig/test/azure_valid_config.yaml b/pkg/propertyprovider/azure/cloudconfig/test/azure_valid_config.yaml deleted file mode 100644 index fa5cc0ed2..000000000 --- a/pkg/propertyprovider/azure/cloudconfig/test/azure_valid_config.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{ - "cloud": "AzurePublicCloud", - "tenantId": "00000000-0000-0000-0000-000000000000", - "subscriptionId": "00000000-0000-0000-0000-000000000000", - "useManagedIdentityExtension": true, - "clusterResourceGroup": "test-rg", - "location": "westus", - clusterName: "test-cluster", - "vnetName": "test-vnet", - "vnetResourceGroup": "test-rg", - "cloudProviderBackoff": false -} \ No newline at end of file diff --git a/pkg/propertyprovider/azure/provider.go b/pkg/propertyprovider/azure/provider.go index 3f239131d..14c091653 100644 --- a/pkg/propertyprovider/azure/provider.go +++ b/pkg/propertyprovider/azure/provider.go @@ -24,7 +24,6 @@ import ( clusterv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1" "go.goms.io/fleet/pkg/propertyprovider" - "go.goms.io/fleet/pkg/propertyprovider/azure/cloudconfig" "go.goms.io/fleet/pkg/propertyprovider/azure/controllers" "go.goms.io/fleet/pkg/propertyprovider/azure/trackers" ) @@ -70,9 +69,6 @@ type PropertyProvider struct { // The controller manager in use by the Azure property provider; this field is mostly reserved for // testing purposes. mgr ctrl.Manager - - // The cloud configuration in use by the Azure property provider. - cloudConfig cloudconfig.CloudConfig } // Verify that the Azure property provider implements the MetricProvider interface at compile time. @@ -316,10 +312,9 @@ func (p *PropertyProvider) autoDiscoverRegionAndSetupTrackers(ctx context.Contex // If the region is unspecified at the time when this function is called, the provider // will attempt to auto-discover the region of its host cluster when the Start method is // called. -func New(region *string, config cloudconfig.CloudConfig) propertyprovider.PropertyProvider { +func New(region *string) propertyprovider.PropertyProvider { return &PropertyProvider{ - region: region, - cloudConfig: config, + region: region, } } @@ -328,9 +323,8 @@ func New(region *string, config cloudconfig.CloudConfig) propertyprovider.Proper // // This is mostly used for allow plugging in of alternate pricing providers (one that // does not use the Karpenter client), and for testing purposes. -func NewWithPricingProvider(pp trackers.PricingProvider, config cloudconfig.CloudConfig) propertyprovider.PropertyProvider { +func NewWithPricingProvider(pp trackers.PricingProvider) propertyprovider.PropertyProvider { return &PropertyProvider{ nodeTracker: trackers.NewNodeTracker(pp), - cloudConfig: config, } } diff --git a/pkg/propertyprovider/azure/suite_test.go b/pkg/propertyprovider/azure/suite_test.go index ad306034c..d26ac62fa 100644 --- a/pkg/propertyprovider/azure/suite_test.go +++ b/pkg/propertyprovider/azure/suite_test.go @@ -22,7 +22,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" "go.goms.io/fleet/pkg/propertyprovider" - "go.goms.io/fleet/pkg/propertyprovider/azure/cloudconfig" "go.goms.io/fleet/pkg/propertyprovider/azure/trackers" ) @@ -95,10 +94,7 @@ var _ = BeforeSuite(func() { // Start the Azure property provider. pp = trackers.NewAKSKarpenterPricingClient(ctx, region) - cloudConfigFile := "./cloudconfig/test/azure_valid_config.yaml" - cloudConfiguration, err := cloudconfig.LoadCloudConfigFromFile(cloudConfigFile) - Expect(err).NotTo(HaveOccurred()) - p = NewWithPricingProvider(pp, *cloudConfiguration) + p = NewWithPricingProvider(pp) Expect(p.Start(ctx, memberCfg)).To(Succeed()) }) diff --git a/pkg/scheduler/queue/queue.go b/pkg/scheduler/queue/queue.go index 3aabc04d2..14081347c 100644 --- a/pkg/scheduler/queue/queue.go +++ b/pkg/scheduler/queue/queue.go @@ -73,7 +73,7 @@ type simpleClusterResourcePlacementSchedulingQueueOptions struct { name string } -// Option is the function that configures the simpleClusterResourcePlacementSchedulingQueue. +// Option is the function that configures the simpleClusterResourcePlacmentSchedulingQueue. type Option func(*simpleClusterResourcePlacementSchedulingQueueOptions) var defaultSimpleClusterResourcePlacementSchedulingQueueOptions = simpleClusterResourcePlacementSchedulingQueueOptions{ diff --git a/pkg/utils/controller/controller.go b/pkg/utils/controller/controller.go index 05976ee07..5ef85cfef 100644 --- a/pkg/utils/controller/controller.go +++ b/pkg/utils/controller/controller.go @@ -171,7 +171,7 @@ func NewController(Name string, KeyFunc KeyFunc, ReconcileFunc ReconcileFunc, ra name: Name, keyFunc: KeyFunc, reconcileFunc: ReconcileFunc, - queue: workqueue.NewRateLimitingQueue(rateLimiter), + queue: workqueue.NewNamedRateLimitingQueue(rateLimiter, Name), } }