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
fc46de5e
Commit
fc46de5e
authored
Oct 01, 2015
by
Prashanth Balasubramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Record pod history in daemon restart e2e
parent
a463b345
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
3 deletions
+47
-3
daemon_restart.go
test/e2e/daemon_restart.go
+47
-3
No files found.
test/e2e/daemon_restart.go
View file @
fc46de5e
...
@@ -50,6 +50,9 @@ const (
...
@@ -50,6 +50,9 @@ const (
restartTimeout
=
10
*
time
.
Minute
restartTimeout
=
10
*
time
.
Minute
numPods
=
10
numPods
=
10
sshPort
=
22
sshPort
=
22
ADD
=
"ADD"
DEL
=
"DEL"
UPDATE
=
"UPDATE"
)
)
// nodeExec execs the given cmd on node via SSH. Note that the nodeName is an sshable name,
// nodeExec execs the given cmd on node via SSH. Note that the nodeName is an sshable name,
...
@@ -126,6 +129,35 @@ func (r *restartDaemonConfig) restart() {
...
@@ -126,6 +129,35 @@ func (r *restartDaemonConfig) restart() {
r
.
waitUp
()
r
.
waitUp
()
}
}
// podTracker records a serial history of events that might've affects pods.
type
podTracker
struct
{
cache
.
ThreadSafeStore
}
func
(
p
*
podTracker
)
remember
(
pod
*
api
.
Pod
,
eventType
string
)
{
if
eventType
==
UPDATE
&&
pod
.
Status
.
Phase
==
api
.
PodRunning
{
return
}
p
.
Add
(
fmt
.
Sprintf
(
"[%v] %v: %v"
,
time
.
Now
(),
eventType
,
pod
.
Name
),
pod
)
}
func
(
p
*
podTracker
)
String
()
(
msg
string
)
{
for
_
,
k
:=
range
p
.
ListKeys
()
{
obj
,
exists
:=
p
.
Get
(
k
)
if
!
exists
{
continue
}
pod
:=
obj
.
(
*
api
.
Pod
)
msg
+=
fmt
.
Sprintf
(
"%v Phase %v Host %v
\n
"
,
k
,
pod
.
Status
.
Phase
,
pod
.
Spec
.
NodeName
)
}
return
}
func
newPodTracker
()
*
podTracker
{
return
&
podTracker
{
cache
.
NewThreadSafeStore
(
cache
.
Indexers
{},
cache
.
Indices
{})}
}
// replacePods replaces content of the store with the given pods.
// replacePods replaces content of the store with the given pods.
func
replacePods
(
pods
[]
*
api
.
Pod
,
store
cache
.
Store
)
{
func
replacePods
(
pods
[]
*
api
.
Pod
,
store
cache
.
Store
)
{
found
:=
make
([]
interface
{},
0
,
len
(
pods
))
found
:=
make
([]
interface
{},
0
,
len
(
pods
))
...
@@ -162,6 +194,7 @@ var _ = Describe("DaemonRestart", func() {
...
@@ -162,6 +194,7 @@ var _ = Describe("DaemonRestart", func() {
var
controller
*
controllerFramework
.
Controller
var
controller
*
controllerFramework
.
Controller
var
newPods
cache
.
Store
var
newPods
cache
.
Store
var
stopCh
chan
struct
{}
var
stopCh
chan
struct
{}
var
tracker
*
podTracker
BeforeEach
(
func
()
{
BeforeEach
(
func
()
{
...
@@ -188,6 +221,7 @@ var _ = Describe("DaemonRestart", func() {
...
@@ -188,6 +221,7 @@ var _ = Describe("DaemonRestart", func() {
replacePods
(
*
config
.
CreatedPods
,
existingPods
)
replacePods
(
*
config
.
CreatedPods
,
existingPods
)
stopCh
=
make
(
chan
struct
{})
stopCh
=
make
(
chan
struct
{})
tracker
=
newPodTracker
()
newPods
,
controller
=
controllerFramework
.
NewInformer
(
newPods
,
controller
=
controllerFramework
.
NewInformer
(
&
cache
.
ListWatch
{
&
cache
.
ListWatch
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
...
@@ -199,7 +233,17 @@ var _ = Describe("DaemonRestart", func() {
...
@@ -199,7 +233,17 @@ var _ = Describe("DaemonRestart", func() {
},
},
&
api
.
Pod
{},
&
api
.
Pod
{},
0
,
0
,
controllerFramework
.
ResourceEventHandlerFuncs
{},
controllerFramework
.
ResourceEventHandlerFuncs
{
AddFunc
:
func
(
obj
interface
{})
{
tracker
.
remember
(
obj
.
(
*
api
.
Pod
),
ADD
)
},
UpdateFunc
:
func
(
oldObj
,
newObj
interface
{})
{
tracker
.
remember
(
newObj
.
(
*
api
.
Pod
),
UPDATE
)
},
DeleteFunc
:
func
(
obj
interface
{})
{
tracker
.
remember
(
obj
.
(
*
api
.
Pod
),
DEL
)
},
},
)
)
go
controller
.
Run
(
stopCh
)
go
controller
.
Run
(
stopCh
)
})
})
...
@@ -235,7 +279,7 @@ var _ = Describe("DaemonRestart", func() {
...
@@ -235,7 +279,7 @@ var _ = Describe("DaemonRestart", func() {
}
}
if
len
(
newKeys
.
List
())
!=
len
(
existingKeys
.
List
())
||
if
len
(
newKeys
.
List
())
!=
len
(
existingKeys
.
List
())
||
!
newKeys
.
IsSuperset
(
existingKeys
)
{
!
newKeys
.
IsSuperset
(
existingKeys
)
{
Failf
(
"RcManager created/deleted pods after restart
"
)
Failf
(
"RcManager created/deleted pods after restart
\n\n
%+v"
,
tracker
)
}
}
})
})
...
@@ -270,7 +314,7 @@ var _ = Describe("DaemonRestart", func() {
...
@@ -270,7 +314,7 @@ var _ = Describe("DaemonRestart", func() {
postRestarts
,
badNodes
:=
getContainerRestarts
(
framework
.
Client
,
ns
,
labelSelector
)
postRestarts
,
badNodes
:=
getContainerRestarts
(
framework
.
Client
,
ns
,
labelSelector
)
if
postRestarts
!=
preRestarts
{
if
postRestarts
!=
preRestarts
{
dumpNodeDebugInfo
(
framework
.
Client
,
badNodes
)
dumpNodeDebugInfo
(
framework
.
Client
,
badNodes
)
Failf
(
"Net container restart count went from %v -> %v after kubelet restart on nodes %v
"
,
preRestarts
,
postRestarts
,
badNodes
)
Failf
(
"Net container restart count went from %v -> %v after kubelet restart on nodes %v
\n\n
%+v"
,
preRestarts
,
postRestarts
,
badNodes
,
tracker
)
}
}
})
})
})
})
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