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
6ceb221f
Commit
6ceb221f
authored
Feb 19, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log pods of RS when deployment e2e test fails
parent
6766f11a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
18 deletions
+39
-18
deployment.go
pkg/util/deployment/deployment.go
+25
-18
util.go
test/e2e/util.go
+14
-0
No files found.
pkg/util/deployment/deployment.go
View file @
6ceb221f
...
...
@@ -179,7 +179,7 @@ func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int {
// Returns the number of available pods corresponding to the given replica sets.
func
GetAvailablePodsForReplicaSets
(
c
clientset
.
Interface
,
rss
[]
*
extensions
.
ReplicaSet
,
minReadySeconds
int
)
(
int
,
error
)
{
allPods
,
err
:=
g
etPodsForReplicaSets
(
c
,
rss
)
allPods
,
err
:=
G
etPodsForReplicaSets
(
c
,
rss
)
if
err
!=
nil
{
return
0
,
err
}
...
...
@@ -189,28 +189,35 @@ func GetAvailablePodsForReplicaSets(c clientset.Interface, rss []*extensions.Rep
func
getReadyPodsCount
(
pods
[]
api
.
Pod
,
minReadySeconds
int
)
int
{
readyPodCount
:=
0
for
_
,
pod
:=
range
pods
{
if
api
.
IsPodReady
(
&
pod
)
{
// Check if we've passed minReadySeconds since LastTransitionTime
// If so, this pod is ready
for
_
,
c
:=
range
pod
.
Status
.
Conditions
{
// we only care about pod ready conditions
if
c
.
Type
==
api
.
PodReady
{
// 2 cases that this ready condition is valid (passed minReadySeconds, i.e. the pod is ready):
// 1. minReadySeconds <= 0
// 2. LastTransitionTime (is set) + minReadySeconds (>0) < current time
minReadySecondsDuration
:=
time
.
Duration
(
minReadySeconds
)
*
time
.
Second
if
minReadySeconds
<=
0
||
!
c
.
LastTransitionTime
.
IsZero
()
&&
c
.
LastTransitionTime
.
Add
(
minReadySecondsDuration
)
.
Before
(
time
.
Now
())
{
readyPodCount
++
break
}
}
}
if
IsPodAvailable
(
&
pod
,
minReadySeconds
)
{
readyPodCount
++
}
}
return
readyPodCount
}
func
getPodsForReplicaSets
(
c
clientset
.
Interface
,
replicaSets
[]
*
extensions
.
ReplicaSet
)
([]
api
.
Pod
,
error
)
{
func
IsPodAvailable
(
pod
*
api
.
Pod
,
minReadySeconds
int
)
bool
{
if
!
api
.
IsPodReady
(
pod
)
{
return
false
}
// Check if we've passed minReadySeconds since LastTransitionTime
// If so, this pod is ready
for
_
,
c
:=
range
pod
.
Status
.
Conditions
{
// we only care about pod ready conditions
if
c
.
Type
==
api
.
PodReady
{
// 2 cases that this ready condition is valid (passed minReadySeconds, i.e. the pod is ready):
// 1. minReadySeconds <= 0
// 2. LastTransitionTime (is set) + minReadySeconds (>0) < current time
minReadySecondsDuration
:=
time
.
Duration
(
minReadySeconds
)
*
time
.
Second
if
minReadySeconds
<=
0
||
!
c
.
LastTransitionTime
.
IsZero
()
&&
c
.
LastTransitionTime
.
Add
(
minReadySecondsDuration
)
.
Before
(
time
.
Now
())
{
return
true
}
}
}
return
false
}
func
GetPodsForReplicaSets
(
c
clientset
.
Interface
,
replicaSets
[]
*
extensions
.
ReplicaSet
)
([]
api
.
Pod
,
error
)
{
allPods
:=
[]
api
.
Pod
{}
for
_
,
rs
:=
range
replicaSets
{
selector
,
err
:=
unversioned
.
LabelSelectorAsSelector
(
rs
.
Spec
.
Selector
)
...
...
test/e2e/util.go
View file @
6ceb221f
...
...
@@ -2128,6 +2128,7 @@ func waitForDeploymentStatus(c clientset.Interface, ns, deploymentName string, d
}
if
totalAvailable
<
minAvailable
{
logReplicaSetsOfDeployment
(
deploymentName
,
oldRSs
,
newRS
)
logPodsOfReplicaSets
(
c
,
allRSs
,
minReadySeconds
)
return
false
,
fmt
.
Errorf
(
"total pods available: %d, less than the min required: %d"
,
totalAvailable
,
minAvailable
)
}
...
...
@@ -2170,6 +2171,19 @@ func logReplicaSetsOfDeployment(deploymentName string, oldRSs []*extensions.Repl
Logf
(
"New ReplicaSet of deployment %s: %+v"
,
deploymentName
,
newRS
)
}
func
logPodsOfReplicaSets
(
c
clientset
.
Interface
,
rss
[]
*
extensions
.
ReplicaSet
,
minReadySeconds
int
)
{
allPods
,
err
:=
deploymentutil
.
GetPodsForReplicaSets
(
c
,
rss
)
if
err
==
nil
{
for
_
,
pod
:=
range
allPods
{
availability
:=
"not available"
if
deploymentutil
.
IsPodAvailable
(
&
pod
,
minReadySeconds
)
{
availability
=
"available"
}
Logf
(
"Pod %s is %s: %+v"
,
pod
.
Name
,
availability
,
pod
)
}
}
}
// Waits for the number of events on the given object to reach a desired count.
func
waitForEvents
(
c
*
client
.
Client
,
ns
string
,
objOrRef
runtime
.
Object
,
desiredEventsCount
int
)
error
{
return
wait
.
Poll
(
poll
,
5
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
...
...
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