Skip to content

Commit

Permalink
Merge pull request kubernetes#21713 from janetkuo/deployment-actual-r…
Browse files Browse the repository at this point in the history
…eplicas

Report actual replicas in deployment status
  • Loading branch information
bgrant0607 committed Feb 24, 2016
2 parents b5c6341 + 3901423 commit 832bc37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/deployment/deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,8 @@ func (dc *DeploymentController) updateDeploymentStatus(allRSs []*extensions.Repl
}

func (dc *DeploymentController) calculateStatus(allRSs []*extensions.ReplicaSet, newRS *extensions.ReplicaSet, deployment extensions.Deployment) (totalReplicas, updatedReplicas, availableReplicas, unavailableReplicas int, err error) {
totalReplicas = deploymentutil.GetReplicaCountForReplicaSets(allRSs)
updatedReplicas = deploymentutil.GetReplicaCountForReplicaSets([]*extensions.ReplicaSet{newRS})
totalReplicas = deploymentutil.GetActualReplicaCountForReplicaSets(allRSs)
updatedReplicas = deploymentutil.GetActualReplicaCountForReplicaSets([]*extensions.ReplicaSet{newRS})
minReadySeconds := deployment.Spec.MinReadySeconds
availableReplicas, err = deploymentutil.GetAvailablePodsForReplicaSets(dc.client, allRSs, minReadySeconds)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions pkg/util/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ func GetReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int {
return totalReplicaCount
}

// GetActualReplicaCountForReplicaSets returns the sum of actual replicas of the given replica sets.
func GetActualReplicaCountForReplicaSets(replicaSets []*extensions.ReplicaSet) int {
totalReplicaCount := 0
for _, rs := range replicaSets {
totalReplicaCount += rs.Status.Replicas
}
return totalReplicaCount
}

// Returns the number of available pods corresponding to the given replica sets.
func GetAvailablePodsForReplicaSets(c clientset.Interface, rss []*extensions.ReplicaSet, minReadySeconds int) (int, error) {
allPods, err := GetPodsForReplicaSets(c, rss)
Expand Down

0 comments on commit 832bc37

Please sign in to comment.