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
97b9c73b
Commit
97b9c73b
authored
Jun 29, 2016
by
Michail Kargakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
e2e: test for scaling+rolling out a deployment at once
parent
62afa3de
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
19 deletions
+32
-19
deployment.go
test/e2e/deployment.go
+0
-0
util.go
test/e2e/framework/util.go
+32
-19
No files found.
test/e2e/deployment.go
View file @
97b9c73b
This diff is collapsed.
Click to expand it.
test/e2e/framework/util.go
View file @
97b9c73b
...
@@ -3019,14 +3019,17 @@ func waitForReplicaSetPodsGone(c *client.Client, rs *extensions.ReplicaSet) erro
...
@@ -3019,14 +3019,17 @@ func waitForReplicaSetPodsGone(c *client.Client, rs *extensions.ReplicaSet) erro
// Waits for the deployment to reach desired state.
// Waits for the deployment to reach desired state.
// Returns an error if minAvailable or maxCreated is broken at any times.
// Returns an error if minAvailable or maxCreated is broken at any times.
func
WaitForDeploymentStatus
(
c
clientset
.
Interface
,
ns
,
deploymentName
string
,
desiredUpdatedReplicas
,
minAvailable
,
maxCreated
,
minReadySeconds
int32
)
error
{
func
WaitForDeploymentStatus
(
c
clientset
.
Interface
,
d
*
extensions
.
Deployment
,
expectComplete
bool
)
error
{
var
oldRSs
,
allOldRSs
,
allRSs
[]
*
extensions
.
ReplicaSet
var
(
var
newRS
*
extensions
.
ReplicaSet
oldRSs
,
allOldRSs
,
allRSs
[]
*
extensions
.
ReplicaSet
var
deployment
*
extensions
.
Deployment
newRS
*
extensions
.
ReplicaSet
err
:=
wait
.
Poll
(
Poll
,
5
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
deployment
*
extensions
.
Deployment
reason
string
)
err
:=
wait
.
Poll
(
Poll
,
2
*
time
.
Minute
,
func
()
(
bool
,
error
)
{
var
err
error
var
err
error
deployment
,
err
=
c
.
Extensions
()
.
Deployments
(
ns
)
.
Get
(
deployment
Name
)
deployment
,
err
=
c
.
Extensions
()
.
Deployments
(
d
.
Namespace
)
.
Get
(
d
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
...
@@ -3036,47 +3039,57 @@ func WaitForDeploymentStatus(c clientset.Interface, ns, deploymentName string, d
...
@@ -3036,47 +3039,57 @@ func WaitForDeploymentStatus(c clientset.Interface, ns, deploymentName string, d
}
}
if
newRS
==
nil
{
if
newRS
==
nil
{
// New RC hasn't been created yet.
// New RC hasn't been created yet.
reason
=
"new replica set hasn't been created yet"
return
false
,
nil
return
false
,
nil
}
}
allRSs
=
append
(
oldRSs
,
newRS
)
allRSs
=
append
(
oldRSs
,
newRS
)
// The old/new ReplicaSets need to contain the pod-template-hash label
// The old/new ReplicaSets need to contain the pod-template-hash label
for
i
:=
range
allRSs
{
for
i
:=
range
allRSs
{
if
!
labelsutil
.
SelectorHasLabel
(
allRSs
[
i
]
.
Spec
.
Selector
,
extensions
.
DefaultDeploymentUniqueLabelKey
)
{
if
!
labelsutil
.
SelectorHasLabel
(
allRSs
[
i
]
.
Spec
.
Selector
,
extensions
.
DefaultDeploymentUniqueLabelKey
)
{
reason
=
"all replica sets need to contain the pod-template-hash label"
return
false
,
nil
return
false
,
nil
}
}
}
}
totalCreated
:=
deploymentutil
.
GetReplicaCountForReplicaSets
(
allRSs
)
totalCreated
:=
deploymentutil
.
GetReplicaCountForReplicaSets
(
allRSs
)
totalAvailable
,
err
:=
deploymentutil
.
GetAvailablePodsForDeployment
(
c
,
deployment
,
m
inReadySeconds
)
totalAvailable
,
err
:=
deploymentutil
.
GetAvailablePodsForDeployment
(
c
,
deployment
,
deployment
.
Spec
.
M
inReadySeconds
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
maxCreated
:=
deployment
.
Spec
.
Replicas
+
deploymentutil
.
MaxSurge
(
*
deployment
)
if
totalCreated
>
maxCreated
{
if
totalCreated
>
maxCreated
{
logReplicaSetsOfDeployment
(
deployment
,
allOldRSs
,
newRS
)
reason
=
fmt
.
Sprintf
(
"total pods created: %d, more than the max allowed: %d"
,
totalCreated
,
maxCreated
)
logPodsOfDeployment
(
c
,
deployment
,
minReadySeconds
)
Logf
(
reason
)
return
false
,
fmt
.
Errorf
(
"total pods created: %d, more than the max allowed: %d"
,
totalCreated
,
maxCreated
)
return
false
,
nil
}
}
minAvailable
:=
deployment
.
Spec
.
Replicas
-
deploymentutil
.
MaxUnavailable
(
*
deployment
)
if
totalAvailable
<
minAvailable
{
if
totalAvailable
<
minAvailable
{
logReplicaSetsOfDeployment
(
deployment
,
allOldRSs
,
newRS
)
reason
=
fmt
.
Sprintf
(
"total pods available: %d, less than the min required: %d"
,
totalAvailable
,
minAvailable
)
logPodsOfDeployment
(
c
,
deployment
,
minReadySeconds
)
Logf
(
reason
)
return
false
,
fmt
.
Errorf
(
"total pods available: %d, less than the min required: %d"
,
totalAvailable
,
minAvailable
)
return
false
,
nil
}
if
!
expectComplete
{
return
true
,
nil
}
}
// When the deployment status and its underlying resources reach the desired state, we're done
// When the deployment status and its underlying resources reach the desired state, we're done
if
deployment
.
Status
.
Replicas
==
de
siredUpdated
Replicas
&&
if
deployment
.
Status
.
Replicas
==
de
ployment
.
Spec
.
Replicas
&&
deployment
.
Status
.
UpdatedReplicas
==
de
siredUpdated
Replicas
&&
deployment
.
Status
.
UpdatedReplicas
==
de
ployment
.
Spec
.
Replicas
&&
deploymentutil
.
GetReplicaCountForReplicaSets
(
oldRSs
)
==
0
&&
deploymentutil
.
GetReplicaCountForReplicaSets
(
oldRSs
)
==
0
&&
deploymentutil
.
GetReplicaCountForReplicaSets
([]
*
extensions
.
ReplicaSet
{
newRS
})
==
de
siredUpdated
Replicas
{
deploymentutil
.
GetReplicaCountForReplicaSets
([]
*
extensions
.
ReplicaSet
{
newRS
})
==
de
ployment
.
Spec
.
Replicas
{
return
true
,
nil
return
true
,
nil
}
}
reason
=
fmt
.
Sprintf
(
"deployment %q is yet to complete: %#v"
,
deployment
.
Name
,
deployment
.
Status
)
return
false
,
nil
return
false
,
nil
})
})
if
err
==
wait
.
ErrWaitTimeout
{
if
err
==
wait
.
ErrWaitTimeout
{
logReplicaSetsOfDeployment
(
deployment
,
allOldRSs
,
newRS
)
logReplicaSetsOfDeployment
(
deployment
,
allOldRSs
,
newRS
)
logPodsOfDeployment
(
c
,
deployment
,
minReadySeconds
)
logPodsOfDeployment
(
c
,
deployment
,
deployment
.
Spec
.
MinReadySeconds
)
err
=
fmt
.
Errorf
(
"%s"
,
reason
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error waiting for deployment %
s status to match expectation: %v"
,
deployment
Name
,
err
)
return
fmt
.
Errorf
(
"error waiting for deployment %
q status to match expectation: %v"
,
d
.
Name
,
err
)
}
}
return
nil
return
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