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
062b9f86
Commit
062b9f86
authored
Feb 24, 2016
by
Janet Kuo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the incorrect deployment.status.unavailableReplicas
parent
4add4eba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
deployment_controller.go
pkg/controller/deployment/deployment_controller.go
+7
-6
deployment.go
pkg/util/deployment/deployment.go
+10
-4
No files found.
pkg/controller/deployment/deployment_controller.go
View file @
062b9f86
...
@@ -578,11 +578,11 @@ func (dc *DeploymentController) syncRollingUpdateDeployment(deployment extension
...
@@ -578,11 +578,11 @@ func (dc *DeploymentController) syncRollingUpdateDeployment(deployment extension
// syncDeploymentStatus checks if the status is up-to-date and sync it if necessary
// syncDeploymentStatus checks if the status is up-to-date and sync it if necessary
func
(
dc
*
DeploymentController
)
syncDeploymentStatus
(
allRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
,
d
extensions
.
Deployment
)
error
{
func
(
dc
*
DeploymentController
)
syncDeploymentStatus
(
allRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
,
d
extensions
.
Deployment
)
error
{
totalReplicas
,
updatedReplicas
,
availableReplicas
,
_
,
err
:=
dc
.
calculateStatus
(
allRSs
,
newRS
,
d
)
total
Actual
Replicas
,
updatedReplicas
,
availableReplicas
,
_
,
err
:=
dc
.
calculateStatus
(
allRSs
,
newRS
,
d
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
d
.
Generation
>
d
.
Status
.
ObservedGeneration
||
d
.
Status
.
Replicas
!=
totalReplicas
||
d
.
Status
.
UpdatedReplicas
!=
updatedReplicas
||
d
.
Status
.
AvailableReplicas
!=
availableReplicas
{
if
d
.
Generation
>
d
.
Status
.
ObservedGeneration
||
d
.
Status
.
Replicas
!=
total
Actual
Replicas
||
d
.
Status
.
UpdatedReplicas
!=
updatedReplicas
||
d
.
Status
.
AvailableReplicas
!=
availableReplicas
{
return
dc
.
updateDeploymentStatus
(
allRSs
,
newRS
,
d
)
return
dc
.
updateDeploymentStatus
(
allRSs
,
newRS
,
d
)
}
}
return
nil
return
nil
...
@@ -1029,7 +1029,7 @@ func (dc *DeploymentController) cleanupOldReplicaSets(oldRSs []*extensions.Repli
...
@@ -1029,7 +1029,7 @@ func (dc *DeploymentController) cleanupOldReplicaSets(oldRSs []*extensions.Repli
}
}
func
(
dc
*
DeploymentController
)
updateDeploymentStatus
(
allRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
,
deployment
extensions
.
Deployment
)
error
{
func
(
dc
*
DeploymentController
)
updateDeploymentStatus
(
allRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
,
deployment
extensions
.
Deployment
)
error
{
totalReplicas
,
updatedReplicas
,
availableReplicas
,
unavailableReplicas
,
err
:=
dc
.
calculateStatus
(
allRSs
,
newRS
,
deployment
)
total
Actual
Replicas
,
updatedReplicas
,
availableReplicas
,
unavailableReplicas
,
err
:=
dc
.
calculateStatus
(
allRSs
,
newRS
,
deployment
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -1038,7 +1038,7 @@ func (dc *DeploymentController) updateDeploymentStatus(allRSs []*extensions.Repl
...
@@ -1038,7 +1038,7 @@ func (dc *DeploymentController) updateDeploymentStatus(allRSs []*extensions.Repl
newDeployment
.
Status
=
extensions
.
DeploymentStatus
{
newDeployment
.
Status
=
extensions
.
DeploymentStatus
{
// TODO: Ensure that if we start retrying status updates, we won't pick up a new Generation value.
// TODO: Ensure that if we start retrying status updates, we won't pick up a new Generation value.
ObservedGeneration
:
deployment
.
Generation
,
ObservedGeneration
:
deployment
.
Generation
,
Replicas
:
totalReplicas
,
Replicas
:
total
Actual
Replicas
,
UpdatedReplicas
:
updatedReplicas
,
UpdatedReplicas
:
updatedReplicas
,
AvailableReplicas
:
availableReplicas
,
AvailableReplicas
:
availableReplicas
,
UnavailableReplicas
:
unavailableReplicas
,
UnavailableReplicas
:
unavailableReplicas
,
...
@@ -1047,8 +1047,8 @@ func (dc *DeploymentController) updateDeploymentStatus(allRSs []*extensions.Repl
...
@@ -1047,8 +1047,8 @@ func (dc *DeploymentController) updateDeploymentStatus(allRSs []*extensions.Repl
return
err
return
err
}
}
func
(
dc
*
DeploymentController
)
calculateStatus
(
allRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
,
deployment
extensions
.
Deployment
)
(
totalReplicas
,
updatedReplicas
,
availableReplicas
,
unavailableReplicas
int
,
err
error
)
{
func
(
dc
*
DeploymentController
)
calculateStatus
(
allRSs
[]
*
extensions
.
ReplicaSet
,
newRS
*
extensions
.
ReplicaSet
,
deployment
extensions
.
Deployment
)
(
total
Actual
Replicas
,
updatedReplicas
,
availableReplicas
,
unavailableReplicas
int
,
err
error
)
{
totalReplicas
=
deploymentutil
.
GetActualReplicaCountForReplicaSets
(
allRSs
)
total
Actual
Replicas
=
deploymentutil
.
GetActualReplicaCountForReplicaSets
(
allRSs
)
updatedReplicas
=
deploymentutil
.
GetActualReplicaCountForReplicaSets
([]
*
extensions
.
ReplicaSet
{
newRS
})
updatedReplicas
=
deploymentutil
.
GetActualReplicaCountForReplicaSets
([]
*
extensions
.
ReplicaSet
{
newRS
})
minReadySeconds
:=
deployment
.
Spec
.
MinReadySeconds
minReadySeconds
:=
deployment
.
Spec
.
MinReadySeconds
availableReplicas
,
err
=
deploymentutil
.
GetAvailablePodsForReplicaSets
(
dc
.
client
,
allRSs
,
minReadySeconds
)
availableReplicas
,
err
=
deploymentutil
.
GetAvailablePodsForReplicaSets
(
dc
.
client
,
allRSs
,
minReadySeconds
)
...
@@ -1056,6 +1056,7 @@ func (dc *DeploymentController) calculateStatus(allRSs []*extensions.ReplicaSet,
...
@@ -1056,6 +1056,7 @@ func (dc *DeploymentController) calculateStatus(allRSs []*extensions.ReplicaSet,
err
=
fmt
.
Errorf
(
"failed to count available pods: %v"
,
err
)
err
=
fmt
.
Errorf
(
"failed to count available pods: %v"
,
err
)
return
return
}
}
totalReplicas
:=
deploymentutil
.
GetReplicaCountForReplicaSets
(
allRSs
)
unavailableReplicas
=
totalReplicas
-
availableReplicas
unavailableReplicas
=
totalReplicas
-
availableReplicas
return
return
}
}
...
...
pkg/util/deployment/deployment.go
View file @
062b9f86
...
@@ -377,7 +377,7 @@ func IsPodAvailable(pod *api.Pod, minReadySeconds int) bool {
...
@@ -377,7 +377,7 @@ func IsPodAvailable(pod *api.Pod, minReadySeconds int) bool {
}
}
func
GetPodsForReplicaSets
(
c
clientset
.
Interface
,
replicaSets
[]
*
extensions
.
ReplicaSet
)
([]
api
.
Pod
,
error
)
{
func
GetPodsForReplicaSets
(
c
clientset
.
Interface
,
replicaSets
[]
*
extensions
.
ReplicaSet
)
([]
api
.
Pod
,
error
)
{
allPods
:=
[
]
api
.
Pod
{}
allPods
:=
map
[
string
]
api
.
Pod
{}
for
_
,
rs
:=
range
replicaSets
{
for
_
,
rs
:=
range
replicaSets
{
selector
,
err
:=
unversioned
.
LabelSelectorAsSelector
(
rs
.
Spec
.
Selector
)
selector
,
err
:=
unversioned
.
LabelSelectorAsSelector
(
rs
.
Spec
.
Selector
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -386,11 +386,17 @@ func GetPodsForReplicaSets(c clientset.Interface, replicaSets []*extensions.Repl
...
@@ -386,11 +386,17 @@ func GetPodsForReplicaSets(c clientset.Interface, replicaSets []*extensions.Repl
options
:=
api
.
ListOptions
{
LabelSelector
:
selector
}
options
:=
api
.
ListOptions
{
LabelSelector
:
selector
}
podList
,
err
:=
c
.
Core
()
.
Pods
(
rs
.
ObjectMeta
.
Namespace
)
.
List
(
options
)
podList
,
err
:=
c
.
Core
()
.
Pods
(
rs
.
ObjectMeta
.
Namespace
)
.
List
(
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
allPods
,
fmt
.
Errorf
(
"error listing pods: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"error listing pods: %v"
,
err
)
}
}
allPods
=
append
(
allPods
,
podList
.
Items
...
)
for
_
,
pod
:=
range
podList
.
Items
{
allPods
[
pod
.
Name
]
=
pod
}
}
requiredPods
:=
[]
api
.
Pod
{}
for
_
,
pod
:=
range
allPods
{
requiredPods
=
append
(
requiredPods
,
pod
)
}
}
return
all
Pods
,
nil
return
required
Pods
,
nil
}
}
// Revision returns the revision number of the input replica set
// Revision returns the revision number of the input replica set
...
...
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