mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 10:19:50 +00:00
naming, comment, typo correction
This commit is contained in:
parent
408f739618
commit
69abfa676d
@ -26,10 +26,10 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// getorCreateRequestBackoff returns a new Backoff object steps = 1
|
// getOrCreateRequestBackoff returns a new Backoff object steps = 1
|
||||||
// This is to make sure that the requested command executes
|
// This is to make sure that the requested command executes
|
||||||
// at least once
|
// at least once
|
||||||
func (az *Cloud) getorCreateRequestBackoff() (resourceRequestBackoff wait.Backoff) {
|
func (az *Cloud) getOrCreateRequestBackoff() (resourceRequestBackoff wait.Backoff) {
|
||||||
if az.CloudProviderBackoff {
|
if az.CloudProviderBackoff {
|
||||||
return az.resourceRequestBackoff
|
return az.resourceRequestBackoff
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ func (az *Cloud) getorCreateRequestBackoff() (resourceRequestBackoff wait.Backof
|
|||||||
func (az *Cloud) GetVirtualMachineWithRetry(name types.NodeName) (compute.VirtualMachine, bool, error) {
|
func (az *Cloud) GetVirtualMachineWithRetry(name types.NodeName) (compute.VirtualMachine, bool, error) {
|
||||||
var machine compute.VirtualMachine
|
var machine compute.VirtualMachine
|
||||||
var exists bool
|
var exists bool
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
machine, exists, retryErr = az.getVirtualMachine(name)
|
machine, exists, retryErr = az.getVirtualMachine(name)
|
||||||
if retryErr != nil {
|
if retryErr != nil {
|
||||||
@ -60,7 +60,7 @@ func (az *Cloud) GetVirtualMachineWithRetry(name types.NodeName) (compute.Virtua
|
|||||||
// VirtualMachineClientGetWithRetry invokes az.VirtualMachinesClient.Get with exponential backoff retry
|
// VirtualMachineClientGetWithRetry invokes az.VirtualMachinesClient.Get with exponential backoff retry
|
||||||
func (az *Cloud) VirtualMachineClientGetWithRetry(resourceGroup, vmName string, types compute.InstanceViewTypes) (compute.VirtualMachine, error) {
|
func (az *Cloud) VirtualMachineClientGetWithRetry(resourceGroup, vmName string, types compute.InstanceViewTypes) (compute.VirtualMachine, error) {
|
||||||
var machine compute.VirtualMachine
|
var machine compute.VirtualMachine
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
machine, retryErr = az.VirtualMachinesClient.Get(resourceGroup, vmName, types)
|
machine, retryErr = az.VirtualMachinesClient.Get(resourceGroup, vmName, types)
|
||||||
@ -78,7 +78,7 @@ func (az *Cloud) VirtualMachineClientGetWithRetry(resourceGroup, vmName string,
|
|||||||
func (az *Cloud) VirtualMachineClientListWithRetry() ([]compute.VirtualMachine, error) {
|
func (az *Cloud) VirtualMachineClientListWithRetry() ([]compute.VirtualMachine, error) {
|
||||||
allNodes := []compute.VirtualMachine{}
|
allNodes := []compute.VirtualMachine{}
|
||||||
var result compute.VirtualMachineListResult
|
var result compute.VirtualMachineListResult
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("VirtualMachinesClient.List(%v): start", az.ResourceGroup)
|
glog.V(10).Infof("VirtualMachinesClient.List(%v): start", az.ResourceGroup)
|
||||||
@ -103,7 +103,7 @@ func (az *Cloud) VirtualMachineClientListWithRetry() ([]compute.VirtualMachine,
|
|||||||
appendResults = false
|
appendResults = false
|
||||||
// follow the next link to get all the vms for resource group
|
// follow the next link to get all the vms for resource group
|
||||||
if result.NextLink != nil {
|
if result.NextLink != nil {
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("VirtualMachinesClient.ListNextResults(%v): start", az.ResourceGroup)
|
glog.V(10).Infof("VirtualMachinesClient.ListNextResults(%v): start", az.ResourceGroup)
|
||||||
@ -130,7 +130,7 @@ func (az *Cloud) VirtualMachineClientListWithRetry() ([]compute.VirtualMachine,
|
|||||||
// GetIPForMachineWithRetry invokes az.getIPForMachine with exponential backoff retry
|
// GetIPForMachineWithRetry invokes az.getIPForMachine with exponential backoff retry
|
||||||
func (az *Cloud) GetIPForMachineWithRetry(name types.NodeName) (string, error) {
|
func (az *Cloud) GetIPForMachineWithRetry(name types.NodeName) (string, error) {
|
||||||
var ip string
|
var ip string
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
ip, retryErr = az.getIPForMachine(name)
|
ip, retryErr = az.getIPForMachine(name)
|
||||||
if retryErr != nil {
|
if retryErr != nil {
|
||||||
@ -145,7 +145,7 @@ func (az *Cloud) GetIPForMachineWithRetry(name types.NodeName) (string, error) {
|
|||||||
|
|
||||||
// CreateOrUpdateSGWithRetry invokes az.SecurityGroupsClient.CreateOrUpdate with exponential backoff retry
|
// CreateOrUpdateSGWithRetry invokes az.SecurityGroupsClient.CreateOrUpdate with exponential backoff retry
|
||||||
func (az *Cloud) CreateOrUpdateSGWithRetry(sg network.SecurityGroup) error {
|
func (az *Cloud) CreateOrUpdateSGWithRetry(sg network.SecurityGroup) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("SecurityGroupsClient.CreateOrUpdate(%s): start", *sg.Name)
|
glog.V(10).Infof("SecurityGroupsClient.CreateOrUpdate(%s): start", *sg.Name)
|
||||||
respChan, errChan := az.SecurityGroupsClient.CreateOrUpdate(az.ResourceGroup, *sg.Name, sg, nil)
|
respChan, errChan := az.SecurityGroupsClient.CreateOrUpdate(az.ResourceGroup, *sg.Name, sg, nil)
|
||||||
@ -158,7 +158,7 @@ func (az *Cloud) CreateOrUpdateSGWithRetry(sg network.SecurityGroup) error {
|
|||||||
|
|
||||||
// CreateOrUpdateLBWithRetry invokes az.LoadBalancerClient.CreateOrUpdate with exponential backoff retry
|
// CreateOrUpdateLBWithRetry invokes az.LoadBalancerClient.CreateOrUpdate with exponential backoff retry
|
||||||
func (az *Cloud) CreateOrUpdateLBWithRetry(lb network.LoadBalancer) error {
|
func (az *Cloud) CreateOrUpdateLBWithRetry(lb network.LoadBalancer) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("LoadBalancerClient.CreateOrUpdate(%s): start", *lb.Name)
|
glog.V(10).Infof("LoadBalancerClient.CreateOrUpdate(%s): start", *lb.Name)
|
||||||
respChan, errChan := az.LoadBalancerClient.CreateOrUpdate(az.ResourceGroup, *lb.Name, lb, nil)
|
respChan, errChan := az.LoadBalancerClient.CreateOrUpdate(az.ResourceGroup, *lb.Name, lb, nil)
|
||||||
@ -169,12 +169,12 @@ func (az *Cloud) CreateOrUpdateLBWithRetry(lb network.LoadBalancer) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListLBWithRetry invokes az.VirtualMachinesClient.List with exponential backoff retry
|
// ListLBWithRetry invokes az.LoadBalancerClient.List with exponential backoff retry
|
||||||
func (az *Cloud) ListLBWithRetry() ([]network.LoadBalancer, error) {
|
func (az *Cloud) ListLBWithRetry() ([]network.LoadBalancer, error) {
|
||||||
allLBs := []network.LoadBalancer{}
|
allLBs := []network.LoadBalancer{}
|
||||||
var result network.LoadBalancerListResult
|
var result network.LoadBalancerListResult
|
||||||
|
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("LoadBalancerClient.List(%v): start", az.ResourceGroup)
|
glog.V(10).Infof("LoadBalancerClient.List(%v): start", az.ResourceGroup)
|
||||||
@ -200,7 +200,7 @@ func (az *Cloud) ListLBWithRetry() ([]network.LoadBalancer, error) {
|
|||||||
|
|
||||||
// follow the next link to get all the vms for resource group
|
// follow the next link to get all the vms for resource group
|
||||||
if result.NextLink != nil {
|
if result.NextLink != nil {
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("LoadBalancerClient.ListNextResults(%v): start", az.ResourceGroup)
|
glog.V(10).Infof("LoadBalancerClient.ListNextResults(%v): start", az.ResourceGroup)
|
||||||
@ -229,7 +229,7 @@ func (az *Cloud) ListLBWithRetry() ([]network.LoadBalancer, error) {
|
|||||||
func (az *Cloud) ListPIPWithRetry() ([]network.PublicIPAddress, error) {
|
func (az *Cloud) ListPIPWithRetry() ([]network.PublicIPAddress, error) {
|
||||||
allPIPs := []network.PublicIPAddress{}
|
allPIPs := []network.PublicIPAddress{}
|
||||||
var result network.PublicIPAddressListResult
|
var result network.PublicIPAddressListResult
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("PublicIPAddressesClient.List(%v): start", az.ResourceGroup)
|
glog.V(10).Infof("PublicIPAddressesClient.List(%v): start", az.ResourceGroup)
|
||||||
@ -255,7 +255,7 @@ func (az *Cloud) ListPIPWithRetry() ([]network.PublicIPAddress, error) {
|
|||||||
|
|
||||||
// follow the next link to get all the vms for resource group
|
// follow the next link to get all the vms for resource group
|
||||||
if result.NextLink != nil {
|
if result.NextLink != nil {
|
||||||
err := wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
err := wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
var retryErr error
|
var retryErr error
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("PublicIPAddressesClient.ListNextResults(%v): start", az.ResourceGroup)
|
glog.V(10).Infof("PublicIPAddressesClient.ListNextResults(%v): start", az.ResourceGroup)
|
||||||
@ -282,7 +282,7 @@ func (az *Cloud) ListPIPWithRetry() ([]network.PublicIPAddress, error) {
|
|||||||
|
|
||||||
// CreateOrUpdatePIPWithRetry invokes az.PublicIPAddressesClient.CreateOrUpdate with exponential backoff retry
|
// CreateOrUpdatePIPWithRetry invokes az.PublicIPAddressesClient.CreateOrUpdate with exponential backoff retry
|
||||||
func (az *Cloud) CreateOrUpdatePIPWithRetry(pip network.PublicIPAddress) error {
|
func (az *Cloud) CreateOrUpdatePIPWithRetry(pip network.PublicIPAddress) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("PublicIPAddressesClient.CreateOrUpdate(%s): start", *pip.Name)
|
glog.V(10).Infof("PublicIPAddressesClient.CreateOrUpdate(%s): start", *pip.Name)
|
||||||
respChan, errChan := az.PublicIPAddressesClient.CreateOrUpdate(az.ResourceGroup, *pip.Name, pip, nil)
|
respChan, errChan := az.PublicIPAddressesClient.CreateOrUpdate(az.ResourceGroup, *pip.Name, pip, nil)
|
||||||
@ -295,7 +295,7 @@ func (az *Cloud) CreateOrUpdatePIPWithRetry(pip network.PublicIPAddress) error {
|
|||||||
|
|
||||||
// CreateOrUpdateInterfaceWithRetry invokes az.PublicIPAddressesClient.CreateOrUpdate with exponential backoff retry
|
// CreateOrUpdateInterfaceWithRetry invokes az.PublicIPAddressesClient.CreateOrUpdate with exponential backoff retry
|
||||||
func (az *Cloud) CreateOrUpdateInterfaceWithRetry(nic network.Interface) error {
|
func (az *Cloud) CreateOrUpdateInterfaceWithRetry(nic network.Interface) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("InterfacesClient.CreateOrUpdate(%s): start", *nic.Name)
|
glog.V(10).Infof("InterfacesClient.CreateOrUpdate(%s): start", *nic.Name)
|
||||||
respChan, errChan := az.InterfacesClient.CreateOrUpdate(az.ResourceGroup, *nic.Name, nic, nil)
|
respChan, errChan := az.InterfacesClient.CreateOrUpdate(az.ResourceGroup, *nic.Name, nic, nil)
|
||||||
@ -308,7 +308,7 @@ func (az *Cloud) CreateOrUpdateInterfaceWithRetry(nic network.Interface) error {
|
|||||||
|
|
||||||
// DeletePublicIPWithRetry invokes az.PublicIPAddressesClient.Delete with exponential backoff retry
|
// DeletePublicIPWithRetry invokes az.PublicIPAddressesClient.Delete with exponential backoff retry
|
||||||
func (az *Cloud) DeletePublicIPWithRetry(pipName string) error {
|
func (az *Cloud) DeletePublicIPWithRetry(pipName string) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("PublicIPAddressesClient.Delete(%s): start", pipName)
|
glog.V(10).Infof("PublicIPAddressesClient.Delete(%s): start", pipName)
|
||||||
respChan, errChan := az.PublicIPAddressesClient.Delete(az.ResourceGroup, pipName, nil)
|
respChan, errChan := az.PublicIPAddressesClient.Delete(az.ResourceGroup, pipName, nil)
|
||||||
@ -321,7 +321,7 @@ func (az *Cloud) DeletePublicIPWithRetry(pipName string) error {
|
|||||||
|
|
||||||
// DeleteLBWithRetry invokes az.LoadBalancerClient.Delete with exponential backoff retry
|
// DeleteLBWithRetry invokes az.LoadBalancerClient.Delete with exponential backoff retry
|
||||||
func (az *Cloud) DeleteLBWithRetry(lbName string) error {
|
func (az *Cloud) DeleteLBWithRetry(lbName string) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("LoadBalancerClient.Delete(%s): start", lbName)
|
glog.V(10).Infof("LoadBalancerClient.Delete(%s): start", lbName)
|
||||||
respChan, errChan := az.LoadBalancerClient.Delete(az.ResourceGroup, lbName, nil)
|
respChan, errChan := az.LoadBalancerClient.Delete(az.ResourceGroup, lbName, nil)
|
||||||
@ -334,7 +334,7 @@ func (az *Cloud) DeleteLBWithRetry(lbName string) error {
|
|||||||
|
|
||||||
// CreateOrUpdateRouteTableWithRetry invokes az.RouteTablesClient.CreateOrUpdate with exponential backoff retry
|
// CreateOrUpdateRouteTableWithRetry invokes az.RouteTablesClient.CreateOrUpdate with exponential backoff retry
|
||||||
func (az *Cloud) CreateOrUpdateRouteTableWithRetry(routeTable network.RouteTable) error {
|
func (az *Cloud) CreateOrUpdateRouteTableWithRetry(routeTable network.RouteTable) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("RouteTablesClient.CreateOrUpdate(%s): start", *routeTable.Name)
|
glog.V(10).Infof("RouteTablesClient.CreateOrUpdate(%s): start", *routeTable.Name)
|
||||||
respChan, errChan := az.RouteTablesClient.CreateOrUpdate(az.ResourceGroup, az.RouteTableName, routeTable, nil)
|
respChan, errChan := az.RouteTablesClient.CreateOrUpdate(az.ResourceGroup, az.RouteTableName, routeTable, nil)
|
||||||
@ -347,7 +347,7 @@ func (az *Cloud) CreateOrUpdateRouteTableWithRetry(routeTable network.RouteTable
|
|||||||
|
|
||||||
// CreateOrUpdateRouteWithRetry invokes az.RoutesClient.CreateOrUpdate with exponential backoff retry
|
// CreateOrUpdateRouteWithRetry invokes az.RoutesClient.CreateOrUpdate with exponential backoff retry
|
||||||
func (az *Cloud) CreateOrUpdateRouteWithRetry(route network.Route) error {
|
func (az *Cloud) CreateOrUpdateRouteWithRetry(route network.Route) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("RoutesClient.CreateOrUpdate(%s): start", *route.Name)
|
glog.V(10).Infof("RoutesClient.CreateOrUpdate(%s): start", *route.Name)
|
||||||
respChan, errChan := az.RoutesClient.CreateOrUpdate(az.ResourceGroup, az.RouteTableName, *route.Name, route, nil)
|
respChan, errChan := az.RoutesClient.CreateOrUpdate(az.ResourceGroup, az.RouteTableName, *route.Name, route, nil)
|
||||||
@ -360,7 +360,7 @@ func (az *Cloud) CreateOrUpdateRouteWithRetry(route network.Route) error {
|
|||||||
|
|
||||||
// DeleteRouteWithRetry invokes az.RoutesClient.Delete with exponential backoff retry
|
// DeleteRouteWithRetry invokes az.RoutesClient.Delete with exponential backoff retry
|
||||||
func (az *Cloud) DeleteRouteWithRetry(routeName string) error {
|
func (az *Cloud) DeleteRouteWithRetry(routeName string) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("RoutesClient.Delete(%s): start", az.RouteTableName)
|
glog.V(10).Infof("RoutesClient.Delete(%s): start", az.RouteTableName)
|
||||||
respChan, errChan := az.RoutesClient.Delete(az.ResourceGroup, az.RouteTableName, routeName, nil)
|
respChan, errChan := az.RoutesClient.Delete(az.ResourceGroup, az.RouteTableName, routeName, nil)
|
||||||
@ -373,7 +373,7 @@ func (az *Cloud) DeleteRouteWithRetry(routeName string) error {
|
|||||||
|
|
||||||
// CreateOrUpdateVMWithRetry invokes az.VirtualMachinesClient.CreateOrUpdate with exponential backoff retry
|
// CreateOrUpdateVMWithRetry invokes az.VirtualMachinesClient.CreateOrUpdate with exponential backoff retry
|
||||||
func (az *Cloud) CreateOrUpdateVMWithRetry(vmName string, newVM compute.VirtualMachine) error {
|
func (az *Cloud) CreateOrUpdateVMWithRetry(vmName string, newVM compute.VirtualMachine) error {
|
||||||
return wait.ExponentialBackoff(az.getorCreateRequestBackoff(), func() (bool, error) {
|
return wait.ExponentialBackoff(az.getOrCreateRequestBackoff(), func() (bool, error) {
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("VirtualMachinesClient.CreateOrUpdate(%s): start", vmName)
|
glog.V(10).Infof("VirtualMachinesClient.CreateOrUpdate(%s): start", vmName)
|
||||||
respChan, errChan := az.VirtualMachinesClient.CreateOrUpdate(az.ResourceGroup, vmName, newVM, nil)
|
respChan, errChan := az.VirtualMachinesClient.CreateOrUpdate(az.ResourceGroup, vmName, newVM, nil)
|
||||||
|
@ -79,8 +79,8 @@ func (az *Cloud) EnsureLoadBalancer(clusterName string, service *v1.Service, nod
|
|||||||
// Here we'll firstly ensure service do not lie in the opposite LB.
|
// Here we'll firstly ensure service do not lie in the opposite LB.
|
||||||
serviceName := getServiceName(service)
|
serviceName := getServiceName(service)
|
||||||
glog.V(5).Infof("ensureloadbalancer(%s): START clusterName=%q", serviceName, clusterName)
|
glog.V(5).Infof("ensureloadbalancer(%s): START clusterName=%q", serviceName, clusterName)
|
||||||
flipedService := flipServiceInternalAnnotation(service)
|
flippedService := flipServiceInternalAnnotation(service)
|
||||||
if _, err := az.reconcileLoadBalancer(clusterName, flipedService, nil, false /* wantLb */); err != nil {
|
if _, err := az.reconcileLoadBalancer(clusterName, flippedService, nil, false /* wantLb */); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ func (az *Cloud) EnsureLoadBalancerDeleted(clusterName string, service *v1.Servi
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getServiceLoadBalancer gets the loadbalancer for the service if it already exits
|
// getServiceLoadBalancer gets the loadbalancer for the service if it already exists
|
||||||
// If wantLb is TRUE then -it selects a new load balancer
|
// If wantLb is TRUE then -it selects a new load balancer
|
||||||
// In case the selected load balancer does not exists it returns network.LoadBalancer struct
|
// In case the selected load balancer does not exists it returns network.LoadBalancer struct
|
||||||
// with added metadata (such as name, location) and existsLB set to FALSE
|
// with added metadata (such as name, location) and existsLB set to FALSE
|
||||||
@ -258,9 +258,11 @@ func (az *Cloud) determinePublicIPName(clusterName string, service *v1.Service)
|
|||||||
|
|
||||||
func flipServiceInternalAnnotation(service *v1.Service) *v1.Service {
|
func flipServiceInternalAnnotation(service *v1.Service) *v1.Service {
|
||||||
copyService := service.DeepCopy()
|
copyService := service.DeepCopy()
|
||||||
if _, ok := copyService.Annotations[ServiceAnnotationLoadBalancerInternal]; ok {
|
if v, ok := copyService.Annotations[ServiceAnnotationLoadBalancerInternal]; ok && v == "true" {
|
||||||
|
// If it is internal now, we make it external by remove the annotation
|
||||||
delete(copyService.Annotations, ServiceAnnotationLoadBalancerInternal)
|
delete(copyService.Annotations, ServiceAnnotationLoadBalancerInternal)
|
||||||
} else {
|
} else {
|
||||||
|
// If it is external now, we make it internal
|
||||||
copyService.Annotations[ServiceAnnotationLoadBalancerInternal] = "true"
|
copyService.Annotations[ServiceAnnotationLoadBalancerInternal] = "true"
|
||||||
}
|
}
|
||||||
return copyService
|
return copyService
|
||||||
@ -628,8 +630,8 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
|
|||||||
// If it is not exist, and no change to that, we don't CreateOrUpdate LB
|
// If it is not exist, and no change to that, we don't CreateOrUpdate LB
|
||||||
if dirtyLb {
|
if dirtyLb {
|
||||||
if lb.FrontendIPConfigurations == nil || len(*lb.FrontendIPConfigurations) == 0 {
|
if lb.FrontendIPConfigurations == nil || len(*lb.FrontendIPConfigurations) == 0 {
|
||||||
// When FrontendIPConfigurations is empty, we need to delete the Azure LoadBalancer resource itself
|
// When FrontendIPConfigurations is empty, we need to delete the Azure load balancer resource itself,
|
||||||
// Because delete all FrontendIPConfigurations in LB is not supported, we have to delete the LB itself
|
// because an Azure load balancer cannot have an empty FrontendIPConfigurations collection
|
||||||
glog.V(3).Infof("delete(%s): lb(%s) - deleting; no remaining frontendipconfigs", serviceName, lbName)
|
glog.V(3).Infof("delete(%s): lb(%s) - deleting; no remaining frontendipconfigs", serviceName, lbName)
|
||||||
|
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
@ -718,14 +720,6 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
az.operationPollRateLimiter.Accept()
|
|
||||||
glog.V(10).Infof("SecurityGroupsClient.Get(%q): start", az.SecurityGroupName)
|
|
||||||
sg, err = az.SecurityGroupsClient.Get(az.ResourceGroup, az.SecurityGroupName, "")
|
|
||||||
glog.V(10).Infof("SecurityGroupsClient.Get(%q): end", az.SecurityGroupName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
destinationIPAddress := ""
|
destinationIPAddress := ""
|
||||||
if wantLb {
|
if wantLb {
|
||||||
// Get lbIP since we make up NSG rules based on ingress IP
|
// Get lbIP since we make up NSG rules based on ingress IP
|
||||||
@ -846,7 +840,6 @@ func (az *Cloud) reconcileSecurityGroup(clusterName string, service *v1.Service,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This reconciles the PublicIP resources similar to how the LB is reconciled.
|
// This reconciles the PublicIP resources similar to how the LB is reconciled.
|
||||||
// This entails adding required, missing SecurityRules and removing stale rules.
|
|
||||||
func (az *Cloud) reconcilePublicIP(clusterName string, service *v1.Service, wantLb bool) (*network.PublicIPAddress, error) {
|
func (az *Cloud) reconcilePublicIP(clusterName string, service *v1.Service, wantLb bool) (*network.PublicIPAddress, error) {
|
||||||
isInternal := requiresInternalLoadBalancer(service)
|
isInternal := requiresInternalLoadBalancer(service)
|
||||||
serviceName := getServiceName(service)
|
serviceName := getServiceName(service)
|
||||||
@ -869,9 +862,7 @@ func (az *Cloud) reconcilePublicIP(clusterName string, service *v1.Service, want
|
|||||||
if wantLb && !isInternal && pipName == desiredPipName {
|
if wantLb && !isInternal && pipName == desiredPipName {
|
||||||
// This is the only case we should preserve the
|
// This is the only case we should preserve the
|
||||||
// Public ip resource with match service tag
|
// Public ip resource with match service tag
|
||||||
// We could do nothing here, we will ensure that out of the loop
|
|
||||||
} else {
|
} else {
|
||||||
// We use tag to decide which IP should be removed
|
|
||||||
glog.V(2).Infof("ensure(%s): pip(%s) - deleting", serviceName, pipName)
|
glog.V(2).Infof("ensure(%s): pip(%s) - deleting", serviceName, pipName)
|
||||||
az.operationPollRateLimiter.Accept()
|
az.operationPollRateLimiter.Accept()
|
||||||
glog.V(10).Infof("PublicIPAddressesClient.Delete(%q): start", pipName)
|
glog.V(10).Infof("PublicIPAddressesClient.Delete(%q): start", pipName)
|
||||||
@ -899,12 +890,12 @@ func (az *Cloud) reconcilePublicIP(clusterName string, service *v1.Service, want
|
|||||||
|
|
||||||
if !isInternal && wantLb {
|
if !isInternal && wantLb {
|
||||||
// Confirm desired public ip resource exists
|
// Confirm desired public ip resource exists
|
||||||
var rpip *network.PublicIPAddress
|
var pip *network.PublicIPAddress
|
||||||
domainNameLabel := getPublicIPLabel(service)
|
domainNameLabel := getPublicIPLabel(service)
|
||||||
if rpip, err = az.ensurePublicIPExists(serviceName, desiredPipName, domainNameLabel); err != nil {
|
if pip, err = az.ensurePublicIPExists(serviceName, desiredPipName, domainNameLabel); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return rpip, nil
|
return pip, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
@ -972,7 +963,7 @@ func (az *Cloud) ensureHostInPool(serviceName string, nodeName types.NodeName, b
|
|||||||
expectedAvailabilitySetName := az.getAvailabilitySetID(availabilitySetName)
|
expectedAvailabilitySetName := az.getAvailabilitySetID(availabilitySetName)
|
||||||
if machine.AvailabilitySet == nil || !strings.EqualFold(*machine.AvailabilitySet.ID, expectedAvailabilitySetName) {
|
if machine.AvailabilitySet == nil || !strings.EqualFold(*machine.AvailabilitySet.ID, expectedAvailabilitySetName) {
|
||||||
glog.V(3).Infof(
|
glog.V(3).Infof(
|
||||||
"nicupdate(%s): skipping nic (%s) since it is not in the availabilitSet(%s)",
|
"nicupdate(%s): skipping nic (%s) since it is not in the availabilitySet(%s)",
|
||||||
serviceName, nicName, availabilitySetName)
|
serviceName, nicName, availabilitySetName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ Service Annotation for Auto and specific load balancer mode
|
|||||||
- ensure Public IP with desiredPipName exists
|
- ensure Public IP with desiredPipName exists
|
||||||
|
|
||||||
- getServiceLoadBalancer(service *v1.Service, clusterName string, nodes []*v1.Node, wantLb bool) (lb, status, exists, error)
|
- getServiceLoadBalancer(service *v1.Service, clusterName string, nodes []*v1.Node, wantLb bool) (lb, status, exists, error)
|
||||||
- gets the loadbalancer for the service if it already exits
|
- gets the loadbalancer for the service if it already exists
|
||||||
- If wantLb is TRUE then -it selects a new load balancer, the selction helps distribute the services across load balancers
|
- If wantLb is TRUE then -it selects a new load balancer, the selction helps distribute the services across load balancers
|
||||||
- In case the selected load balancer does not exists it returns network.LoadBalancer struct with added metadata (such as name, location) and existsLB set to FALSE
|
- In case the selected load balancer does not exists it returns network.LoadBalancer struct with added metadata (such as name, location) and existsLB set to FALSE
|
||||||
- By default - cluster default LB is returned
|
- By default - cluster default LB is returned
|
||||||
@ -52,7 +52,7 @@ Service Annotation for Auto and specific load balancer mode
|
|||||||
|
|
||||||
### EnsureLoadBalancer
|
### EnsureLoadBalancer
|
||||||
|
|
||||||
- Reconcile LB for the fliped service
|
- Reconcile LB for the flipped service
|
||||||
- Call reconcileLoadBalancer(clusterName, flipedService, nil, false/* wantLb */)
|
- Call reconcileLoadBalancer(clusterName, flipedService, nil, false/* wantLb */)
|
||||||
- Reconcile Public IP
|
- Reconcile Public IP
|
||||||
- Call reconcilePublicIP(cluster, service, true)
|
- Call reconcilePublicIP(cluster, service, true)
|
||||||
|
@ -127,12 +127,12 @@ func testLoadBalancerServiceDefaultModeSelection(t *testing.T, isInternal bool)
|
|||||||
|
|
||||||
ruleCount := len(*lb.LoadBalancingRules)
|
ruleCount := len(*lb.LoadBalancingRules)
|
||||||
if ruleCount != index {
|
if ruleCount != index {
|
||||||
t.Errorf("lb rule could should be equal to nuber of services deployed, expected (%d) Found (%d)", index, ruleCount)
|
t.Errorf("lb rule count should be equal to nuber of services deployed, expected (%d) Found (%d)", index, ruleCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate even distribution of external services across load balances
|
// Validate even distribution of external services across load balancers
|
||||||
// based on number of availability sets
|
// based on number of availability sets
|
||||||
func testLoadBalancerServiceAutoModeSelection(t *testing.T, isInternal bool) {
|
func testLoadBalancerServiceAutoModeSelection(t *testing.T, isInternal bool) {
|
||||||
az := getTestCloud()
|
az := getTestCloud()
|
||||||
@ -173,8 +173,7 @@ func testLoadBalancerServiceAutoModeSelection(t *testing.T, isInternal bool) {
|
|||||||
|
|
||||||
maxRules := 0
|
maxRules := 0
|
||||||
minRules := serviceCount
|
minRules := serviceCount
|
||||||
for x := range *result.Value {
|
for _, lb := range *result.Value {
|
||||||
lb := (*result.Value)[x]
|
|
||||||
ruleCount := len(*lb.LoadBalancingRules)
|
ruleCount := len(*lb.LoadBalancingRules)
|
||||||
if ruleCount < minRules {
|
if ruleCount < minRules {
|
||||||
minRules = ruleCount
|
minRules = ruleCount
|
||||||
@ -737,7 +736,7 @@ func TestReconcilePublicIPWithNewService(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error: %q", err)
|
t.Errorf("Unexpected error: %q", err)
|
||||||
}
|
}
|
||||||
validatePublicIP(t, pip, &svc, true)
|
validatePublicIP(t, pip2, &svc, true)
|
||||||
if pip.Name != pip2.Name ||
|
if pip.Name != pip2.Name ||
|
||||||
pip.PublicIPAddressPropertiesFormat.IPAddress != pip2.PublicIPAddressPropertiesFormat.IPAddress {
|
pip.PublicIPAddressPropertiesFormat.IPAddress != pip2.PublicIPAddressPropertiesFormat.IPAddress {
|
||||||
t.Errorf("We should get the exact same public ip resource after a second reconcile")
|
t.Errorf("We should get the exact same public ip resource after a second reconcile")
|
||||||
@ -814,7 +813,7 @@ func getTestCloud() (az *Cloud) {
|
|||||||
SubnetName: "subnet",
|
SubnetName: "subnet",
|
||||||
SecurityGroupName: "nsg",
|
SecurityGroupName: "nsg",
|
||||||
RouteTableName: "rt",
|
RouteTableName: "rt",
|
||||||
PrimaryAvailabilitySetName: "asName",
|
PrimaryAvailabilitySetName: "as",
|
||||||
MaximumLoadBalancerRuleCount: 250,
|
MaximumLoadBalancerRuleCount: 250,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -832,8 +831,8 @@ func getTestCloud() (az *Cloud) {
|
|||||||
const networkInterfacesIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkInterfaces/%s"
|
const networkInterfacesIDTemplate = "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkInterfaces/%s"
|
||||||
const primaryIPConfigIDTemplate = "%s/ipConfigurations/ipconfig"
|
const primaryIPConfigIDTemplate = "%s/ipConfigurations/ipconfig"
|
||||||
|
|
||||||
// returns the full identifier of a publicIPAddress.
|
// returns the full identifier of Network Interface.
|
||||||
func getNetworkInterfacesID(subscriptionID string, resourceGroupName, nicName string) string {
|
func getNetworkInterfaceID(subscriptionID string, resourceGroupName, nicName string) string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
networkInterfacesIDTemplate,
|
networkInterfacesIDTemplate,
|
||||||
subscriptionID,
|
subscriptionID,
|
||||||
@ -892,7 +891,7 @@ func getClusterResources(az *Cloud, vmCount int, availabilitySetCount int) (clus
|
|||||||
clusterResources.availabilitySetNames = append(clusterResources.availabilitySetNames, asName)
|
clusterResources.availabilitySetNames = append(clusterResources.availabilitySetNames, asName)
|
||||||
|
|
||||||
nicName := getNICName(vmIndex)
|
nicName := getNICName(vmIndex)
|
||||||
nicID := getNetworkInterfacesID(az.Config.SubscriptionID, az.Config.ResourceGroup, nicName)
|
nicID := getNetworkInterfaceID(az.Config.SubscriptionID, az.Config.ResourceGroup, nicName)
|
||||||
primaryIPConfigID := getPrimaryIPConfigID(nicID)
|
primaryIPConfigID := getPrimaryIPConfigID(nicID)
|
||||||
isPrimary := true
|
isPrimary := true
|
||||||
newNIC := network.Interface{
|
newNIC := network.Interface{
|
||||||
|
Loading…
Reference in New Issue
Block a user