Unverified Commit 0726f8c7 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #58798 from feiskyer/cleanup

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Clean up unused functions and consts **What this PR does / why we need it**: Clean up unused functions and consts. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents 7726877a 6c2c5c26
...@@ -311,14 +311,9 @@ func initDiskControllers(az *Cloud) error { ...@@ -311,14 +311,9 @@ func initDiskControllers(az *Cloud) error {
// needed by both blob disk and managed disk controllers // needed by both blob disk and managed disk controllers
common := &controllerCommon{ common := &controllerCommon{
aadResourceEndPoint: az.Environment.ServiceManagementEndpoint,
clientID: az.AADClientID,
clientSecret: az.AADClientSecret,
location: az.Location, location: az.Location,
storageEndpointSuffix: az.Environment.StorageEndpointSuffix, storageEndpointSuffix: az.Environment.StorageEndpointSuffix,
managementEndpoint: az.Environment.ResourceManagerEndpoint,
resourceGroup: az.ResourceGroup, resourceGroup: az.ResourceGroup,
tokenEndPoint: az.Environment.ActiveDirectoryEndpoint,
subscriptionID: az.SubscriptionID, subscriptionID: az.SubscriptionID,
cloud: az, cloud: az,
} }
......
...@@ -637,18 +637,6 @@ func (c *BlobDiskController) getNextAccountNum() int { ...@@ -637,18 +637,6 @@ func (c *BlobDiskController) getNextAccountNum() int {
return max + 1 return max + 1
} }
func (c *BlobDiskController) deleteStorageAccount(storageAccountName string) error {
resp, err := c.common.cloud.StorageAccountClient.Delete(c.common.resourceGroup, storageAccountName)
if err != nil {
return fmt.Errorf("azureDisk - Delete of storage account '%s' failed with status %s...%v", storageAccountName, resp.Status, err)
}
c.removeAccountState(storageAccountName)
glog.Infof("azureDisk - Storage Account %s was deleted", storageAccountName)
return nil
}
//Gets storage account exist, provisionStatus, Error if any //Gets storage account exist, provisionStatus, Error if any
func (c *BlobDiskController) getStorageAccountState(storageAccountName string) (bool, storage.ProvisioningState, error) { func (c *BlobDiskController) getStorageAccountState(storageAccountName string) (bool, storage.ProvisioningState, error) {
account, err := c.common.cloud.StorageAccountClient.GetProperties(c.common.resourceGroup, storageAccountName) account, err := c.common.cloud.StorageAccountClient.GetProperties(c.common.resourceGroup, storageAccountName)
...@@ -667,12 +655,6 @@ func (c *BlobDiskController) addAccountState(key string, state *storageAccountSt ...@@ -667,12 +655,6 @@ func (c *BlobDiskController) addAccountState(key string, state *storageAccountSt
} }
} }
func (c *BlobDiskController) removeAccountState(key string) {
accountsLock.Lock()
defer accountsLock.Unlock()
delete(c.accounts, key)
}
// pads account num with zeros as needed // pads account num with zeros as needed
func getAccountNameForNum(num int) string { func getAccountNameForNum(num int) string {
sNum := strconv.Itoa(num) sNum := strconv.Itoa(num)
......
...@@ -30,14 +30,12 @@ import ( ...@@ -30,14 +30,12 @@ import (
) )
const ( const (
defaultDataDiskCount int = 16 // which will allow you to work with most medium size VMs (if not found in map) storageAccountNameTemplate = "pvc%s"
storageAccountNameTemplate = "pvc%s"
// for limits check https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#storage-limits // for limits check https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#storage-limits
maxStorageAccounts = 100 // max # is 200 (250 with special request). this allows 100 for everything else including stand alone disks maxStorageAccounts = 100 // max # is 200 (250 with special request). this allows 100 for everything else including stand alone disks
maxDisksPerStorageAccounts = 60 maxDisksPerStorageAccounts = 60
storageAccountUtilizationBeforeGrowing = 0.5 storageAccountUtilizationBeforeGrowing = 0.5
storageAccountsCountInit = 2 // When the plug-in is init-ed, 2 storage accounts will be created to allow fast pvc create/attach/mount
maxLUN = 64 // max number of LUNs per VM maxLUN = 64 // max number of LUNs per VM
errLeaseFailed = "AcquireDiskLeaseFailed" errLeaseFailed = "AcquireDiskLeaseFailed"
...@@ -58,13 +56,6 @@ type controllerCommon struct { ...@@ -58,13 +56,6 @@ type controllerCommon struct {
location string location string
storageEndpointSuffix string storageEndpointSuffix string
resourceGroup string resourceGroup string
clientID string
clientSecret string
managementEndpoint string
tokenEndPoint string
aadResourceEndPoint string
aadToken string
expiresOn time.Time
cloud *Cloud cloud *Cloud
} }
......
...@@ -119,9 +119,3 @@ func (az *Cloud) CurrentNodeName(hostname string) (types.NodeName, error) { ...@@ -119,9 +119,3 @@ func (az *Cloud) CurrentNodeName(hostname string) (types.NodeName, error) {
func mapNodeNameToVMName(nodeName types.NodeName) string { func mapNodeNameToVMName(nodeName types.NodeName) string {
return string(nodeName) return string(nodeName)
} }
// mapVMNameToNodeName maps an Azure VM Name to a k8s NodeName
// This is a simple string cast.
func mapVMNameToNodeName(vmName string) types.NodeName {
return types.NodeName(vmName)
}
...@@ -45,9 +45,7 @@ const ( ...@@ -45,9 +45,7 @@ const (
availabilitySetIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/availabilitySets/%s" availabilitySetIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/availabilitySets/%s"
frontendIPConfigIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/frontendIPConfigurations/%s" frontendIPConfigIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/frontendIPConfigurations/%s"
backendPoolIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/backendAddressPools/%s" backendPoolIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/backendAddressPools/%s"
loadBalancerRuleIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/loadBalancingRules/%s"
loadBalancerProbeIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/probes/%s" loadBalancerProbeIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/probes/%s"
securityRuleIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s"
// InternalLoadBalancerNameSuffix is load balancer posfix // InternalLoadBalancerNameSuffix is load balancer posfix
InternalLoadBalancerNameSuffix = "-internal" InternalLoadBalancerNameSuffix = "-internal"
...@@ -97,16 +95,6 @@ func (az *Cloud) getBackendPoolID(lbName, backendPoolName string) string { ...@@ -97,16 +95,6 @@ func (az *Cloud) getBackendPoolID(lbName, backendPoolName string) string {
backendPoolName) backendPoolName)
} }
// returns the full identifier of a loadbalancer rule.
func (az *Cloud) getLoadBalancerRuleID(lbName, lbRuleName string) string {
return fmt.Sprintf(
loadBalancerRuleIDTemplate,
az.SubscriptionID,
az.ResourceGroup,
lbName,
lbRuleName)
}
// returns the full identifier of a loadbalancer probe. // returns the full identifier of a loadbalancer probe.
func (az *Cloud) getLoadBalancerProbeID(lbName, lbRuleName string) string { func (az *Cloud) getLoadBalancerProbeID(lbName, lbRuleName string) string {
return fmt.Sprintf( return fmt.Sprintf(
...@@ -117,25 +105,6 @@ func (az *Cloud) getLoadBalancerProbeID(lbName, lbRuleName string) string { ...@@ -117,25 +105,6 @@ func (az *Cloud) getLoadBalancerProbeID(lbName, lbRuleName string) string {
lbRuleName) lbRuleName)
} }
// returns the full identifier of a network security group security rule.
func (az *Cloud) getSecurityRuleID(securityRuleName string) string {
return fmt.Sprintf(
securityRuleIDTemplate,
az.SubscriptionID,
az.ResourceGroup,
az.SecurityGroupName,
securityRuleName)
}
// returns the full identifier of a publicIPAddress.
func (az *Cloud) getpublicIPAddressID(pipName string) string {
return fmt.Sprintf(
publicIPAddressIDTemplate,
az.SubscriptionID,
az.ResourceGroup,
pipName)
}
func (az *Cloud) mapLoadBalancerNameToVMSet(lbName string, clusterName string) (vmSetName string) { func (az *Cloud) mapLoadBalancerNameToVMSet(lbName string, clusterName string) (vmSetName string) {
vmSetName = strings.TrimSuffix(lbName, InternalLoadBalancerNameSuffix) vmSetName = strings.TrimSuffix(lbName, InternalLoadBalancerNameSuffix)
if strings.EqualFold(clusterName, lbName) { if strings.EqualFold(clusterName, lbName) {
......
...@@ -861,14 +861,17 @@ func getTestCloud() (az *Cloud) { ...@@ -861,14 +861,17 @@ func getTestCloud() (az *Cloud) {
MaximumLoadBalancerRuleCount: 250, MaximumLoadBalancerRuleCount: 250,
}, },
} }
az.DisksClient = newFakeDisksClient()
az.InterfacesClient = newFakeAzureInterfacesClient()
az.LoadBalancerClient = newFakeAzureLBClient() az.LoadBalancerClient = newFakeAzureLBClient()
az.PublicIPAddressesClient = newFakeAzurePIPClient(az.Config.SubscriptionID) az.PublicIPAddressesClient = newFakeAzurePIPClient(az.Config.SubscriptionID)
az.SubnetsClient = newFakeAzureSubnetsClient() az.RoutesClient = newFakeRoutesClient()
az.RouteTablesClient = newFakeRouteTablesClient()
az.SecurityGroupsClient = newFakeAzureNSGClient() az.SecurityGroupsClient = newFakeAzureNSGClient()
az.VirtualMachinesClient = newFakeAzureVirtualMachinesClient() az.SubnetsClient = newFakeAzureSubnetsClient()
az.InterfacesClient = newFakeAzureInterfacesClient()
az.VirtualMachineScaleSetsClient = newFakeVirtualMachineScaleSetsClient() az.VirtualMachineScaleSetsClient = newFakeVirtualMachineScaleSetsClient()
az.VirtualMachineScaleSetVMsClient = newFakeVirtualMachineScaleSetVMsClient() az.VirtualMachineScaleSetVMsClient = newFakeVirtualMachineScaleSetVMsClient()
az.VirtualMachinesClient = newFakeAzureVirtualMachinesClient()
az.vmSet = newAvailabilitySet(az) az.vmSet = newAvailabilitySet(az)
return az return az
......
...@@ -131,54 +131,6 @@ func (az *Cloud) getRouteTable() (routeTable network.RouteTable, exists bool, er ...@@ -131,54 +131,6 @@ func (az *Cloud) getRouteTable() (routeTable network.RouteTable, exists bool, er
return routeTable, exists, err return routeTable, exists, err
} }
func (az *Cloud) getSecurityGroup() (sg network.SecurityGroup, exists bool, err error) {
var realErr error
sg, err = az.SecurityGroupsClient.Get(az.ResourceGroup, az.SecurityGroupName, "")
exists, realErr = checkResourceExistsFromError(err)
if realErr != nil {
return sg, false, realErr
}
if !exists {
return sg, false, nil
}
return sg, exists, err
}
func (az *Cloud) getAzureLoadBalancer(name string) (lb network.LoadBalancer, exists bool, err error) {
var realErr error
lb, err = az.LoadBalancerClient.Get(az.ResourceGroup, name, "")
exists, realErr = checkResourceExistsFromError(err)
if realErr != nil {
return lb, false, realErr
}
if !exists {
return lb, false, nil
}
return lb, exists, err
}
func (az *Cloud) listLoadBalancers() (lbListResult network.LoadBalancerListResult, exists bool, err error) {
var realErr error
lbListResult, err = az.LoadBalancerClient.List(az.ResourceGroup)
exists, realErr = checkResourceExistsFromError(err)
if realErr != nil {
return lbListResult, false, realErr
}
if !exists {
return lbListResult, false, nil
}
return lbListResult, exists, err
}
func (az *Cloud) getPublicIPAddress(pipResourceGroup string, pipName string) (pip network.PublicIPAddress, exists bool, err error) { func (az *Cloud) getPublicIPAddress(pipResourceGroup string, pipName string) (pip network.PublicIPAddress, exists bool, err error) {
resourceGroup := az.ResourceGroup resourceGroup := az.ResourceGroup
if pipResourceGroup != "" { if pipResourceGroup != "" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment