mirror of https://github.com/k3s-io/k3s
parent
598a01989d
commit
11527d6910
|
@ -67,7 +67,17 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
|
||||||
CreateOption: "attach",
|
CreateOption: "attach",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
vm.StorageProfile.DataDisks = &disks
|
newVM := compute.VirtualMachineScaleSetVM{
|
||||||
|
Sku: vm.Sku,
|
||||||
|
Location: vm.Location,
|
||||||
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
|
HardwareProfile: vm.HardwareProfile,
|
||||||
|
StorageProfile: &compute.StorageProfile{
|
||||||
|
OsDisk: vm.StorageProfile.OsDisk,
|
||||||
|
DataDisks: &disks,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := getContextWithCancel()
|
ctx, cancel := getContextWithCancel()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
@ -77,7 +87,7 @@ func (ss *scaleSet) AttachDisk(isManagedDisk bool, diskName, diskURI string, nod
|
||||||
defer ss.vmssVMCache.Delete(key)
|
defer ss.vmssVMCache.Delete(key)
|
||||||
|
|
||||||
klog.V(2).Infof("azureDisk - update(%s): vm(%s) - attach disk(%s)", nodeResourceGroup, nodeName, diskName)
|
klog.V(2).Infof("azureDisk - update(%s): vm(%s) - attach disk(%s)", nodeResourceGroup, nodeName, diskName)
|
||||||
_, err = ss.VirtualMachineScaleSetVMsClient.Update(ctx, nodeResourceGroup, ssName, instanceID, vm)
|
_, err = ss.VirtualMachineScaleSetVMsClient.Update(ctx, nodeResourceGroup, ssName, instanceID, newVM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
detail := err.Error()
|
detail := err.Error()
|
||||||
if strings.Contains(detail, errLeaseFailed) || strings.Contains(detail, errDiskBlobNotFound) {
|
if strings.Contains(detail, errLeaseFailed) || strings.Contains(detail, errDiskBlobNotFound) {
|
||||||
|
@ -126,7 +136,18 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
|
||||||
return fmt.Errorf("detach azure disk failure, disk %s not found, diskURI: %s", diskName, diskURI)
|
return fmt.Errorf("detach azure disk failure, disk %s not found, diskURI: %s", diskName, diskURI)
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.StorageProfile.DataDisks = &disks
|
newVM := compute.VirtualMachineScaleSetVM{
|
||||||
|
Sku: vm.Sku,
|
||||||
|
Location: vm.Location,
|
||||||
|
VirtualMachineScaleSetVMProperties: &compute.VirtualMachineScaleSetVMProperties{
|
||||||
|
HardwareProfile: vm.HardwareProfile,
|
||||||
|
StorageProfile: &compute.StorageProfile{
|
||||||
|
OsDisk: vm.StorageProfile.OsDisk,
|
||||||
|
DataDisks: &disks,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
ctx, cancel := getContextWithCancel()
|
ctx, cancel := getContextWithCancel()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
@ -135,7 +156,7 @@ func (ss *scaleSet) DetachDiskByName(diskName, diskURI string, nodeName types.No
|
||||||
defer ss.vmssVMCache.Delete(key)
|
defer ss.vmssVMCache.Delete(key)
|
||||||
|
|
||||||
klog.V(2).Infof("azureDisk - update(%s): vm(%s) - detach disk(%s)", nodeResourceGroup, nodeName, diskName)
|
klog.V(2).Infof("azureDisk - update(%s): vm(%s) - detach disk(%s)", nodeResourceGroup, nodeName, diskName)
|
||||||
_, err = ss.VirtualMachineScaleSetVMsClient.Update(ctx, nodeResourceGroup, ssName, instanceID, vm)
|
_, err = ss.VirtualMachineScaleSetVMsClient.Update(ctx, nodeResourceGroup, ssName, instanceID, newVM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("azureDisk - detach disk(%s) from %s failed, err: %v", diskName, nodeName, err)
|
klog.Errorf("azureDisk - detach disk(%s) from %s failed, err: %v", diskName, nodeName, err)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue