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

Add validation for negative provisioned-throughput-on-create parameter #1896

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions pkg/common/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func (pp *ParameterProcessor) ExtractAndDefaultParameters(parameters map[string]
if err != nil {
return p, fmt.Errorf("parameters contain invalid provisionedThroughputOnCreate parameter: %w", err)
}
if paramProvisionedThroughputOnCreate < 0 {
return p, fmt.Errorf("parameter provisionedThroughputOnCreate cannot be negative")
}
p.ProvisionedThroughputOnCreate = paramProvisionedThroughputOnCreate
case ParameterAvailabilityClass:
paramAvailabilityClass, err := ConvertStringToAvailabilityClass(v)
Expand Down
7 changes: 7 additions & 0 deletions pkg/common/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ func TestExtractAndDefaultParameters(t *testing.T) {
labels: map[string]string{},
expectErr: true,
},
{
name: "invalid storage pool parameters, negative ProvisionedThroughputOnCreate",
enableStoragePools: true,
parameters: map[string]string{ParameterKeyType: "hyperdisk-throughput", ParameterKeyReplicationType: "none", ParameterKeyDiskEncryptionKmsKey: "foo/key", ParameterKeyLabels: "key1=value1,key2=value2", ParameterKeyResourceTags: "parent1/key1/value1,parent2/key2/value2", ParameterKeyProvisionedThroughputOnCreate: "-50Mi"},
labels: map[string]string{},
expectErr: true,
},
{
name: "storage pool parameters, enableStoragePools is false",
enableStoragePools: false,
Expand Down