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
3ee150fc
Commit
3ee150fc
authored
Dec 22, 2016
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubectl: ignore deleted pods in the rolling updater
parent
f9707a7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
rolling_updater.go
pkg/kubectl/rolling_updater.go
+4
-0
rolling_updater_test.go
pkg/kubectl/rolling_updater_test.go
+30
-2
No files found.
pkg/kubectl/rolling_updater.go
View file @
3ee150fc
...
...
@@ -425,6 +425,10 @@ func (r *RollingUpdater) readyPods(oldRc, newRc *api.ReplicationController, minR
if
err
:=
v1
.
Convert_api_Pod_To_v1_Pod
(
&
pod
,
v1Pod
,
nil
);
err
!=
nil
{
return
0
,
0
,
err
}
// Do not count deleted pods as ready
if
v1Pod
.
DeletionTimestamp
!=
nil
{
continue
}
if
!
deploymentutil
.
IsPodAvailable
(
v1Pod
,
minReadySeconds
,
r
.
nowFn
()
.
Time
)
{
continue
}
...
...
pkg/kubectl/rolling_updater_test.go
View file @
3ee150fc
...
...
@@ -1651,6 +1651,10 @@ func TestRollingUpdater_readyPods(t *testing.T) {
// pods owned by the rcs; indicate whether they're ready
oldPods
[]
bool
newPods
[]
bool
// deletions - should be less then the size of the respective slice above
// eg. len(oldPods) > oldPodDeletions && len(newPods) > newPodDeletions
oldPodDeletions
int
newPodDeletions
int
// specify additional time to wait for deployment to wait on top of the
// pod ready time
minReadySeconds
int32
...
...
@@ -1728,6 +1732,18 @@ func TestRollingUpdater_readyPods(t *testing.T) {
nowFn
:
func
()
metav1
.
Time
{
return
metav1
.
Time
{
Time
:
now
.
Add
(
time
.
Duration
(
6
*
time
.
Second
))}
},
podReadyTimeFn
:
func
()
metav1
.
Time
{
return
now
},
},
{
oldRc
:
oldRc
(
4
,
4
),
newRc
:
newRc
(
4
,
4
),
oldReady
:
2
,
newReady
:
0
,
oldPods
:
[]
bool
{
// All old pods are ready
true
,
true
,
true
,
true
,
},
// Two of them have been marked for deletion though
oldPodDeletions
:
2
,
},
}
for
i
,
test
:=
range
tests
{
...
...
@@ -1741,10 +1757,22 @@ func TestRollingUpdater_readyPods(t *testing.T) {
// Populate the fake client with pods associated with their owners.
pods
:=
[]
runtime
.
Object
{}
for
_
,
ready
:=
range
test
.
oldPods
{
pods
=
append
(
pods
,
mkpod
(
test
.
oldRc
,
ready
,
test
.
podReadyTimeFn
()))
pod
:=
mkpod
(
test
.
oldRc
,
ready
,
test
.
podReadyTimeFn
())
if
test
.
oldPodDeletions
>
0
{
now
:=
metav1
.
Now
()
pod
.
DeletionTimestamp
=
&
now
test
.
oldPodDeletions
--
}
pods
=
append
(
pods
,
pod
)
}
for
_
,
ready
:=
range
test
.
newPods
{
pods
=
append
(
pods
,
mkpod
(
test
.
newRc
,
ready
,
test
.
podReadyTimeFn
()))
pod
:=
mkpod
(
test
.
newRc
,
ready
,
test
.
podReadyTimeFn
())
if
test
.
newPodDeletions
>
0
{
now
:=
metav1
.
Now
()
pod
.
DeletionTimestamp
=
&
now
test
.
newPodDeletions
--
}
pods
=
append
(
pods
,
pod
)
}
client
:=
fake
.
NewSimpleClientset
(
pods
...
)
...
...
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