Skip to content

Commit 4093df7

Browse files
authored
Merge pull request kubernetes#93011 from andyzhangx/list-disks
fix: azure disk resize error if source does not exist
2 parents 2ded1e0 + ea51fba commit 4093df7

21 files changed

+331
-224
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ type Cloud struct {
248248

249249
ResourceRequestBackoff wait.Backoff
250250
metadata *InstanceMetadataService
251-
vmSet VMSet
251+
VMSet VMSet
252252

253253
// ipv6DualStack allows overriding for unit testing. It's normally initialized from featuregates
254254
ipv6DualStackEnabled bool
@@ -491,12 +491,12 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret bool) erro
491491
}
492492

493493
if strings.EqualFold(vmTypeVMSS, az.Config.VMType) {
494-
az.vmSet, err = newScaleSet(az)
494+
az.VMSet, err = newScaleSet(az)
495495
if err != nil {
496496
return err
497497
}
498498
} else {
499-
az.vmSet = newAvailabilitySet(az)
499+
az.VMSet = newAvailabilitySet(az)
500500
}
501501

502502
az.vmCache, err = az.newVMCache()

staging/src/k8s.io/legacy-cloud-providers/azure/azure_backoff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (az *Cloud) getPrivateIPsForMachineWithRetry(nodeName types.NodeName) ([]st
111111
var privateIPs []string
112112
err := wait.ExponentialBackoff(az.RequestBackoff(), func() (bool, error) {
113113
var retryErr error
114-
privateIPs, retryErr = az.vmSet.GetPrivateIPsByNodeName(string(nodeName))
114+
privateIPs, retryErr = az.VMSet.GetPrivateIPsByNodeName(string(nodeName))
115115
if retryErr != nil {
116116
// won't retry since the instance doesn't exist on Azure.
117117
if retryErr == cloudprovider.InstanceNotFound {
@@ -135,7 +135,7 @@ func (az *Cloud) GetIPForMachineWithRetry(name types.NodeName) (string, string,
135135
var ip, publicIP string
136136
err := wait.ExponentialBackoff(az.RequestBackoff(), func() (bool, error) {
137137
var retryErr error
138-
ip, publicIP, retryErr = az.vmSet.GetIPByNodeName(string(name))
138+
ip, publicIP, retryErr = az.VMSet.GetIPByNodeName(string(name))
139139
if retryErr != nil {
140140
klog.Errorf("GetIPForMachineWithRetry(%s): backoff failure, will retry,err=%v", name, retryErr)
141141
return false, nil

staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ type controllerCommon struct {
9090

9191
// getNodeVMSet gets the VMSet interface based on config.VMType and the real virtual machine type.
9292
func (c *controllerCommon) getNodeVMSet(nodeName types.NodeName, crt azcache.AzureCacheReadType) (VMSet, error) {
93-
// 1. vmType is standard, return cloud.vmSet directly.
93+
// 1. vmType is standard, return cloud.VMSet directly.
9494
if c.cloud.VMType == vmTypeStandard {
95-
return c.cloud.vmSet, nil
95+
return c.cloud.VMSet, nil
9696
}
9797

9898
// 2. vmType is Virtual Machine Scale Set (vmss), convert vmSet to scaleSet.
99-
ss, ok := c.cloud.vmSet.(*scaleSet)
99+
ss, ok := c.cloud.VMSet.(*scaleSet)
100100
if !ok {
101-
return nil, fmt.Errorf("error of converting vmSet (%q) to scaleSet with vmType %q", c.cloud.vmSet, c.cloud.VMType)
101+
return nil, fmt.Errorf("error of converting vmSet (%q) to scaleSet with vmType %q", c.cloud.VMSet, c.cloud.VMType)
102102
}
103103

104104
// 3. If the node is managed by availability set, then return ss.availabilitySet.

staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_common_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func TestCommonAttachDiskWithVMSS(t *testing.T) {
222222
}
223223
ss, err := newScaleSet(testCloud)
224224
assert.Nil(t, err)
225-
testCloud.vmSet = ss
225+
testCloud.VMSet = ss
226226
}
227227

228228
common := &controllerCommon{

staging/src/k8s.io/legacy-cloud-providers/azure/azure_controller_standard_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestStandardAttachDisk(t *testing.T) {
7979

8080
for i, test := range testCases {
8181
testCloud := GetTestCloud(ctrl)
82-
vmSet := testCloud.vmSet
82+
vmSet := testCloud.VMSet
8383
expectedVMs := setTestVirtualMachines(testCloud, map[string]string{"vm1": "PowerState/Running"}, false)
8484
mockVMsClient := testCloud.VirtualMachinesClient.(*mockvmclient.MockInterface)
8585
for _, vm := range expectedVMs {
@@ -148,7 +148,7 @@ func TestStandardDetachDisk(t *testing.T) {
148148

149149
for i, test := range testCases {
150150
testCloud := GetTestCloud(ctrl)
151-
vmSet := testCloud.vmSet
151+
vmSet := testCloud.VMSet
152152
expectedVMs := setTestVirtualMachines(testCloud, map[string]string{"vm1": "PowerState/Running"}, false)
153153
mockVMsClient := testCloud.VirtualMachinesClient.(*mockvmclient.MockInterface)
154154
for _, vm := range expectedVMs {
@@ -224,7 +224,7 @@ func TestGetDataDisks(t *testing.T) {
224224
}
225225
for i, test := range testCases {
226226
testCloud := GetTestCloud(ctrl)
227-
vmSet := testCloud.vmSet
227+
vmSet := testCloud.VMSet
228228
expectedVMs := setTestVirtualMachines(testCloud, map[string]string{"vm1": "PowerState/Running"}, false)
229229
mockVMsClient := testCloud.VirtualMachinesClient.(*mockvmclient.MockInterface)
230230
for _, vm := range expectedVMs {

staging/src/k8s.io/legacy-cloud-providers/azure/azure_fakes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func GetTestCloud(ctrl *gomock.Controller) (az *Cloud) {
8383
az.VirtualMachineScaleSetsClient = mockvmssclient.NewMockInterface(ctrl)
8484
az.VirtualMachineScaleSetVMsClient = mockvmssvmclient.NewMockInterface(ctrl)
8585
az.VirtualMachinesClient = mockvmclient.NewMockInterface(ctrl)
86-
az.vmSet = newAvailabilitySet(az)
86+
az.VMSet = newAvailabilitySet(az)
8787
az.vmCache, _ = az.newVMCache()
8888
az.lbCache, _ = az.newLBCache()
8989
az.nsgCache, _ = az.newNSGCache()

staging/src/k8s.io/legacy-cloud-providers/azure/azure_instances.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (az *Cloud) NodeAddresses(ctx context.Context, name types.NodeName) ([]v1.N
9595

9696
// Not local instance, get addresses from Azure ARM API.
9797
if !isLocalInstance {
98-
if az.vmSet != nil {
98+
if az.VMSet != nil {
9999
return az.addressGetter(name)
100100
}
101101

@@ -168,7 +168,7 @@ func (az *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID strin
168168
return nil, nil
169169
}
170170

171-
name, err := az.vmSet.GetNodeNameByProviderID(providerID)
171+
name, err := az.VMSet.GetNodeNameByProviderID(providerID)
172172
if err != nil {
173173
return nil, err
174174
}
@@ -189,7 +189,7 @@ func (az *Cloud) InstanceExistsByProviderID(ctx context.Context, providerID stri
189189
return true, nil
190190
}
191191

192-
name, err := az.vmSet.GetNodeNameByProviderID(providerID)
192+
name, err := az.VMSet.GetNodeNameByProviderID(providerID)
193193
if err != nil {
194194
if err == cloudprovider.InstanceNotFound {
195195
return false, nil
@@ -214,7 +214,7 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
214214
return false, nil
215215
}
216216

217-
nodeName, err := az.vmSet.GetNodeNameByProviderID(providerID)
217+
nodeName, err := az.VMSet.GetNodeNameByProviderID(providerID)
218218
if err != nil {
219219
// Returns false, so the controller manager will continue to check InstanceExistsByProviderID().
220220
if err == cloudprovider.InstanceNotFound {
@@ -224,7 +224,7 @@ func (az *Cloud) InstanceShutdownByProviderID(ctx context.Context, providerID st
224224
return false, err
225225
}
226226

227-
powerStatus, err := az.vmSet.GetPowerStatusByNodeName(string(nodeName))
227+
powerStatus, err := az.VMSet.GetPowerStatusByNodeName(string(nodeName))
228228
if err != nil {
229229
// Returns false, so the controller manager will continue to check InstanceExistsByProviderID().
230230
if err == cloudprovider.InstanceNotFound {
@@ -292,8 +292,8 @@ func (az *Cloud) InstanceID(ctx context.Context, name types.NodeName) (string, e
292292

293293
// Not local instance, get instanceID from Azure ARM API.
294294
if !isLocalInstance {
295-
if az.vmSet != nil {
296-
return az.vmSet.GetInstanceIDByNodeName(nodeName)
295+
if az.VMSet != nil {
296+
return az.VMSet.GetInstanceIDByNodeName(nodeName)
297297
}
298298

299299
// vmSet == nil indicates credentials are not provided.
@@ -302,7 +302,7 @@ func (az *Cloud) InstanceID(ctx context.Context, name types.NodeName) (string, e
302302
return az.getLocalInstanceProviderID(metadata, nodeName)
303303
}
304304

305-
return az.vmSet.GetInstanceIDByNodeName(nodeName)
305+
return az.VMSet.GetInstanceIDByNodeName(nodeName)
306306
}
307307

308308
func (az *Cloud) getLocalInstanceProviderID(metadata *InstanceMetadata, nodeName string) (string, error) {
@@ -342,7 +342,7 @@ func (az *Cloud) InstanceTypeByProviderID(ctx context.Context, providerID string
342342
return "", nil
343343
}
344344

345-
name, err := az.vmSet.GetNodeNameByProviderID(providerID)
345+
name, err := az.VMSet.GetNodeNameByProviderID(providerID)
346346
if err != nil {
347347
return "", err
348348
}
@@ -380,8 +380,8 @@ func (az *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string,
380380
return "", err
381381
}
382382
if !isLocalInstance {
383-
if az.vmSet != nil {
384-
return az.vmSet.GetInstanceTypeByNodeName(string(name))
383+
if az.VMSet != nil {
384+
return az.VMSet.GetInstanceTypeByNodeName(string(name))
385385
}
386386

387387
// vmSet == nil indicates credentials are not provided.
@@ -393,7 +393,7 @@ func (az *Cloud) InstanceType(ctx context.Context, name types.NodeName) (string,
393393
}
394394
}
395395

396-
return az.vmSet.GetInstanceTypeByNodeName(string(name))
396+
return az.VMSet.GetInstanceTypeByNodeName(string(name))
397397
}
398398

399399
// AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances

0 commit comments

Comments
 (0)