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
ac4e015e
Commit
ac4e015e
authored
Jun 01, 2018
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trigger kubelet sync pod on reconciliation
parent
d46cdbed
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
7 deletions
+27
-7
kubelet.go
pkg/kubelet/kubelet.go
+7
-0
status_manager.go
pkg/kubelet/status/status_manager.go
+20
-7
No files found.
pkg/kubelet/kubelet.go
View file @
ac4e015e
...
@@ -2042,11 +2042,18 @@ func (kl *Kubelet) HandlePodRemoves(pods []*v1.Pod) {
...
@@ -2042,11 +2042,18 @@ func (kl *Kubelet) HandlePodRemoves(pods []*v1.Pod) {
// HandlePodReconcile is the callback in the SyncHandler interface for pods
// HandlePodReconcile is the callback in the SyncHandler interface for pods
// that should be reconciled.
// that should be reconciled.
func
(
kl
*
Kubelet
)
HandlePodReconcile
(
pods
[]
*
v1
.
Pod
)
{
func
(
kl
*
Kubelet
)
HandlePodReconcile
(
pods
[]
*
v1
.
Pod
)
{
start
:=
kl
.
clock
.
Now
()
for
_
,
pod
:=
range
pods
{
for
_
,
pod
:=
range
pods
{
// Update the pod in pod manager, status manager will do periodically reconcile according
// Update the pod in pod manager, status manager will do periodically reconcile according
// to the pod manager.
// to the pod manager.
kl
.
podManager
.
UpdatePod
(
pod
)
kl
.
podManager
.
UpdatePod
(
pod
)
// Reconcile Pod "Ready" condition if necessary. Trigger sync pod for reconciliation.
if
status
.
NeedToReconcilePodReadiness
(
pod
)
{
mirrorPod
,
_
:=
kl
.
podManager
.
GetMirrorPodByPod
(
pod
)
kl
.
dispatchWork
(
pod
,
kubetypes
.
SyncPodSync
,
mirrorPod
,
start
)
}
// After an evicted pod is synced, all dead containers in the pod can be removed.
// After an evicted pod is synced, all dead containers in the pod can be removed.
if
eviction
.
PodIsEvicted
(
pod
.
Status
)
{
if
eviction
.
PodIsEvicted
(
pod
.
Status
)
{
if
podStatus
,
err
:=
kl
.
podCache
.
Get
(
pod
.
UID
);
err
==
nil
{
if
podStatus
,
err
:=
kl
.
podCache
.
Get
(
pod
.
UID
);
err
==
nil
{
...
...
pkg/kubelet/status/status_manager.go
View file @
ac4e015e
...
@@ -227,21 +227,20 @@ func (m *manager) SetContainerReadiness(podUID types.UID, containerID kubecontai
...
@@ -227,21 +227,20 @@ func (m *manager) SetContainerReadiness(podUID types.UID, containerID kubecontai
containerStatus
.
Ready
=
ready
containerStatus
.
Ready
=
ready
// Update pod condition.
// Update pod condition.
r
eadyConditionIndex
:=
-
1
podR
eadyConditionIndex
:=
-
1
for
i
,
condition
:=
range
status
.
Conditions
{
for
i
,
condition
:=
range
status
.
Conditions
{
if
condition
.
Type
==
v1
.
PodReady
{
if
condition
.
Type
==
v1
.
PodReady
{
r
eadyConditionIndex
=
i
podR
eadyConditionIndex
=
i
break
break
}
}
}
}
readyCondition
:=
GeneratePodReadyCondition
(
&
pod
.
Spec
,
status
.
ContainerStatuses
,
status
.
Phase
)
podReady
:=
GeneratePodReadyCondition
(
&
pod
.
Spec
,
status
.
Conditions
,
status
.
ContainerStatuses
,
status
.
Phase
)
if
r
eadyConditionIndex
!=
-
1
{
if
podR
eadyConditionIndex
!=
-
1
{
status
.
Conditions
[
readyConditionIndex
]
=
readyCondition
status
.
Conditions
[
podReadyConditionIndex
]
=
podReady
}
else
{
}
else
{
glog
.
Warningf
(
"PodStatus missing PodReady condition: %+v"
,
status
)
glog
.
Warningf
(
"PodStatus missing PodReady condition: %+v"
,
status
)
status
.
Conditions
=
append
(
status
.
Conditions
,
readyCondition
)
status
.
Conditions
=
append
(
status
.
Conditions
,
podReady
)
}
}
m
.
updateStatusInternal
(
pod
,
status
,
false
)
m
.
updateStatusInternal
(
pod
,
status
,
false
)
}
}
...
@@ -652,3 +651,17 @@ func mergePodStatus(oldPodStatus, newPodStatus v1.PodStatus) v1.PodStatus {
...
@@ -652,3 +651,17 @@ func mergePodStatus(oldPodStatus, newPodStatus v1.PodStatus) v1.PodStatus {
newPodStatus
.
Conditions
=
podConditions
newPodStatus
.
Conditions
=
podConditions
return
newPodStatus
return
newPodStatus
}
}
// NeedToReconcilePodReadiness returns if the pod "Ready" condition need to be reconcile
func
NeedToReconcilePodReadiness
(
pod
*
v1
.
Pod
)
bool
{
if
len
(
pod
.
Spec
.
ReadinessGates
)
==
0
{
return
false
}
podReadyCondition
:=
GeneratePodReadyCondition
(
&
pod
.
Spec
,
pod
.
Status
.
Conditions
,
pod
.
Status
.
ContainerStatuses
,
pod
.
Status
.
Phase
)
i
,
curCondition
:=
podutil
.
GetPodConditionFromList
(
pod
.
Status
.
Conditions
,
v1
.
PodReady
)
// Only reconcile if "Ready" condition is present
if
i
>=
0
&&
curCondition
.
Status
!=
podReadyCondition
.
Status
{
return
true
}
return
false
}
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