"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go" between
kubernetes-1.15.9.tar.gz and kubernetes-1.15.10.tar.gz

About: Kubernetes is a platform for automating deployment, scaling, and operations of application containers across clusters of hosts (written in "Go"). 1.15.x series.

azure_vmss.go  (kubernetes-1.15.9):azure_vmss.go  (kubernetes-1.15.10)
skipping to change at line 114 skipping to change at line 114
} }
vmss, err := getter(vmssName) vmss, err := getter(vmssName)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if vmss != nil { if vmss != nil {
return vmss, nil return vmss, nil
} }
klog.V(3).Infof("Couldn't find VMSS with name %s, refreshing the cache", vmssName) klog.V(2).Infof("Couldn't find VMSS with name %s, refreshing the cache", vmssName)
ss.vmssCache.Delete(vmssKey) ss.vmssCache.Delete(vmssKey)
vmss, err = getter(vmssName) vmss, err = getter(vmssName)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if vmss == nil { if vmss == nil {
return nil, cloudprovider.InstanceNotFound return nil, cloudprovider.InstanceNotFound
} }
return vmss, nil return vmss, nil
} }
// getVmssVM gets virtualMachineScaleSetVM by nodeName from cache. // getVmssVM gets virtualMachineScaleSetVM by nodeName from cache.
// It returns cloudprovider.InstanceNotFound if node does not belong to any scal e sets. // It returns cloudprovider.InstanceNotFound if node does not belong to any scal e sets.
func (ss *scaleSet) getVmssVM(nodeName string, crt cacheReadType) (string, strin g, *compute.VirtualMachineScaleSetVM, error) { func (ss *scaleSet) getVmssVM(nodeName string, crt cacheReadType) (string, strin g, *compute.VirtualMachineScaleSetVM, error) {
getter := func(nodeName string) (string, string, *compute.VirtualMachineS getter := func(nodeName string, crt cacheReadType) (string, string, *comp
caleSetVM, error) { ute.VirtualMachineScaleSetVM, bool, error) {
var found bool
cached, err := ss.vmssVMCache.Get(vmssVirtualMachinesKey, crt) cached, err := ss.vmssVMCache.Get(vmssVirtualMachinesKey, crt)
if err != nil { if err != nil {
return "", "", nil, err return "", "", nil, found, err
} }
virtualMachines := cached.(*sync.Map) virtualMachines := cached.(*sync.Map)
if vm, ok := virtualMachines.Load(nodeName); ok { if vm, ok := virtualMachines.Load(nodeName); ok {
result := vm.(*vmssVirtualMachinesEntry) result := vm.(*vmssVirtualMachinesEntry)
return result.vmssName, result.instanceID, result.virtual found = true
Machine, nil return result.vmssName, result.instanceID, result.virtual
Machine, found, nil
} }
return "", "", nil, nil return "", "", nil, found, nil
} }
_, err := getScaleSetVMInstanceID(nodeName) _, err := getScaleSetVMInstanceID(nodeName)
if err != nil { if err != nil {
return "", "", nil, err return "", "", nil, err
} }
vmssName, instanceID, vm, err := getter(nodeName) vmssName, instanceID, vm, found, err := getter(nodeName, crt)
if err != nil { if err != nil {
return "", "", nil, err return "", "", nil, err
} }
if vm != nil {
return vmssName, instanceID, vm, nil if !found {
klog.V(2).Infof("Couldn't find VMSS VM with nodeName %s, refreshi
ng the cache", nodeName)
vmssName, instanceID, vm, found, err = getter(nodeName, cacheRead
TypeForceRefresh)
if err != nil {
return "", "", nil, err
}
} }
klog.V(3).Infof("Couldn't find VMSS VM with nodeName %s, refreshing the c if found && vm != nil {
ache", nodeName) return vmssName, instanceID, vm, nil
ss.vmssVMCache.Delete(vmssVirtualMachinesKey)
vmssName, instanceID, vm, err = getter(nodeName)
if err != nil {
return "", "", nil, err
} }
if vm == nil { if !found || vm == nil {
return "", "", nil, cloudprovider.InstanceNotFound return "", "", nil, cloudprovider.InstanceNotFound
} }
return vmssName, instanceID, vm, nil return vmssName, instanceID, vm, nil
} }
// GetPowerStatusByNodeName returns the power state of the specified node. // GetPowerStatusByNodeName returns the power state of the specified node.
func (ss *scaleSet) GetPowerStatusByNodeName(name string) (powerState string, er r error) { func (ss *scaleSet) GetPowerStatusByNodeName(name string) (powerState string, er r error) {
_, _, vm, err := ss.getVmssVM(name, cacheReadTypeDefault) _, _, vm, err := ss.getVmssVM(name, cacheReadTypeDefault)
if err != nil { if err != nil {
return powerState, err return powerState, err
skipping to change at line 194 skipping to change at line 198
} }
} }
} }
return "", fmt.Errorf("failed to get power status for node %q", name) return "", fmt.Errorf("failed to get power status for node %q", name)
} }
// getCachedVirtualMachineByInstanceID gets scaleSetVMInfo from cache. // getCachedVirtualMachineByInstanceID gets scaleSetVMInfo from cache.
// The node must belong to one of scale sets. // The node must belong to one of scale sets.
func (ss *scaleSet) getVmssVMByInstanceID(resourceGroup, scaleSetName, instanceI D string, crt cacheReadType) (*compute.VirtualMachineScaleSetVM, error) { func (ss *scaleSet) getVmssVMByInstanceID(resourceGroup, scaleSetName, instanceI D string, crt cacheReadType) (*compute.VirtualMachineScaleSetVM, error) {
getter := func() (vm *compute.VirtualMachineScaleSetVM, found bool, err e rror) { getter := func(crt cacheReadType) (vm *compute.VirtualMachineScaleSetVM, found bool, err error) {
cached, err := ss.vmssVMCache.Get(vmssVirtualMachinesKey, crt) cached, err := ss.vmssVMCache.Get(vmssVirtualMachinesKey, crt)
if err != nil { if err != nil {
return nil, false, err return nil, false, err
} }
virtualMachines := cached.(*sync.Map) virtualMachines := cached.(*sync.Map)
virtualMachines.Range(func(key, value interface{}) bool { virtualMachines.Range(func(key, value interface{}) bool {
vmEntry := value.(*vmssVirtualMachinesEntry) vmEntry := value.(*vmssVirtualMachinesEntry)
if strings.EqualFold(vmEntry.resourceGroup, resourceGroup ) && if strings.EqualFold(vmEntry.resourceGroup, resourceGroup ) &&
strings.EqualFold(vmEntry.vmssName, scaleSetName) && strings.EqualFold(vmEntry.vmssName, scaleSetName) &&
skipping to change at line 217 skipping to change at line 221
found = true found = true
return false return false
} }
return true return true
}) })
return vm, found, nil return vm, found, nil
} }
vm, found, err := getter() vm, found, err := getter(crt)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if found { if !found {
return vm, nil klog.V(2).Infof("Couldn't find VMSS VM with scaleSetName %q and i
nstanceID %q, refreshing the cache", scaleSetName, instanceID)
vm, found, err = getter(cacheReadTypeForceRefresh)
if err != nil {
return nil, err
}
} }
if found && vm != nil {
klog.V(3).Infof("Couldn't find VMSS VM with scaleSetName %q and instanceI return vm, nil
D %q, refreshing the cache", scaleSetName, instanceID)
ss.vmssVMCache.Delete(vmssVirtualMachinesKey)
vm, found, err = getter()
if err != nil {
return nil, err
} }
if !found { if !found || vm == nil {
return nil, cloudprovider.InstanceNotFound return nil, cloudprovider.InstanceNotFound
} }
return vm, nil return vm, nil
} }
// GetInstanceIDByNodeName gets the cloud provider ID by node name. // GetInstanceIDByNodeName gets the cloud provider ID by node name.
// It must return ("", cloudprovider.InstanceNotFound) if the instance does // It must return ("", cloudprovider.InstanceNotFound) if the instance does
// not exist or is no longer running. // not exist or is no longer running.
func (ss *scaleSet) GetInstanceIDByNodeName(name string) (string, error) { func (ss *scaleSet) GetInstanceIDByNodeName(name string) (string, error) {
 End of changes. 14 change blocks. 
29 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)