Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.29] fix: allow resizing to min required size for performance plus disks #1986

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 73 additions & 72 deletions pkg/azureconstants/azure_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,78 +21,79 @@ import (
)

const (
AzureDiskCSIDriverName = "azuredisk_csi_driver"
CachingModeField = "cachingmode"
DefaultAzureCredentialFileEnv = "AZURE_CREDENTIAL_FILE"
DefaultCredFilePathLinux = "/etc/kubernetes/azure.json"
DefaultCredFilePathWindows = "C:\\k\\azure.json"
DefaultDriverName = "disk.csi.azure.com"
DesIDField = "diskencryptionsetid"
DiskEncryptionTypeField = "diskencryptiontype"
DiskAccessIDField = "diskaccessid"
DiskIOPSReadWriteField = "diskiopsreadwrite"
DiskMBPSReadWriteField = "diskmbpsreadwrite"
DiskNameField = "diskname"
EnableBurstingField = "enablebursting"
ErrDiskNotFound = "not found"
FsTypeField = "fstype"
IncrementalField = "incremental"
KindField = "kind"
LocationField = "location"
LogicalSectorSizeField = "logicalsectorsize"
LUN = "LUN"
MaxSharesField = "maxshares"
MinimumDiskSizeGiB = 1
NetworkAccessPolicyField = "networkaccesspolicy"
PublicNetworkAccessField = "publicnetworkaccess"
NotFound = "NotFound"
PerfProfileBasic = "basic"
PerfProfileAdvanced = "advanced"
PerfProfileField = "perfprofile"
PerfProfileNone = "none"
PremiumAccountPrefix = "premium"
PvcNameKey = "csi.storage.k8s.io/pvc/name"
PvcNamespaceKey = "csi.storage.k8s.io/pvc/namespace"
PvcNamespaceTag = "kubernetes.io-created-for-pvc-namespace"
PvcNameTag = "kubernetes.io-created-for-pvc-name"
PvNameKey = "csi.storage.k8s.io/pv/name"
PvNameTag = "kubernetes.io-created-for-pv-name"
RateLimited = "rate limited"
RequestedSizeGib = "requestedsizegib"
ResizeRequired = "resizeRequired"
SubscriptionIDField = "subscriptionid"
ResourceGroupField = "resourcegroup"
DataAccessAuthModeField = "dataaccessauthmode"
ResourceNotFound = "ResourceNotFound"
SkuNameField = "skuname"
SourceDiskSearchMaxDepth = 10
SourceSnapshot = "snapshot"
SourceVolume = "volume"
StandardSsdAccountPrefix = "standardssd"
StorageAccountTypeField = "storageaccounttype"
TagsField = "tags"
ThrottlingKey = "throttlingKey"
TrueValue = "true"
FalseValue = "false"
UserAgentField = "useragent"
VolumeAttributePartition = "partition"
WellKnownTopologyKey = "topology.kubernetes.io/zone"
InstanceTypeKey = "node.kubernetes.io/instance-type"
WriteAcceleratorEnabled = "writeacceleratorenabled"
ZonedField = "zoned"
EnableAsyncAttachField = "enableasyncattach"
PerformancePlusField = "enableperformanceplus"
AttachDiskInitialDelayField = "attachdiskinitialdelay"
TooManyRequests = "TooManyRequests"
ClientThrottled = "client throttled"
VolumeID = "volumeid"
Node = "node"
SourceResourceID = "source_resource_id"
SnapshotName = "snapshot_name"
SnapshotID = "snapshot_id"
DeviceSettingsKeyPrefix = "device-setting/"
BlockDeviceRootPathLinux = "/sys/block"
DummyBlockDevicePathLinux = "/sys/block/sda"
AzureDiskCSIDriverName = "azuredisk_csi_driver"
CachingModeField = "cachingmode"
DefaultAzureCredentialFileEnv = "AZURE_CREDENTIAL_FILE"
DefaultCredFilePathLinux = "/etc/kubernetes/azure.json"
DefaultCredFilePathWindows = "C:\\k\\azure.json"
DefaultDriverName = "disk.csi.azure.com"
DesIDField = "diskencryptionsetid"
DiskEncryptionTypeField = "diskencryptiontype"
DiskAccessIDField = "diskaccessid"
DiskIOPSReadWriteField = "diskiopsreadwrite"
DiskMBPSReadWriteField = "diskmbpsreadwrite"
DiskNameField = "diskname"
EnableBurstingField = "enablebursting"
ErrDiskNotFound = "not found"
FsTypeField = "fstype"
IncrementalField = "incremental"
KindField = "kind"
LocationField = "location"
LogicalSectorSizeField = "logicalsectorsize"
LUN = "LUN"
MaxSharesField = "maxshares"
MinimumDiskSizeGiB = 1
NetworkAccessPolicyField = "networkaccesspolicy"
PublicNetworkAccessField = "publicnetworkaccess"
NotFound = "NotFound"
PerfProfileBasic = "basic"
PerfProfileAdvanced = "advanced"
PerfProfileField = "perfprofile"
PerfProfileNone = "none"
PremiumAccountPrefix = "premium"
PvcNameKey = "csi.storage.k8s.io/pvc/name"
PvcNamespaceKey = "csi.storage.k8s.io/pvc/namespace"
PvcNamespaceTag = "kubernetes.io-created-for-pvc-namespace"
PvcNameTag = "kubernetes.io-created-for-pvc-name"
PvNameKey = "csi.storage.k8s.io/pv/name"
PvNameTag = "kubernetes.io-created-for-pv-name"
RateLimited = "rate limited"
RequestedSizeGib = "requestedsizegib"
ResizeRequired = "resizeRequired"
SubscriptionIDField = "subscriptionid"
ResourceGroupField = "resourcegroup"
DataAccessAuthModeField = "dataaccessauthmode"
ResourceNotFound = "ResourceNotFound"
SkuNameField = "skuname"
SourceDiskSearchMaxDepth = 10
SourceSnapshot = "snapshot"
SourceVolume = "volume"
StandardSsdAccountPrefix = "standardssd"
StorageAccountTypeField = "storageaccounttype"
TagsField = "tags"
ThrottlingKey = "throttlingKey"
TrueValue = "true"
FalseValue = "false"
UserAgentField = "useragent"
VolumeAttributePartition = "partition"
WellKnownTopologyKey = "topology.kubernetes.io/zone"
InstanceTypeKey = "node.kubernetes.io/instance-type"
WriteAcceleratorEnabled = "writeacceleratorenabled"
ZonedField = "zoned"
EnableAsyncAttachField = "enableasyncattach"
PerformancePlusField = "enableperformanceplus"
PerformancePlusMinimumDiskSizeGiB = 513
AttachDiskInitialDelayField = "attachdiskinitialdelay"
TooManyRequests = "TooManyRequests"
ClientThrottled = "client throttled"
VolumeID = "volumeid"
Node = "node"
SourceResourceID = "source_resource_id"
SnapshotName = "snapshot_name"
SnapshotID = "snapshot_id"
DeviceSettingsKeyPrefix = "device-setting/"
BlockDeviceRootPathLinux = "/sys/block"
DummyBlockDevicePathLinux = "/sys/block/sda"
// define different sleep time when hit throttling
SnapshotOpThrottlingSleepSec = 50
)
Expand Down
6 changes: 6 additions & 0 deletions pkg/azuredisk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
capacityBytes := req.GetCapacityRange().GetRequiredBytes()
volSizeBytes := int64(capacityBytes)
requestGiB := int(volumehelper.RoundUpGiB(volSizeBytes))

if diskParams.PerformancePlus != nil && *diskParams.PerformancePlus && requestGiB < consts.PerformancePlusMinimumDiskSizeGiB {
klog.Warningf("using PerformancePlus, increasing requested disk size from %vGiB to %vGiB (minimal size for PerformancePlus feature)", requestGiB, consts.PerformancePlusMinimumDiskSizeGiB)
requestGiB = consts.PerformancePlusMinimumDiskSizeGiB
}
if requestGiB < consts.MinimumDiskSizeGiB {
klog.Infof("increasing requested disk size from %vGiB to %vGiB (minimal disk size)", requestGiB, consts.MinimumDiskSizeGiB)
requestGiB = consts.MinimumDiskSizeGiB
}

Expand Down
35 changes: 35 additions & 0 deletions pkg/azuredisk/controllerserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,41 @@ func TestCreateVolume(t *testing.T) {
}
},
},
{
name: "valid PerformancePlus request, disk resizes to min required size",
testFunc: func(t *testing.T) {
d, _ := NewFakeDriver(t)
stdCapacityRangetest := &csi.CapacityRange{
RequiredBytes: volumehelper.GiBToBytes(10),
LimitBytes: volumehelper.GiBToBytes(514),
}
req := &csi.CreateVolumeRequest{
Name: testVolumeName,
VolumeCapabilities: stdVolumeCapabilities,
CapacityRange: stdCapacityRangetest,
Parameters: map[string]string{consts.PerformancePlusField: "true"},
}
size := int32(volumehelper.BytesToGiB(req.CapacityRange.RequiredBytes))
id := fmt.Sprintf(consts.ManagedDiskPath, "subs", "rg", testVolumeName)
state := "Succeeded"
disk := compute.Disk{
ID: &id,
Name: &testVolumeName,
DiskProperties: &compute.DiskProperties{
DiskSizeGB: &size,
ProvisioningState: &state,
},
}
d.getCloud().DisksClient.(*mockdiskclient.MockInterface).EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(disk, nil).AnyTimes()
d.getCloud().DisksClient.(*mockdiskclient.MockInterface).EXPECT().CreateOrUpdate(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
res, err := d.CreateVolume(context.Background(), req)
assert.Equal(t, res.Volume.CapacityBytes, volumehelper.GiBToBytes(consts.PerformancePlusMinimumDiskSizeGiB))
expectedErr := error(nil)
if !reflect.DeepEqual(err, expectedErr) {
t.Errorf("actualErr: (%v), expectedErr: (%v)", err, expectedErr)
}
},
},
}
for _, tc := range testCases {
t.Run(tc.name, tc.testFunc)
Expand Down
6 changes: 6 additions & 0 deletions pkg/azuredisk/controllerserver_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ func (d *DriverV2) CreateVolume(ctx context.Context, req *csi.CreateVolumeReques
capacityBytes := req.GetCapacityRange().GetRequiredBytes()
volSizeBytes := int64(capacityBytes)
requestGiB := int(volumehelper.RoundUpGiB(volSizeBytes))

if diskParams.PerformancePlus != nil && *diskParams.PerformancePlus && requestGiB < consts.PerformancePlusMinimumDiskSizeGiB {
klog.Warningf("using PerformancePlus, increasing requested disk size from %vGiB to %vGiB (minimal size for PerformancePlus feature)", requestGiB, consts.PerformancePlusMinimumDiskSizeGiB)
requestGiB = consts.PerformancePlusMinimumDiskSizeGiB
}
if requestGiB < consts.MinimumDiskSizeGiB {
klog.Infof("increasing requested disk size from %vGiB to %vGiB (minimal disk size)", requestGiB, consts.MinimumDiskSizeGiB)
requestGiB = consts.MinimumDiskSizeGiB
}

Expand Down
Loading