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
f1e83562
Unverified
Commit
f1e83562
authored
Apr 19, 2017
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deployments complete only when all desired pods are available
Signed-off-by:
Michail Kargakis
<
mkargaki@redhat.com
>
parent
0a59f6c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
10 deletions
+16
-10
deployment_util.go
pkg/controller/deployment/util/deployment_util.go
+4
-4
deployment_util_test.go
pkg/controller/deployment/util/deployment_util_test.go
+12
-6
No files found.
pkg/controller/deployment/util/deployment_util.go
View file @
f1e83562
...
...
@@ -410,7 +410,7 @@ func SetReplicasAnnotations(rs *extensions.ReplicaSet, desiredReplicas, maxRepli
// MaxUnavailable returns the maximum unavailable pods a rolling deployment can take.
func
MaxUnavailable
(
deployment
extensions
.
Deployment
)
int32
{
if
!
IsRollingUpdate
(
&
deployment
)
{
if
!
IsRollingUpdate
(
&
deployment
)
||
*
(
deployment
.
Spec
.
Replicas
)
==
0
{
return
int32
(
0
)
}
// Error caught by validation
...
...
@@ -828,12 +828,12 @@ func IsRollingUpdate(deployment *extensions.Deployment) bool {
return
deployment
.
Spec
.
Strategy
.
Type
==
extensions
.
RollingUpdateDeploymentStrategyType
}
// DeploymentComplete considers a deployment to be complete once
its desired replicas equals it
s
//
updatedReplicas, no old pods are running, and it doesn't violate minimum availability
.
// DeploymentComplete considers a deployment to be complete once
all of its desired replica
s
//
are updated and available, and no old pods are running
.
func
DeploymentComplete
(
deployment
*
extensions
.
Deployment
,
newStatus
*
extensions
.
DeploymentStatus
)
bool
{
return
newStatus
.
UpdatedReplicas
==
*
(
deployment
.
Spec
.
Replicas
)
&&
newStatus
.
Replicas
==
*
(
deployment
.
Spec
.
Replicas
)
&&
newStatus
.
AvailableReplicas
>=
*
(
deployment
.
Spec
.
Replicas
)
-
MaxUnavailable
(
*
deployment
)
&&
newStatus
.
AvailableReplicas
==
*
(
deployment
.
Spec
.
Replicas
)
&&
newStatus
.
ObservedGeneration
>=
deployment
.
Generation
}
...
...
pkg/controller/deployment/util/deployment_util_test.go
View file @
f1e83562
...
...
@@ -960,37 +960,43 @@ func TestDeploymentComplete(t *testing.T) {
expected
bool
}{
{
name
:
"
complet
e"
,
name
:
"
not complete: min but not all pods become availabl
e"
,
d
:
deployment
(
5
,
5
,
5
,
4
,
1
,
0
),
expected
:
tru
e
,
expected
:
fals
e
,
},
{
name
:
"not complete"
,
name
:
"not complete
: min availability is not honored
"
,
d
:
deployment
(
5
,
5
,
5
,
3
,
1
,
0
),
expected
:
false
,
},
{
name
:
"complete
#2
"
,
name
:
"complete"
,
d
:
deployment
(
5
,
5
,
5
,
5
,
0
,
0
),
expected
:
true
,
},
{
name
:
"not complete
#2
"
,
name
:
"not complete
: all pods are available but not updated
"
,
d
:
deployment
(
5
,
5
,
4
,
5
,
0
,
0
),
expected
:
false
,
},
{
name
:
"not complete
#3
"
,
name
:
"not complete
: still running old pods
"
,
// old replica set: spec.replicas=1, status.replicas=1, status.availableReplicas=1
// new replica set: spec.replicas=1, status.replicas=1, status.availableReplicas=0
d
:
deployment
(
1
,
2
,
1
,
1
,
0
,
1
),
expected
:
false
,
},
{
name
:
"not complete: one replica deployment never comes up"
,
d
:
deployment
(
1
,
1
,
1
,
0
,
1
,
1
),
expected
:
false
,
},
}
for
_
,
test
:=
range
tests
{
...
...
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