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
79e0c9f5
Commit
79e0c9f5
authored
Jan 21, 2016
by
Alex Mohr
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19842 from yujuhong/status_update
Don't handle graceful deletion of mirror pods in status manager
parents
9a264c4b
f1535a0d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
3 deletions
+61
-3
manager.go
pkg/kubelet/status/manager.go
+4
-1
manager_test.go
pkg/kubelet/status/manager_test.go
+57
-2
No files found.
pkg/kubelet/status/manager.go
View file @
79e0c9f5
...
@@ -370,7 +370,10 @@ func (m *manager) syncPod(uid types.UID, status versionedPodStatus) {
...
@@ -370,7 +370,10 @@ func (m *manager) syncPod(uid types.UID, status versionedPodStatus) {
if
err
==
nil
{
if
err
==
nil
{
glog
.
V
(
3
)
.
Infof
(
"Status for pod %q updated successfully: %+v"
,
format
.
Pod
(
pod
),
status
)
glog
.
V
(
3
)
.
Infof
(
"Status for pod %q updated successfully: %+v"
,
format
.
Pod
(
pod
),
status
)
m
.
apiStatusVersions
[
pod
.
UID
]
=
status
.
version
m
.
apiStatusVersions
[
pod
.
UID
]
=
status
.
version
if
kubepod
.
IsMirrorPod
(
pod
)
{
// We don't handle graceful deletion of mirror pods.
return
}
if
pod
.
DeletionTimestamp
==
nil
{
if
pod
.
DeletionTimestamp
==
nil
{
return
return
}
}
...
...
pkg/kubelet/status/manager_test.go
View file @
79e0c9f5
...
@@ -84,14 +84,14 @@ func getRandomPodStatus() api.PodStatus {
...
@@ -84,14 +84,14 @@ func getRandomPodStatus() api.PodStatus {
func
verifyActions
(
t
*
testing
.
T
,
kubeClient
client
.
Interface
,
expectedActions
[]
testclient
.
Action
)
{
func
verifyActions
(
t
*
testing
.
T
,
kubeClient
client
.
Interface
,
expectedActions
[]
testclient
.
Action
)
{
actions
:=
kubeClient
.
(
*
testclient
.
Fake
)
.
Actions
()
actions
:=
kubeClient
.
(
*
testclient
.
Fake
)
.
Actions
()
if
len
(
actions
)
!=
len
(
expectedActions
)
{
if
len
(
actions
)
!=
len
(
expectedActions
)
{
t
.
Fatalf
(
"unexpected actions, got: %
s expected: %s
"
,
actions
,
expectedActions
)
t
.
Fatalf
(
"unexpected actions, got: %
+v expected: %+v
"
,
actions
,
expectedActions
)
return
return
}
}
for
i
:=
0
;
i
<
len
(
actions
);
i
++
{
for
i
:=
0
;
i
<
len
(
actions
);
i
++
{
e
:=
expectedActions
[
i
]
e
:=
expectedActions
[
i
]
a
:=
actions
[
i
]
a
:=
actions
[
i
]
if
!
a
.
Matches
(
e
.
GetVerb
(),
e
.
GetResource
())
||
a
.
GetSubresource
()
!=
e
.
GetSubresource
()
{
if
!
a
.
Matches
(
e
.
GetVerb
(),
e
.
GetResource
())
||
a
.
GetSubresource
()
!=
e
.
GetSubresource
()
{
t
.
Errorf
(
"unexpected actions, got: %
s expected: %s
"
,
actions
,
expectedActions
)
t
.
Errorf
(
"unexpected actions, got: %
+v expected: %+v
"
,
actions
,
expectedActions
)
}
}
}
}
}
}
...
@@ -714,3 +714,58 @@ func expectPodStatus(t *testing.T, m *manager, pod *api.Pod) api.PodStatus {
...
@@ -714,3 +714,58 @@ func expectPodStatus(t *testing.T, m *manager, pod *api.Pod) api.PodStatus {
}
}
return
status
return
status
}
}
func
TestDeletePods
(
t
*
testing
.
T
)
{
pod
:=
getTestPod
()
// Set the deletion timestamp.
pod
.
DeletionTimestamp
=
new
(
unversioned
.
Time
)
client
:=
testclient
.
NewSimpleFake
(
pod
)
m
:=
newTestManager
(
client
)
m
.
podManager
.
AddPod
(
pod
)
status
:=
getRandomPodStatus
()
now
:=
unversioned
.
Now
()
status
.
StartTime
=
&
now
m
.
SetPodStatus
(
pod
,
status
)
m
.
testSyncBatch
()
// Expect to see an delete action.
verifyActions
(
t
,
m
.
kubeClient
,
[]
testclient
.
Action
{
testclient
.
GetActionImpl
{
ActionImpl
:
testclient
.
ActionImpl
{
Verb
:
"get"
,
Resource
:
"pods"
}},
testclient
.
UpdateActionImpl
{
ActionImpl
:
testclient
.
ActionImpl
{
Verb
:
"update"
,
Resource
:
"pods"
,
Subresource
:
"status"
}},
testclient
.
DeleteActionImpl
{
ActionImpl
:
testclient
.
ActionImpl
{
Verb
:
"delete"
,
Resource
:
"pods"
}},
})
}
func
TestDoNotDeleteMirrorPods
(
t
*
testing
.
T
)
{
staticPod
:=
getTestPod
()
staticPod
.
Annotations
=
map
[
string
]
string
{
kubetypes
.
ConfigSourceAnnotationKey
:
"file"
}
mirrorPod
:=
getTestPod
()
mirrorPod
.
UID
=
"mirror-12345678"
mirrorPod
.
Annotations
=
map
[
string
]
string
{
kubetypes
.
ConfigSourceAnnotationKey
:
"api"
,
kubetypes
.
ConfigMirrorAnnotationKey
:
"mirror"
,
}
// Set the deletion timestamp.
mirrorPod
.
DeletionTimestamp
=
new
(
unversioned
.
Time
)
client
:=
testclient
.
NewSimpleFake
(
mirrorPod
)
m
:=
newTestManager
(
client
)
m
.
podManager
.
AddPod
(
staticPod
)
m
.
podManager
.
AddPod
(
mirrorPod
)
// Verify setup.
assert
.
True
(
t
,
kubepod
.
IsStaticPod
(
staticPod
),
"SetUp error: staticPod"
)
assert
.
True
(
t
,
kubepod
.
IsMirrorPod
(
mirrorPod
),
"SetUp error: mirrorPod"
)
assert
.
Equal
(
t
,
m
.
podManager
.
TranslatePodUID
(
mirrorPod
.
UID
),
staticPod
.
UID
)
status
:=
getRandomPodStatus
()
now
:=
unversioned
.
Now
()
status
.
StartTime
=
&
now
m
.
SetPodStatus
(
staticPod
,
status
)
m
.
testSyncBatch
()
// Expect not to see an delete action.
verifyActions
(
t
,
m
.
kubeClient
,
[]
testclient
.
Action
{
testclient
.
GetActionImpl
{
ActionImpl
:
testclient
.
ActionImpl
{
Verb
:
"get"
,
Resource
:
"pods"
}},
testclient
.
UpdateActionImpl
{
ActionImpl
:
testclient
.
ActionImpl
{
Verb
:
"update"
,
Resource
:
"pods"
,
Subresource
:
"status"
}},
})
}
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