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
a2ee93b5
Commit
a2ee93b5
authored
Aug 24, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
controller expectations for deletion can be met by 404
parent
963adda7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
controller_utils.go
pkg/controller/controller_utils.go
+2
-1
controller_utils_test.go
pkg/controller/controller_utils_test.go
+13
-0
No files found.
pkg/controller/controller_utils.go
View file @
a2ee93b5
...
...
@@ -27,6 +27,7 @@ import (
apps
"k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
apierrors
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
...
...
@@ -595,7 +596,7 @@ func (r RealPodControl) DeletePod(namespace string, podID string, object runtime
return
fmt
.
Errorf
(
"object does not have ObjectMeta, %v"
,
err
)
}
glog
.
V
(
2
)
.
Infof
(
"Controller %v deleting pod %v/%v"
,
accessor
.
GetName
(),
namespace
,
podID
)
if
err
:=
r
.
KubeClient
.
CoreV1
()
.
Pods
(
namespace
)
.
Delete
(
podID
,
nil
);
err
!=
nil
{
if
err
:=
r
.
KubeClient
.
CoreV1
()
.
Pods
(
namespace
)
.
Delete
(
podID
,
nil
);
err
!=
nil
&&
!
apierrors
.
IsNotFound
(
err
)
{
r
.
Recorder
.
Eventf
(
object
,
v1
.
EventTypeWarning
,
FailedDeletePodReason
,
"Error deleting: %v"
,
err
)
return
fmt
.
Errorf
(
"unable to delete pods: %v"
,
err
)
}
else
{
...
...
pkg/controller/controller_utils_test.go
View file @
a2ee93b5
...
...
@@ -314,6 +314,19 @@ func TestCreatePods(t *testing.T) {
"Body: %s"
,
fakeHandler
.
RequestBody
)
}
func
TestDeletePodsAllowsMissing
(
t
*
testing
.
T
)
{
fakeClient
:=
fake
.
NewSimpleClientset
()
podControl
:=
RealPodControl
{
KubeClient
:
fakeClient
,
Recorder
:
&
record
.
FakeRecorder
{},
}
controllerSpec
:=
newReplicationController
(
1
)
err
:=
podControl
.
DeletePod
(
"namespace-name"
,
"podName"
,
controllerSpec
)
assert
.
NoError
(
t
,
err
,
"unexpected error: %v"
,
err
)
}
func
TestActivePodFiltering
(
t
*
testing
.
T
)
{
// This rc is not needed by the test, only the newPodList to give the pods labels/a namespace.
rc
:=
newReplicationController
(
0
)
...
...
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