Skip to content

Commit

Permalink
chore: undo azClient rename for now
Browse files Browse the repository at this point in the history
  • Loading branch information
comtalyst committed Jun 20, 2024
1 parent a981a0e commit d07dbf2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
18 changes: 9 additions & 9 deletions cluster-autoscaler/cloudprovider/azure/azure_agent_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (as *AgentPool) initialize() error {
ctx, cancel := getContextWithCancel()
defer cancel()

template, err := as.manager.azureClients.deploymentClient.ExportTemplate(ctx, as.manager.config.ResourceGroup, as.manager.config.Deployment)
template, err := as.manager.azClient.deploymentClient.ExportTemplate(ctx, as.manager.config.ResourceGroup, as.manager.config.Deployment)
if err != nil {
klog.Errorf("deploymentClient.ExportTemplate(%s, %s) failed: %v", as.manager.config.ResourceGroup, as.manager.config.Deployment, err)
return err.Error()
Expand Down Expand Up @@ -215,7 +215,7 @@ func (as *AgentPool) getAllSucceededAndFailedDeployments() ([]resources.Deployme
ctx, cancel := getContextWithCancel()
defer cancel()

allDeployments, err := as.manager.azureClients.deploymentClient.List(ctx, as.manager.config.ResourceGroup)
allDeployments, err := as.manager.azClient.deploymentClient.List(ctx, as.manager.config.ResourceGroup)
if err != nil {
klog.Errorf("getAllSucceededAndFailedDeployments: failed to list deployments with error: %v", err)
return nil, err.Error()
Expand Down Expand Up @@ -264,7 +264,7 @@ func (as *AgentPool) deleteOutdatedDeployments() (err error) {
errList := make([]error, 0)
for _, deployment := range toBeDeleted {
klog.V(4).Infof("deleteOutdatedDeployments: starts deleting outdated deployment (%s)", *deployment.Name)
err := as.manager.azureClients.deploymentClient.Delete(ctx, as.manager.config.ResourceGroup, *deployment.Name)
err := as.manager.azClient.deploymentClient.Delete(ctx, as.manager.config.ResourceGroup, *deployment.Name)
if err != nil {
errList = append(errList, err.Error())
}
Expand Down Expand Up @@ -324,7 +324,7 @@ func (as *AgentPool) IncreaseSize(delta int) error {
ctx, cancel := getContextWithCancel()
defer cancel()
klog.V(3).Infof("Waiting for deploymentClient.CreateOrUpdate(%s, %s, %v)", as.manager.config.ResourceGroup, newDeploymentName, newDeployment)
retryErr := as.manager.azureClients.deploymentClient.CreateOrUpdate(ctx, as.manager.config.ResourceGroup, newDeploymentName, newDeployment, "")
retryErr := as.manager.azClient.deploymentClient.CreateOrUpdate(ctx, as.manager.config.ResourceGroup, newDeploymentName, newDeployment, "")
if err != nil {
klog.Errorf("deploymentClient.CreateOrUpdate for deployment %q failed: %v", newDeploymentName, retryErr)
return retryErr.Error()
Expand Down Expand Up @@ -507,7 +507,7 @@ func (as *AgentPool) deleteBlob(accountName, vhdContainer, vhdBlob string) error
ctx, cancel := getContextWithCancel()
defer cancel()

storageKeysResult, rerr := as.manager.azureClients.storageAccountsClient.ListKeys(ctx, as.manager.config.SubscriptionID, as.manager.config.ResourceGroup, accountName)
storageKeysResult, rerr := as.manager.azClient.storageAccountsClient.ListKeys(ctx, as.manager.config.SubscriptionID, as.manager.config.ResourceGroup, accountName)
if rerr != nil {
return rerr.Error()
}
Expand All @@ -530,7 +530,7 @@ func (as *AgentPool) deleteVirtualMachine(name string) error {
ctx, cancel := getContextWithCancel()
defer cancel()

vm, rerr := as.manager.azureClients.virtualMachinesClient.Get(ctx, as.manager.config.ResourceGroup, name, "")
vm, rerr := as.manager.azClient.virtualMachinesClient.Get(ctx, as.manager.config.ResourceGroup, name, "")
if rerr != nil {
if exists, _ := checkResourceExistsFromRetryError(rerr); !exists {
klog.V(2).Infof("VirtualMachine %s/%s has already been removed", as.manager.config.ResourceGroup, name)
Expand Down Expand Up @@ -566,7 +566,7 @@ func (as *AgentPool) deleteVirtualMachine(name string) error {
defer deleteCancel()

klog.Infof("waiting for VirtualMachine deletion: %s/%s", as.manager.config.ResourceGroup, name)
rerr = as.manager.azureClients.virtualMachinesClient.Delete(deleteCtx, as.manager.config.ResourceGroup, name)
rerr = as.manager.azClient.virtualMachinesClient.Delete(deleteCtx, as.manager.config.ResourceGroup, name)
_, realErr := checkResourceExistsFromRetryError(rerr)
if realErr != nil {
return realErr
Expand All @@ -577,7 +577,7 @@ func (as *AgentPool) deleteVirtualMachine(name string) error {
klog.Infof("deleting nic: %s/%s", as.manager.config.ResourceGroup, nicName)
interfaceCtx, interfaceCancel := getContextWithCancel()
defer interfaceCancel()
rerr := as.manager.azureClients.interfacesClient.Delete(interfaceCtx, as.manager.config.ResourceGroup, nicName)
rerr := as.manager.azClient.interfacesClient.Delete(interfaceCtx, as.manager.config.ResourceGroup, nicName)
klog.Infof("waiting for nic deletion: %s/%s", as.manager.config.ResourceGroup, nicName)
_, realErr := checkResourceExistsFromRetryError(rerr)
if realErr != nil {
Expand Down Expand Up @@ -609,7 +609,7 @@ func (as *AgentPool) deleteVirtualMachine(name string) error {
klog.Infof("deleting managed disk: %s/%s", as.manager.config.ResourceGroup, *osDiskName)
disksCtx, disksCancel := getContextWithCancel()
defer disksCancel()
rerr := as.manager.azureClients.disksClient.Delete(disksCtx, as.manager.config.SubscriptionID, as.manager.config.ResourceGroup, *osDiskName)
rerr := as.manager.azClient.disksClient.Delete(disksCtx, as.manager.config.SubscriptionID, as.manager.config.ResourceGroup, *osDiskName)
_, realErr := checkResourceExistsFromRetryError(rerr)
if realErr != nil {
return realErr
Expand Down
12 changes: 6 additions & 6 deletions cluster-autoscaler/cloudprovider/azure/azure_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var (
type azureCache struct {
mutex sync.Mutex
interrupt chan struct{}
azureClients *azureClients
azClient *azClient
refreshInterval time.Duration

// Cache content.
Expand All @@ -62,10 +62,10 @@ type azureCache struct {
skus map[string]*skewer.Cache
}

func newAzureCache(client *azureClients, cacheTTL time.Duration, resourceGroup, vmType string, enableDynamicInstanceList bool, defaultLocation string) (*azureCache, error) {
func newAzureCache(client *azClient, cacheTTL time.Duration, resourceGroup, vmType string, enableDynamicInstanceList bool, defaultLocation string) (*azureCache, error) {
cache := &azureCache{
interrupt: make(chan struct{}),
azureClients: client,
azClient: client,
refreshInterval: cacheTTL,
resourceGroup: resourceGroup,
vmType: vmType,
Expand Down Expand Up @@ -207,7 +207,7 @@ func (m *azureCache) fetchVirtualMachines() (map[string][]compute.VirtualMachine
ctx, cancel := getContextWithCancel()
defer cancel()

result, err := m.azureClients.virtualMachinesClient.List(ctx, m.resourceGroup)
result, err := m.azClient.virtualMachinesClient.List(ctx, m.resourceGroup)
if err != nil {
klog.Errorf("VirtualMachinesClient.List in resource group %q failed: %v", m.resourceGroup, err)
return nil, nil, err.Error()
Expand Down Expand Up @@ -253,7 +253,7 @@ func (m *azureCache) fetchScaleSets() (map[string]compute.VirtualMachineScaleSet
ctx, cancel := getContextWithTimeout(vmssContextTimeout)
defer cancel()

result, err := m.azureClients.virtualMachineScaleSetsClient.List(ctx, m.resourceGroup)
result, err := m.azClient.virtualMachineScaleSetsClient.List(ctx, m.resourceGroup)
if err != nil {
klog.Errorf("VirtualMachineScaleSetsClient.List in resource group %q failed: %v", m.resourceGroup, err)
return nil, err.Error()
Expand Down Expand Up @@ -318,7 +318,7 @@ func (m *azureCache) Unregister(nodeGroup cloudprovider.NodeGroup) bool {
func (m *azureCache) fetchSKUs(ctx context.Context, location string) (*skewer.Cache, error) {
return skewer.NewCache(ctx,
skewer.WithLocation(location),
skewer.WithResourceClient(m.azureClients.skuClient),
skewer.WithResourceClient(m.azClient.skuClient),
)
}

Expand Down
6 changes: 3 additions & 3 deletions cluster-autoscaler/cloudprovider/azure/azure_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
providerazureconfig "sigs.k8s.io/cloud-provider-azure/pkg/provider/config"
)

type azureClients struct {
type azClient struct {
virtualMachineScaleSetsClient vmssclient.Interface
virtualMachineScaleSetVMsClient vmssvmclient.Interface
virtualMachinesClient vmclient.Interface
Expand All @@ -62,7 +62,7 @@ func newAuthorizer(config *Config, env *azure.Environment) (autorest.Authorizer,
}
}

func newAzureClients(cfg *Config, env *azure.Environment) (*azureClients, error) {
func newAzClient(cfg *Config, env *azure.Environment) (*azClient, error) {
authorizer, err := newAuthorizer(cfg, env)
if err != nil {
return nil, err
Expand Down Expand Up @@ -105,7 +105,7 @@ func newAzureClients(cfg *Config, env *azure.Environment) (*azureClients, error)
skuClient.Authorizer = azClientConfig.Authorizer
klog.V(5).Infof("Created sku client with authorizer: %v", skuClient)

return &azureClients{
return &azClient{
disksClient: disksClient,
interfacesClient: interfacesClient,
virtualMachineScaleSetsClient: scaleSetsClient,
Expand Down
18 changes: 9 additions & 9 deletions cluster-autoscaler/cloudprovider/azure/azure_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ const (

// AzureManager handles Azure communication and data caching.
type AzureManager struct {
config *Config
azureClients *azureClients
env azure.Environment
config *Config
azClient *azClient
env azure.Environment

azureCache *azureCache
lastRefresh time.Time
autoDiscoverySpecs []labelAutoDiscoveryConfig
explicitlyConfigured map[string]bool
}

// createAzureManagerInternal allows for a custom azureClients to be passed in by tests.
func createAzureManagerInternal(configReader io.Reader, discoveryOpts cloudprovider.NodeGroupDiscoveryOptions, azureClients *azureClients) (*AzureManager, error) {
// createAzureManagerInternal allows for a custom azClient to be passed in by tests.
func createAzureManagerInternal(configReader io.Reader, discoveryOpts cloudprovider.NodeGroupDiscoveryOptions, azClient *azClient) (*AzureManager, error) {
cfg, err := BuildAzureConfig(configReader)
if err != nil {
return nil, err
Expand All @@ -72,8 +72,8 @@ func createAzureManagerInternal(configReader io.Reader, discoveryOpts cloudprovi

klog.Infof("Starting azure manager with subscription ID %q", cfg.SubscriptionID)

if azureClients == nil {
azureClients, err = newAzureClients(cfg, &env)
if azClient == nil {
azClient, err = newAzClient(cfg, &env)
if err != nil {
return nil, err
}
Expand All @@ -83,15 +83,15 @@ func createAzureManagerInternal(configReader io.Reader, discoveryOpts cloudprovi
manager := &AzureManager{
config: cfg,
env: env,
azureClients: azureClients,
azClient: azClient,
explicitlyConfigured: make(map[string]bool),
}

cacheTTL := refreshInterval
if cfg.VmssCacheTTLInSeconds != 0 {
cacheTTL = time.Duration(cfg.VmssCacheTTLInSeconds) * time.Second
}
cache, err := newAzureCache(azureClients, cacheTTL, cfg.ResourceGroup, cfg.VMType, cfg.EnableDynamicInstanceList, cfg.Location)
cache, err := newAzureCache(azClient, cacheTTL, cfg.ResourceGroup, cfg.VMType, cfg.EnableDynamicInstanceList, cfg.Location)
if err != nil {
return nil, err
}
Expand Down
14 changes: 7 additions & 7 deletions cluster-autoscaler/cloudprovider/azure/azure_scale_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (scaleSet *ScaleSet) waitForDeleteInstances(future *azure.Future, requiredI
defer cancel()

klog.V(3).Infof("Calling virtualMachineScaleSetsClient.WaitForDeleteInstancesResult(%v) for %s", requiredIds.InstanceIds, scaleSet.Name)
httpResponse, err := scaleSet.manager.azureClients.virtualMachineScaleSetsClient.WaitForDeleteInstancesResult(ctx, future, scaleSet.manager.config.ResourceGroup)
httpResponse, err := scaleSet.manager.azClient.virtualMachineScaleSetsClient.WaitForDeleteInstancesResult(ctx, future, scaleSet.manager.config.ResourceGroup)
isSuccess, err := isSuccessHTTPResponse(httpResponse, err)
if isSuccess {
klog.V(3).Infof("virtualMachineScaleSetsClient.WaitForDeleteInstancesResult(%v) for %s success", requiredIds.InstanceIds, scaleSet.Name)
Expand All @@ -220,7 +220,7 @@ func (scaleSet *ScaleSet) updateVMSSCapacity(future *azure.Future) {
defer cancel()

klog.V(3).Infof("Calling virtualMachineScaleSetsClient.WaitForCreateOrUpdateResult(%s)", scaleSet.Name)
httpResponse, err := scaleSet.manager.azureClients.virtualMachineScaleSetsClient.WaitForCreateOrUpdateResult(ctx, future, scaleSet.manager.config.ResourceGroup)
httpResponse, err := scaleSet.manager.azClient.virtualMachineScaleSetsClient.WaitForCreateOrUpdateResult(ctx, future, scaleSet.manager.config.ResourceGroup)

isSuccess, err := isSuccessHTTPResponse(httpResponse, err)
if isSuccess {
Expand Down Expand Up @@ -267,7 +267,7 @@ func (scaleSet *ScaleSet) SetScaleSetSize(size int64) error {
ctx, cancel := getContextWithTimeout(vmssContextTimeout)
defer cancel()
klog.V(3).Infof("Waiting for virtualMachineScaleSetsClient.CreateOrUpdateAsync(%s)", scaleSet.Name)
future, rerr := scaleSet.manager.azureClients.virtualMachineScaleSetsClient.CreateOrUpdateAsync(ctx, scaleSet.manager.config.ResourceGroup, scaleSet.Name, op)
future, rerr := scaleSet.manager.azClient.virtualMachineScaleSetsClient.CreateOrUpdateAsync(ctx, scaleSet.manager.config.ResourceGroup, scaleSet.Name, op)
if rerr != nil {
klog.Errorf("virtualMachineScaleSetsClient.CreateOrUpdate for scale set %q failed: %v", scaleSet.Name, rerr)
return rerr.Error()
Expand Down Expand Up @@ -322,7 +322,7 @@ func (scaleSet *ScaleSet) GetScaleSetVms() ([]compute.VirtualMachineScaleSetVM,
defer cancel()

resourceGroup := scaleSet.manager.config.ResourceGroup
vmList, rerr := scaleSet.manager.azureClients.virtualMachineScaleSetVMsClient.List(ctx, resourceGroup, scaleSet.Name, "instanceView")
vmList, rerr := scaleSet.manager.azClient.virtualMachineScaleSetVMsClient.List(ctx, resourceGroup, scaleSet.Name, "instanceView")
klog.V(4).Infof("GetScaleSetVms: scaleSet.Name: %s, vmList: %v", scaleSet.Name, vmList)
if rerr != nil {
klog.Errorf("VirtualMachineScaleSetVMsClient.List failed for %s: %v", scaleSet.Name, rerr)
Expand All @@ -348,7 +348,7 @@ func (scaleSet *ScaleSet) GetFlexibleScaleSetVms() ([]compute.VirtualMachine, *r
}
return nil, rerr
}
vmList, rerr := scaleSet.manager.azureClients.virtualMachinesClient.ListVmssFlexVMsWithoutInstanceView(ctx, *vmssInfo.ID)
vmList, rerr := scaleSet.manager.azClient.virtualMachinesClient.ListVmssFlexVMsWithoutInstanceView(ctx, *vmssInfo.ID)
if rerr != nil {
klog.Errorf("VirtualMachineScaleSetVMsClient.List failed for %s: %v", scaleSet.Name, rerr)
return nil, rerr
Expand Down Expand Up @@ -451,11 +451,11 @@ func (scaleSet *ScaleSet) DeleteInstances(instances []*azureRef, hasUnregistered

scaleSet.instanceMutex.Lock()
klog.V(3).Infof("Calling virtualMachineScaleSetsClient.DeleteInstancesAsync(%v), force delete set to %v", requiredIds.InstanceIds, scaleSet.enableForceDelete)
future, rerr := scaleSet.manager.azureClients.virtualMachineScaleSetsClient.DeleteInstancesAsync(ctx, resourceGroup, commonAsg.Id(), *requiredIds, scaleSet.enableForceDelete)
future, rerr := scaleSet.manager.azClient.virtualMachineScaleSetsClient.DeleteInstancesAsync(ctx, resourceGroup, commonAsg.Id(), *requiredIds, scaleSet.enableForceDelete)

if scaleSet.enableForceDelete && isOperationNotAllowed(rerr) {
klog.Infof("falling back to normal delete for instances %v for %s", requiredIds.InstanceIds, scaleSet.Name)
future, rerr = scaleSet.manager.azureClients.virtualMachineScaleSetsClient.DeleteInstancesAsync(ctx, resourceGroup,
future, rerr = scaleSet.manager.azClient.virtualMachineScaleSetsClient.DeleteInstancesAsync(ctx, resourceGroup,
commonAsg.Id(), *requiredIds, false)
}

Expand Down
10 changes: 5 additions & 5 deletions cluster-autoscaler/cloudprovider/azure/azure_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (util *AzUtil) DeleteBlob(accountName, vhdContainer, vhdBlob string) error
ctx, cancel := getContextWithCancel()
defer cancel()

storageKeysResult, rerr := util.manager.azureClients.storageAccountsClient.ListKeys(ctx, util.manager.config.SubscriptionID, util.manager.config.ResourceGroup, accountName)
storageKeysResult, rerr := util.manager.azClient.storageAccountsClient.ListKeys(ctx, util.manager.config.SubscriptionID, util.manager.config.ResourceGroup, accountName)
if rerr != nil {
return rerr.Error()
}
Expand All @@ -136,7 +136,7 @@ func (util *AzUtil) DeleteVirtualMachine(rg string, name string) error {
ctx, cancel := getContextWithCancel()
defer cancel()

vm, rerr := util.manager.azureClients.virtualMachinesClient.Get(ctx, rg, name, "")
vm, rerr := util.manager.azClient.virtualMachinesClient.Get(ctx, rg, name, "")
if rerr != nil {
if exists, _ := checkResourceExistsFromRetryError(rerr); !exists {
klog.V(2).Infof("VirtualMachine %s/%s has already been removed", rg, name)
Expand Down Expand Up @@ -173,7 +173,7 @@ func (util *AzUtil) DeleteVirtualMachine(rg string, name string) error {
defer deleteCancel()

klog.Infof("waiting for VirtualMachine deletion: %s/%s", rg, name)
rerr = util.manager.azureClients.virtualMachinesClient.Delete(deleteCtx, rg, name)
rerr = util.manager.azClient.virtualMachinesClient.Delete(deleteCtx, rg, name)
_, realErr := checkResourceExistsFromRetryError(rerr)
if realErr != nil {
return realErr
Expand All @@ -185,7 +185,7 @@ func (util *AzUtil) DeleteVirtualMachine(rg string, name string) error {
interfaceCtx, interfaceCancel := getContextWithCancel()
defer interfaceCancel()
klog.Infof("waiting for nic deletion: %s/%s", rg, nicName)
nicErr := util.manager.azureClients.interfacesClient.Delete(interfaceCtx, rg, nicName)
nicErr := util.manager.azClient.interfacesClient.Delete(interfaceCtx, rg, nicName)
_, realErr := checkResourceExistsFromRetryError(nicErr)
if realErr != nil {
return realErr
Expand Down Expand Up @@ -216,7 +216,7 @@ func (util *AzUtil) DeleteVirtualMachine(rg string, name string) error {
klog.Infof("deleting managed disk: %s/%s", rg, *osDiskName)
disksCtx, disksCancel := getContextWithCancel()
defer disksCancel()
diskErr := util.manager.azureClients.disksClient.Delete(disksCtx, util.manager.config.SubscriptionID, rg, *osDiskName)
diskErr := util.manager.azClient.disksClient.Delete(disksCtx, util.manager.config.SubscriptionID, rg, *osDiskName)
_, realErr := checkResourceExistsFromRetryError(diskErr)
if realErr != nil {
return realErr
Expand Down

0 comments on commit d07dbf2

Please sign in to comment.