feat: support Azure shared disk

This commit is contained in:
andyzhangx 2020-03-21 13:16:22 +00:00
parent a19942cbd7
commit f889213d38
3 changed files with 18 additions and 1 deletions

View File

@ -133,6 +133,8 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
diskIopsReadWrite string
diskMbpsReadWrite string
diskEncryptionSetID string
maxShares int
)
// maxLength = 79 - (4 for ".vhd") = 75
name := util.GenerateVolumeName(p.options.ClusterName, p.options.PVName, 75)
@ -179,6 +181,14 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
diskEncryptionSetID = v
case azure.WriteAcceleratorEnabled:
writeAcceleratorEnabled = v
case "maxshares":
maxShares, err = strconv.Atoi(v)
if err != nil {
return nil, fmt.Errorf("parse %s failed with error: %v", v, err)
}
if maxShares < 1 {
return nil, fmt.Errorf("parse %s returned with invalid value: %d", v, maxShares)
}
default:
return nil, fmt.Errorf("AzureDisk - invalid option %s in storage class", k)
}
@ -261,6 +271,7 @@ func (p *azureDiskProvisioner) Provision(selectedNode *v1.Node, allowedTopologie
DiskIOPSReadWrite: diskIopsReadWrite,
DiskMBpsReadWrite: diskMbpsReadWrite,
DiskEncryptionSetID: diskEncryptionSetID,
MaxShares: int32(maxShares),
}
diskURI, err = diskController.CreateManagedDisk(volumeOptions)
if err != nil {

View File

@ -136,7 +136,7 @@ func (c *controllerCommon) AttachDisk(isManagedDisk bool, diskName, diskURI stri
return -1, rerr.Error()
}
if disk.ManagedBy != nil {
if disk.ManagedBy != nil && (disk.MaxShares == nil || *disk.MaxShares <= 1) {
attachErr := fmt.Sprintf(
"disk(%s) already attached to node(%s), could not be attached to node(%s)",
diskURI, *disk.ManagedBy, nodeName)

View File

@ -75,6 +75,8 @@ type ManagedDiskOptions struct {
SourceType string
// ResourceId of the disk encryption set to use for enabling encryption at rest.
DiskEncryptionSetID string
// The maximum number of VMs that can attach to the disk at the same time. Value greater than one indicates a disk that can be mounted on multiple VMs at the same time.
MaxShares int32
}
//CreateManagedDisk : create managed disk
@ -152,6 +154,10 @@ func (c *ManagedDiskController) CreateManagedDisk(options *ManagedDiskOptions) (
}
}
if options.MaxShares > 1 {
diskProperties.MaxShares = &options.MaxShares
}
model := compute.Disk{
Location: &c.common.location,
Tags: newTags,