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
755f5870
Commit
755f5870
authored
Dec 05, 2016
by
Dominika Hodovska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LimitRange: modified approach for PVC max storage request validation
parent
fdfe315b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
admission.go
plugin/pkg/admission/limitranger/admission.go
+17
-2
No files found.
plugin/pkg/admission/limitranger/admission.go
View file @
755f5870
...
...
@@ -279,6 +279,21 @@ func minConstraint(limitType api.LimitType, resourceName api.ResourceName, enfor
return
nil
}
// maxRequestConstraint enforces the max constraint over the specified resource
// use when specify LimitType resource doesn't recognize limit values
func
maxRequestConstraint
(
limitType
api
.
LimitType
,
resourceName
api
.
ResourceName
,
enforced
resource
.
Quantity
,
request
api
.
ResourceList
)
error
{
req
,
reqExists
:=
request
[
resourceName
]
observedReqValue
,
_
,
enforcedValue
:=
requestLimitEnforcedValues
(
req
,
resource
.
Quantity
{},
enforced
)
if
!
reqExists
{
return
fmt
.
Errorf
(
"maximum %s usage per %s is %s. No request is specified."
,
resourceName
,
limitType
,
enforced
.
String
())
}
if
observedReqValue
>
enforcedValue
{
return
fmt
.
Errorf
(
"maximum %s usage per %s is %s, but request is %s."
,
resourceName
,
limitType
,
enforced
.
String
(),
req
.
String
())
}
return
nil
}
// maxConstraint enforces the max constraint over the specified resource
func
maxConstraint
(
limitType
api
.
LimitType
,
resourceName
api
.
ResourceName
,
enforced
resource
.
Quantity
,
request
api
.
ResourceList
,
limit
api
.
ResourceList
)
error
{
req
,
reqExists
:=
request
[
resourceName
]
...
...
@@ -415,9 +430,9 @@ func PersistentVolumeClaimLimitFunc(limitRange *api.LimitRange, pvc *api.Persist
}
}
for
k
,
v
:=
range
limit
.
Max
{
//
reverse usage of maxConstraint.
We want to enforce the max of the LimitRange against what
// We want to enforce the max of the LimitRange against what
// the user requested.
if
err
:=
max
Constraint
(
limitType
,
k
,
v
,
api
.
ResourceList
{}
,
pvc
.
Spec
.
Resources
.
Requests
);
err
!=
nil
{
if
err
:=
max
RequestConstraint
(
limitType
,
k
,
v
,
pvc
.
Spec
.
Resources
.
Requests
);
err
!=
nil
{
errs
=
append
(
errs
,
err
)
}
}
...
...
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