-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from peter-wangxu/bugfix/enhance_throttle_io
blkio throttling enhancement: support quantity in `bps`
- Loading branch information
Showing
11 changed files
with
206 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
# Storage Class | ||
|
||
These parameters can be configured in StorageClass: | ||
|
||
| Parameters | Values | Default | Description | | ||
|-----------------------------|----------------------------------------|----------|---------------------| | ||
| "csi.storage.k8s.io/fstype" | xfs, ext2, ext3, ext4 | ext4 | File system type that will be formatted during volume creation. This parameter is case sensitive! | | ||
| "volumeType" | LVM, MountPoint, Device | | PV type that will be created by Open-Local. This parameter is case sensitive! | | ||
| "mediaType" | hdd,ssd | | Media type that will be used when allocate Device for PV. The param only works when volumeType is MountPoint or Device. | | ||
| "vgName" | | | The volume group name that the open-local will use to create the logical volume. This name must be contained in vg list, which can be found in .status.filteredStorageInfo in every [nls](../api/nls_zh_CN.md). If no value is set, open-local will choose a vg from vg list by itself. | | ||
| "iops" | | | I/O operations per second. | | ||
| "bps" | | | Throughput in KiB/s. | | ||
| Parameters | Values | mandatory | Description | | ||
|----------------------------- |------------------------- |----------- |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| "csi.storage.k8s.io/fstype" | xfs, ext2, ext3, ext4 | No | File system type that will be formatted during volume creation. This parameter is case sensitive! Default value is `ext4` | | ||
| "volumeType" | LVM, MountPoint, Device | Yes | PV type that will be created by Open-Local. This parameter is case sensitive! | | ||
| "mediaType" | hdd,ssd | No | Media type that will be used when allocate Device for PV. The param only works when volumeType is MountPoint or Device. | | ||
| "vgName" | | No | The volume group name that the open-local will use to create the logical volume. This name must be contained in vg list, which can be found in .status.filteredStorageInfo in every nls. If no value is set, open-local will choose a vg from vg list by itself. | | ||
| "iops" | | No | I/O operations per second. | | ||
| "bps" | | No | Throughput in byte/Ki/Mi/Gi per second The default unit is `byte`, `102400`, `1Mi`, `100Mi`, `1Gi` are all valid format since v0.7.2. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright © 2023 Alibaba Group Holding Ltd. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package csi | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_requireThrottleIO(t *testing.T) { | ||
type args struct { | ||
volumeContext map[string]string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantR bool | ||
wantBpsValue int64 | ||
wantIopsValue int64 | ||
wantErr bool | ||
}{ | ||
{name: "test empty throttle value", | ||
args: args{volumeContext: map[string]string{}}, | ||
wantR: false, wantBpsValue: 0, wantIopsValue: 0, wantErr: false}, | ||
{name: "test bps throttle value only", | ||
args: args{volumeContext: map[string]string{"bps": "1024"}}, | ||
wantR: true, wantBpsValue: 1024, wantIopsValue: 0, wantErr: false}, | ||
{name: "test iops throttle value only", | ||
args: args{volumeContext: map[string]string{"iops": "100"}}, | ||
wantR: true, wantBpsValue: 0, wantIopsValue: 100, wantErr: false}, | ||
{name: "test bps and iops throttle value", | ||
args: args{volumeContext: map[string]string{"bps": "10240", "iops": "110"}}, | ||
wantR: true, wantBpsValue: 10240, wantIopsValue: 110, wantErr: false}, | ||
{name: "test bps quantity throttle value", | ||
args: args{volumeContext: map[string]string{"bps": "1Mi", "iops": "110"}}, | ||
wantR: true, wantBpsValue: 1048576, wantIopsValue: 110, wantErr: false}, | ||
{name: "test invalid bps throttle value", | ||
args: args{volumeContext: map[string]string{"bps": "abc"}}, | ||
wantR: false, wantBpsValue: 0, wantIopsValue: 0, wantErr: true}, | ||
{name: "test invalid iops throttle value", | ||
args: args{volumeContext: map[string]string{"bps": "10240", "iops": "11b"}}, | ||
wantR: false, wantBpsValue: 0, wantIopsValue: 0, wantErr: true}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotR, gotBpsValue, gotIopsValue, err := requireThrottleIO(tt.args.volumeContext) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("requireThrottleIO() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if gotR != tt.wantR { | ||
t.Errorf("requireThrottleIO() gotR = %v, want %v", gotR, tt.wantR) | ||
} | ||
if gotBpsValue != tt.wantBpsValue { | ||
t.Errorf("requireThrottleIO() gotBpsValue = %v, want %v", gotBpsValue, tt.wantBpsValue) | ||
} | ||
if gotIopsValue != tt.wantIopsValue { | ||
t.Errorf("requireThrottleIO() gotIopsValue = %v, want %v", gotIopsValue, tt.wantIopsValue) | ||
} | ||
}) | ||
} | ||
} |