@@ -693,77 +693,32 @@ func (az *Cloud) deleteRouteWithRetry(routeName string) error {
693
693
})
694
694
}
695
695
696
- // UpdateVmssVMWithRetry invokes az.VirtualMachineScaleSetVMsClient.Update with exponential backoff retry
697
- func (az * Cloud ) UpdateVmssVMWithRetry (resourceGroupName string , VMScaleSetName string , instanceID string , parameters compute.VirtualMachineScaleSetVM , source string ) error {
698
- return wait .ExponentialBackoff (az .RequestBackoff (), func () (bool , error ) {
699
- ctx , cancel := getContextWithCancel ()
700
- defer cancel ()
701
-
702
- rerr := az .VirtualMachineScaleSetVMsClient .Update (ctx , resourceGroupName , VMScaleSetName , instanceID , parameters , source )
703
- klog .V (10 ).Infof ("UpdateVmssVMWithRetry: VirtualMachineScaleSetVMsClient.Update(%s,%s): end" , VMScaleSetName , instanceID )
704
- if rerr == nil {
705
- return true , nil
706
- }
707
-
708
- if strings .Contains (rerr .Error ().Error (), vmssVMNotActiveErrorMessage ) {
709
- // When instances are under deleting, updating API would report "not an active Virtual Machine Scale Set VM instanceId" error.
710
- // Since they're under deleting, we shouldn't send more update requests for it.
711
- klog .V (3 ).Infof ("UpdateVmssVMWithRetry: VirtualMachineScaleSetVMsClient.Update(%s,%s) gets error message %q, abort backoff because it's probably under deleting" , VMScaleSetName , instanceID , vmssVMNotActiveErrorMessage )
712
- return true , nil
713
- }
714
-
715
- return ! rerr .Retriable , rerr .Error ()
716
- })
717
- }
718
-
719
- // CreateOrUpdateVmssWithRetry invokes az.VirtualMachineScaleSetsClient.Update with exponential backoff retry
720
- func (az * Cloud ) CreateOrUpdateVmssWithRetry (resourceGroupName string , VMScaleSetName string , parameters compute.VirtualMachineScaleSet ) error {
721
- return wait .ExponentialBackoff (az .RequestBackoff (), func () (bool , error ) {
722
- ctx , cancel := getContextWithCancel ()
723
- defer cancel ()
724
-
725
- // When vmss is being deleted, CreateOrUpdate API would report "the vmss is being deleted" error.
726
- // Since it is being deleted, we shouldn't send more CreateOrUpdate requests for it.
727
- klog .V (3 ).Infof ("CreateOrUpdateVmssWithRetry: verify the status of the vmss being created or updated" )
728
- vmss , rerr := az .VirtualMachineScaleSetsClient .Get (ctx , resourceGroupName , VMScaleSetName )
729
- if rerr != nil {
730
- klog .Warningf ("CreateOrUpdateVmssWithRetry: error getting vmss: %v" , rerr )
731
- }
732
- if vmss .ProvisioningState != nil && strings .EqualFold (* vmss .ProvisioningState , virtualMachineScaleSetsDeallocating ) {
733
- klog .V (3 ).Infof ("CreateOrUpdateVmssWithRetry: found vmss %s being deleted, skipping" , VMScaleSetName )
734
- return true , nil
735
- }
736
-
737
- rerr = az .VirtualMachineScaleSetsClient .CreateOrUpdate (ctx , resourceGroupName , VMScaleSetName , parameters )
738
- klog .V (10 ).Infof ("UpdateVmssVMWithRetry: VirtualMachineScaleSetsClient.CreateOrUpdate(%s): end" , VMScaleSetName )
739
- if rerr == nil {
740
- return true , nil
741
- }
742
-
743
- return ! rerr .Retriable , rerr .Error ()
744
- })
745
- }
746
-
747
- // GetScaleSetWithRetry gets scale set with exponential backoff retry
748
- func (az * Cloud ) GetScaleSetWithRetry (service * v1.Service , resourceGroupName , vmssName string ) (compute.VirtualMachineScaleSet , error ) {
749
- var result compute.VirtualMachineScaleSet
750
- var retryErr * retry.Error
751
-
752
- err := wait .ExponentialBackoff (az .RequestBackoff (), func () (bool , error ) {
753
- ctx , cancel := getContextWithCancel ()
754
- defer cancel ()
696
+ // CreateOrUpdateVMSS invokes az.VirtualMachineScaleSetsClient.Update().
697
+ func (az * Cloud ) CreateOrUpdateVMSS (resourceGroupName string , VMScaleSetName string , parameters compute.VirtualMachineScaleSet ) * retry.Error {
698
+ ctx , cancel := getContextWithCancel ()
699
+ defer cancel ()
700
+
701
+ // When vmss is being deleted, CreateOrUpdate API would report "the vmss is being deleted" error.
702
+ // Since it is being deleted, we shouldn't send more CreateOrUpdate requests for it.
703
+ klog .V (3 ).Infof ("CreateOrUpdateVMSS: verify the status of the vmss being created or updated" )
704
+ vmss , rerr := az .VirtualMachineScaleSetsClient .Get (ctx , resourceGroupName , VMScaleSetName )
705
+ if rerr != nil {
706
+ klog .Errorf ("CreateOrUpdateVMSS: error getting vmss(%s): %v" , VMScaleSetName , rerr )
707
+ return rerr
708
+ }
709
+ if vmss .ProvisioningState != nil && strings .EqualFold (* vmss .ProvisioningState , virtualMachineScaleSetsDeallocating ) {
710
+ klog .V (3 ).Infof ("CreateOrUpdateVMSS: found vmss %s being deleted, skipping" , VMScaleSetName )
711
+ return nil
712
+ }
755
713
756
- result , retryErr = az .VirtualMachineScaleSetsClient .Get (ctx , resourceGroupName , vmssName )
757
- if retryErr != nil {
758
- az .Event (service , v1 .EventTypeWarning , "GetVirtualMachineScaleSet" , retryErr .Error ().Error ())
759
- klog .Errorf ("backoff: failure for scale set %q, will retry,err=%v" , vmssName , retryErr )
760
- return false , nil
761
- }
762
- klog .V (4 ).Infof ("backoff: success for scale set %q" , vmssName )
763
- return true , nil
764
- })
714
+ rerr = az .VirtualMachineScaleSetsClient .CreateOrUpdate (ctx , resourceGroupName , VMScaleSetName , parameters )
715
+ klog .V (10 ).Infof ("UpdateVmssVMWithRetry: VirtualMachineScaleSetsClient.CreateOrUpdate(%s): end" , VMScaleSetName )
716
+ if rerr != nil {
717
+ klog .Errorf ("CreateOrUpdateVMSS: error CreateOrUpdate vmss(%s): %v" , VMScaleSetName , rerr )
718
+ return rerr
719
+ }
765
720
766
- return result , err
721
+ return nil
767
722
}
768
723
769
724
func (cfg * Config ) shouldOmitCloudProviderBackoff () bool {
0 commit comments