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
7255af6d
Commit
7255af6d
authored
Jan 27, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix e2e test failure for RecreateDeployment
parent
458eb528
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
11 deletions
+23
-11
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+23
-11
No files found.
pkg/controller/deployment/deployment_controller.go
View file @
7255af6d
...
...
@@ -504,13 +504,11 @@ func (dc *DeploymentController) syncRollingUpdateDeployment(deployment extension
// syncDeploymentStatus checks if the status is up-to-date and sync it if necessary
func
(
dc
*
DeploymentController
)
syncDeploymentStatus
(
allRCs
[]
*
api
.
ReplicationController
,
newRC
*
api
.
ReplicationController
,
deployment
extensions
.
Deployment
)
error
{
totalReplicas
:=
deploymentutil
.
GetReplicaCountForRCs
(
allRCs
)
updatedReplicas
:=
deploymentutil
.
GetReplicaCountForRCs
([]
*
api
.
ReplicationController
{
newRC
})
availablePods
,
err
:=
deploymentutil
.
GetAvailablePodsForRCs
(
dc
.
client
,
allRCs
,
deployment
.
Spec
.
Strategy
.
RollingUpdate
.
MinReadySeconds
)
totalReplicas
,
updatedReplicas
,
availableReplicas
,
_
,
err
:=
dc
.
calculateStatus
(
allRCs
,
newRC
,
deployment
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to count ready pods: %v"
,
err
)
return
err
}
if
deployment
.
Status
.
Replicas
!=
totalReplicas
||
deployment
.
Status
.
UpdatedReplicas
!=
updatedReplicas
||
deployment
.
Status
.
AvailableReplicas
!=
available
Pod
s
{
if
deployment
.
Status
.
Replicas
!=
totalReplicas
||
deployment
.
Status
.
UpdatedReplicas
!=
updatedReplicas
||
deployment
.
Status
.
AvailableReplicas
!=
available
Replica
s
{
return
dc
.
updateDeploymentStatus
(
allRCs
,
newRC
,
deployment
)
}
return
nil
...
...
@@ -709,24 +707,38 @@ func (dc *DeploymentController) scaleUpNewRCForRecreate(newRC *api.ReplicationCo
}
func
(
dc
*
DeploymentController
)
updateDeploymentStatus
(
allRCs
[]
*
api
.
ReplicationController
,
newRC
*
api
.
ReplicationController
,
deployment
extensions
.
Deployment
)
error
{
totalReplicas
:=
deploymentutil
.
GetReplicaCountForRCs
(
allRCs
)
updatedReplicas
:=
deploymentutil
.
GetReplicaCountForRCs
([]
*
api
.
ReplicationController
{
newRC
})
availablePods
,
err
:=
deploymentutil
.
GetAvailablePodsForRCs
(
dc
.
client
,
allRCs
,
deployment
.
Spec
.
Strategy
.
RollingUpdate
.
MinReadySeconds
)
totalReplicas
,
updatedReplicas
,
availableReplicas
,
unavailableReplicas
,
err
:=
dc
.
calculateStatus
(
allRCs
,
newRC
,
deployment
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to count ready pods: %v"
,
err
)
return
err
}
newDeployment
:=
deployment
// TODO: Reconcile this with API definition. API definition talks about ready pods, while this just computes created pods.
newDeployment
.
Status
=
extensions
.
DeploymentStatus
{
Replicas
:
totalReplicas
,
UpdatedReplicas
:
updatedReplicas
,
AvailableReplicas
:
available
Pod
s
,
UnavailableReplicas
:
totalReplicas
-
availablePod
s
,
AvailableReplicas
:
available
Replica
s
,
UnavailableReplicas
:
unavailableReplica
s
,
}
_
,
err
=
dc
.
expClient
.
Deployments
(
deployment
.
ObjectMeta
.
Namespace
)
.
UpdateStatus
(
&
newDeployment
)
return
err
}
func
(
dc
*
DeploymentController
)
calculateStatus
(
allRCs
[]
*
api
.
ReplicationController
,
newRC
*
api
.
ReplicationController
,
deployment
extensions
.
Deployment
)
(
totalReplicas
,
updatedReplicas
,
availableReplicas
,
unavailableReplicas
int
,
err
error
)
{
totalReplicas
=
deploymentutil
.
GetReplicaCountForRCs
(
allRCs
)
updatedReplicas
=
deploymentutil
.
GetReplicaCountForRCs
([]
*
api
.
ReplicationController
{
newRC
})
minReadySeconds
:=
0
if
deployment
.
Spec
.
Strategy
.
Type
==
extensions
.
RollingUpdateDeploymentStrategyType
{
minReadySeconds
=
deployment
.
Spec
.
Strategy
.
RollingUpdate
.
MinReadySeconds
}
availableReplicas
,
err
=
deploymentutil
.
GetAvailablePodsForRCs
(
dc
.
client
,
allRCs
,
minReadySeconds
)
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"failed to count available pods: %v"
,
err
)
return
}
unavailableReplicas
=
totalReplicas
-
availableReplicas
return
}
func
(
dc
*
DeploymentController
)
scaleRCAndRecordEvent
(
rc
*
api
.
ReplicationController
,
newScale
int
,
deployment
extensions
.
Deployment
)
(
*
api
.
ReplicationController
,
error
)
{
scalingOperation
:=
"down"
if
rc
.
Spec
.
Replicas
<
newScale
{
...
...
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