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
2aaf8bdd
Commit
2aaf8bdd
authored
Aug 19, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update controllers and client to handle terminating pods
parent
02dbb954
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
3 deletions
+31
-3
controller_utils.go
pkg/controller/controller_utils.go
+2
-1
endpoints_controller.go
pkg/controller/endpoint/endpoints_controller.go
+5
-1
replication_controller.go
pkg/controller/replication/replication_controller.go
+15
-0
describe.go
pkg/kubectl/describe.go
+6
-1
resource_printer.go
pkg/kubectl/resource_printer.go
+3
-0
No files found.
pkg/controller/controller_utils.go
View file @
2aaf8bdd
...
@@ -322,7 +322,8 @@ func FilterActivePods(pods []api.Pod) []*api.Pod {
...
@@ -322,7 +322,8 @@ func FilterActivePods(pods []api.Pod) []*api.Pod {
var
result
[]
*
api
.
Pod
var
result
[]
*
api
.
Pod
for
i
:=
range
pods
{
for
i
:=
range
pods
{
if
api
.
PodSucceeded
!=
pods
[
i
]
.
Status
.
Phase
&&
if
api
.
PodSucceeded
!=
pods
[
i
]
.
Status
.
Phase
&&
api
.
PodFailed
!=
pods
[
i
]
.
Status
.
Phase
{
api
.
PodFailed
!=
pods
[
i
]
.
Status
.
Phase
&&
pods
[
i
]
.
DeletionTimestamp
==
nil
{
result
=
append
(
result
,
&
pods
[
i
])
result
=
append
(
result
,
&
pods
[
i
])
}
}
}
}
...
...
pkg/controller/endpoint/endpoints_controller.go
View file @
2aaf8bdd
...
@@ -310,7 +310,11 @@ func (e *EndpointController) syncService(key string) {
...
@@ -310,7 +310,11 @@ func (e *EndpointController) syncService(key string) {
continue
continue
}
}
if
len
(
pod
.
Status
.
PodIP
)
==
0
{
if
len
(
pod
.
Status
.
PodIP
)
==
0
{
glog
.
V
(
4
)
.
Infof
(
"Failed to find an IP for pod %s/%s"
,
pod
.
Namespace
,
pod
.
Name
)
glog
.
V
(
5
)
.
Infof
(
"Failed to find an IP for pod %s/%s"
,
pod
.
Namespace
,
pod
.
Name
)
continue
}
if
pod
.
DeletionTimestamp
!=
nil
{
glog
.
V
(
5
)
.
Infof
(
"Pod is being deleted %s/%s"
,
pod
.
Namespace
,
pod
.
Name
)
continue
continue
}
}
...
...
pkg/controller/replication/replication_controller.go
View file @
2aaf8bdd
...
@@ -213,6 +213,12 @@ func (rm *ReplicationManager) getPodController(pod *api.Pod) *api.ReplicationCon
...
@@ -213,6 +213,12 @@ func (rm *ReplicationManager) getPodController(pod *api.Pod) *api.ReplicationCon
// When a pod is created, enqueue the controller that manages it and update it's expectations.
// When a pod is created, enqueue the controller that manages it and update it's expectations.
func
(
rm
*
ReplicationManager
)
addPod
(
obj
interface
{})
{
func
(
rm
*
ReplicationManager
)
addPod
(
obj
interface
{})
{
pod
:=
obj
.
(
*
api
.
Pod
)
pod
:=
obj
.
(
*
api
.
Pod
)
if
pod
.
DeletionTimestamp
!=
nil
{
// on a restart of the controller manager, it's possible a new pod shows up in a state that
// is already pending deletion. Prevent the pod from being a creation observation.
rm
.
deletePod
(
pod
)
return
}
if
rc
:=
rm
.
getPodController
(
pod
);
rc
!=
nil
{
if
rc
:=
rm
.
getPodController
(
pod
);
rc
!=
nil
{
rcKey
,
err
:=
controller
.
KeyFunc
(
rc
)
rcKey
,
err
:=
controller
.
KeyFunc
(
rc
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -234,6 +240,15 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
...
@@ -234,6 +240,15 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
}
}
// TODO: Write a unittest for this case
// TODO: Write a unittest for this case
curPod
:=
cur
.
(
*
api
.
Pod
)
curPod
:=
cur
.
(
*
api
.
Pod
)
if
curPod
.
DeletionTimestamp
!=
nil
{
// when a pod is deleted gracefully it's deletion timestamp is first modified to reflect a grace period,
// and after such time has passed, the kubelet actually deletes it from the store. We receive an update
// for modification of the deletion timestamp and expect an rc to create more replicas asap, not wait
// until the kubelet actually deletes the pod. This is different from the Phase of a pod changing, because
// an rc never initiates a phase change, and so is never asleep waiting for the same.
rm
.
deletePod
(
curPod
)
return
}
if
rc
:=
rm
.
getPodController
(
curPod
);
rc
!=
nil
{
if
rc
:=
rm
.
getPodController
(
curPod
);
rc
!=
nil
{
rm
.
enqueueController
(
rc
)
rm
.
enqueueController
(
rc
)
}
}
...
...
pkg/kubectl/describe.go
View file @
2aaf8bdd
...
@@ -417,7 +417,12 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
...
@@ -417,7 +417,12 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
makeImageList
(
&
pod
.
Spec
))
fmt
.
Fprintf
(
out
,
"Image(s):
\t
%s
\n
"
,
makeImageList
(
&
pod
.
Spec
))
fmt
.
Fprintf
(
out
,
"Node:
\t
%s
\n
"
,
pod
.
Spec
.
NodeName
+
"/"
+
pod
.
Status
.
HostIP
)
fmt
.
Fprintf
(
out
,
"Node:
\t
%s
\n
"
,
pod
.
Spec
.
NodeName
+
"/"
+
pod
.
Status
.
HostIP
)
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
pod
.
Labels
))
fmt
.
Fprintf
(
out
,
"Labels:
\t
%s
\n
"
,
formatLabels
(
pod
.
Labels
))
fmt
.
Fprintf
(
out
,
"Status:
\t
%s
\n
"
,
string
(
pod
.
Status
.
Phase
))
if
pod
.
DeletionTimestamp
!=
nil
{
fmt
.
Fprintf
(
out
,
"Status:
\t
Terminating (expires %s)
\n
"
,
pod
.
DeletionTimestamp
.
Time
.
Format
(
time
.
RFC1123Z
))
fmt
.
Fprintf
(
out
,
"Termination Grace Period:
\t
%ds
\n
"
,
pod
.
DeletionGracePeriodSeconds
)
}
else
{
fmt
.
Fprintf
(
out
,
"Status:
\t
%s
\n
"
,
string
(
pod
.
Status
.
Phase
))
}
fmt
.
Fprintf
(
out
,
"Reason:
\t
%s
\n
"
,
pod
.
Status
.
Reason
)
fmt
.
Fprintf
(
out
,
"Reason:
\t
%s
\n
"
,
pod
.
Status
.
Reason
)
fmt
.
Fprintf
(
out
,
"Message:
\t
%s
\n
"
,
pod
.
Status
.
Message
)
fmt
.
Fprintf
(
out
,
"Message:
\t
%s
\n
"
,
pod
.
Status
.
Message
)
fmt
.
Fprintf
(
out
,
"IP:
\t
%s
\n
"
,
pod
.
Status
.
PodIP
)
fmt
.
Fprintf
(
out
,
"IP:
\t
%s
\n
"
,
pod
.
Status
.
PodIP
)
...
...
pkg/kubectl/resource_printer.go
View file @
2aaf8bdd
...
@@ -425,6 +425,9 @@ func printPod(pod *api.Pod, w io.Writer, withNamespace bool, wide bool, showAll
...
@@ -425,6 +425,9 @@ func printPod(pod *api.Pod, w io.Writer, withNamespace bool, wide bool, showAll
readyContainers
++
readyContainers
++
}
}
}
}
if
pod
.
DeletionTimestamp
!=
nil
{
reason
=
"Terminating"
}
if
withNamespace
{
if
withNamespace
{
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
"
,
namespace
);
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
"
,
namespace
);
err
!=
nil
{
...
...
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