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
1748b42b
Commit
1748b42b
authored
Dec 08, 2017
by
Derek Carr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LimitRange ignores objects previously marked for deletion
parent
8583b663
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
admission.go
plugin/pkg/admission/limitranger/admission.go
+12
-0
admission_test.go
plugin/pkg/admission/limitranger/admission_test.go
+9
-0
No files found.
plugin/pkg/admission/limitranger/admission.go
View file @
1748b42b
...
@@ -113,6 +113,18 @@ func (l *LimitRanger) runLimitFunc(a admission.Attributes, limitFn func(limitRan
...
@@ -113,6 +113,18 @@ func (l *LimitRanger) runLimitFunc(a admission.Attributes, limitFn func(limitRan
}
}
}
}
// ignore all objects marked for deletion
oldObj
:=
a
.
GetOldObject
()
if
oldObj
!=
nil
{
oldAccessor
,
err
:=
meta
.
Accessor
(
oldObj
)
if
err
!=
nil
{
return
admission
.
NewForbidden
(
a
,
err
)
}
if
oldAccessor
.
GetDeletionTimestamp
()
!=
nil
{
return
nil
}
}
items
,
err
:=
l
.
GetLimitRanges
(
a
)
items
,
err
:=
l
.
GetLimitRanges
(
a
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
plugin/pkg/admission/limitranger/admission_test.go
View file @
1748b42b
...
@@ -733,6 +733,15 @@ func TestLimitRangerAdmitPod(t *testing.T) {
...
@@ -733,6 +733,15 @@ func TestLimitRangerAdmitPod(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"Should have ignored calls to any subresource of pod %v"
,
err
)
t
.
Errorf
(
"Should have ignored calls to any subresource of pod %v"
,
err
)
}
}
// a pod that is undergoing termination should never be blocked
terminatingPod
:=
validPod
(
"terminatingPod"
,
1
,
api
.
ResourceRequirements
{})
now
:=
metav1
.
Now
()
terminatingPod
.
DeletionTimestamp
=
&
now
err
=
handler
.
Validate
(
admission
.
NewAttributesRecord
(
&
terminatingPod
,
&
terminatingPod
,
api
.
Kind
(
"Pod"
)
.
WithVersion
(
"version"
),
limitRange
.
Namespace
,
"terminatingPod"
,
api
.
Resource
(
"pods"
)
.
WithVersion
(
"version"
),
""
,
admission
.
Update
,
nil
))
if
err
!=
nil
{
t
.
Errorf
(
"LimitRange should ignore a pod marked for termination"
)
}
}
}
// newMockClientForTest creates a mock client that returns a client configured for the specified list of limit ranges
// newMockClientForTest creates a mock client that returns a client configured for the specified list of limit ranges
...
...
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