Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3a22b5f5
Commit
3a22b5f5
authored
Nov 06, 2017
by
NickrenREN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that storage request of pvc is not zero
parent
338ee7f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
validation.go
pkg/apis/core/validation/validation.go
+4
-0
validation_test.go
pkg/apis/core/validation/validation_test.go
+22
-0
No files found.
pkg/apis/core/validation/validation.go
View file @
3a22b5f5
...
...
@@ -62,6 +62,7 @@ const isNegativeErrorMsg string = apimachineryvalidation.IsNegativeErrorMsg
const
isInvalidQuotaResource
string
=
`must be a standard resource for quota`
const
fieldImmutableErrorMsg
string
=
genericvalidation
.
FieldImmutableErrorMsg
const
isNotIntegerErrorMsg
string
=
`must be an integer`
const
isZeroErrorMsg
string
=
`must be greater than zero`
var
pdPartitionErrorMsg
string
=
validation
.
InclusiveRangeError
(
1
,
255
)
var
volumeModeErrorMsg
string
=
"must be a number between 0 and 0777 (octal), both inclusive"
...
...
@@ -1601,6 +1602,9 @@ func ValidatePersistentVolumeClaimSpec(spec *core.PersistentVolumeClaimSpec, fld
allErrs
=
append
(
allErrs
,
field
.
Required
(
fldPath
.
Child
(
"resources"
)
.
Key
(
string
(
core
.
ResourceStorage
)),
""
))
}
else
{
allErrs
=
append
(
allErrs
,
ValidateResourceQuantityValue
(
string
(
core
.
ResourceStorage
),
storageValue
,
fldPath
.
Child
(
"resources"
)
.
Key
(
string
(
core
.
ResourceStorage
)))
...
)
if
storageValue
.
Value
()
==
int64
(
0
)
{
allErrs
=
append
(
allErrs
,
field
.
Invalid
(
fldPath
,
storageValue
,
isZeroErrorMsg
))
}
}
if
spec
.
StorageClassName
!=
nil
&&
len
(
*
spec
.
StorageClassName
)
>
0
{
...
...
pkg/apis/core/validation/validation_test.go
View file @
3a22b5f5
...
...
@@ -765,6 +765,28 @@ func TestValidatePersistentVolumeClaim(t *testing.T) {
},
}),
},
"zero-storage-request"
:
{
isExpectedFailure
:
true
,
claim
:
testVolumeClaim
(
"foo"
,
"ns"
,
core
.
PersistentVolumeClaimSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchExpressions
:
[]
metav1
.
LabelSelectorRequirement
{
{
Key
:
"key2"
,
Operator
:
"Exists"
,
},
},
},
AccessModes
:
[]
core
.
PersistentVolumeAccessMode
{
core
.
ReadWriteOnce
,
core
.
ReadOnlyMany
,
},
Resources
:
core
.
ResourceRequirements
{
Requests
:
core
.
ResourceList
{
core
.
ResourceName
(
api
.
ResourceStorage
)
:
resource
.
MustParse
(
"0G"
),
},
},
}),
},
"invalid-storage-class-name"
:
{
isExpectedFailure
:
true
,
claim
:
testVolumeClaim
(
"foo"
,
"ns"
,
core
.
PersistentVolumeClaimSpec
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment