mirror of https://github.com/k3s-io/k3s
Merge pull request #63275 from feiskyer/vmss-disk
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>. Fix panic for attaching AzureDisk to vmss nodes **What this PR does / why we need it**: Azure vmss virtual machine's data disks may be nil (while Azure virtual machine doesn't have the issue) so it will panic controller-manager when attaching new disks. This PR fixes the issue by adding a check. **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**: Should be cherry picked to v1.10. **Release note**: ```release-note Fix panic for attaching AzureDisk to vmss nodes ```pull/8/head
commit
81478b804e
|
@ -34,7 +34,10 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
|
|||
return err
|
||||
}
|
||||
|
||||
disks := *vm.StorageProfile.DataDisks
|
||||
disks := []compute.DataDisk{}
|
||||
if vm.StorageProfile != nil && vm.StorageProfile.DataDisks != nil {
|
||||
disks = *vm.StorageProfile.DataDisks
|
||||
}
|
||||
if isManagedDisk {
|
||||
disks = append(disks,
|
||||
compute.DataDisk{
|
||||
|
@ -95,7 +98,10 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
|
|||
return err
|
||||
}
|
||||
|
||||
disks := *vm.StorageProfile.DataDisks
|
||||
disks := []compute.DataDisk{}
|
||||
if vm.StorageProfile != nil && vm.StorageProfile.DataDisks != nil {
|
||||
disks = *vm.StorageProfile.DataDisks
|
||||
}
|
||||
bFoundDisk := false
|
||||
for i, disk := range disks {
|
||||
if disk.Lun != nil && (disk.Name != nil && diskName != "" && *disk.Name == diskName) ||
|
||||
|
@ -144,7 +150,7 @@ func (ss *scaleSet) GetDataDisks(nodeName types.NodeName) ([]compute.DataDisk, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if vm.StorageProfile.DataDisks == nil {
|
||||
if vm.StorageProfile == nil || vm.StorageProfile.DataDisks == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue