mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	api: add readyReplicas in RC/RS
This commit is contained in:
		@@ -27,12 +27,13 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// updateReplicaCount attempts to update the Status.Replicas of the given controller, with a single GET/PUT retry.
 | 
			
		||||
func updateReplicaCount(rcClient unversionedcore.ReplicationControllerInterface, controller api.ReplicationController, numReplicas, numFullyLabeledReplicas int) (updateErr error) {
 | 
			
		||||
func updateReplicaCount(rcClient unversionedcore.ReplicationControllerInterface, controller api.ReplicationController, numReplicas, numFullyLabeledReplicas, numReadyReplicas int) (updateErr error) {
 | 
			
		||||
	// This is the steady state. It happens when the rc doesn't have any expectations, since
 | 
			
		||||
	// we do a periodic relist every 30s. If the generations differ but the replicas are
 | 
			
		||||
	// the same, a caller might've resized to the same replica count.
 | 
			
		||||
	if int(controller.Status.Replicas) == numReplicas &&
 | 
			
		||||
		int(controller.Status.FullyLabeledReplicas) == numFullyLabeledReplicas &&
 | 
			
		||||
		int(controller.Status.ReadyReplicas) == numReadyReplicas &&
 | 
			
		||||
		controller.Generation == controller.Status.ObservedGeneration {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
@@ -47,9 +48,15 @@ func updateReplicaCount(rcClient unversionedcore.ReplicationControllerInterface,
 | 
			
		||||
		glog.V(4).Infof(fmt.Sprintf("Updating replica count for rc: %s/%s, ", controller.Namespace, controller.Name) +
 | 
			
		||||
			fmt.Sprintf("replicas %d->%d (need %d), ", controller.Status.Replicas, numReplicas, controller.Spec.Replicas) +
 | 
			
		||||
			fmt.Sprintf("fullyLabeledReplicas %d->%d, ", controller.Status.FullyLabeledReplicas, numFullyLabeledReplicas) +
 | 
			
		||||
			fmt.Sprintf("readyReplicas %d->%d, ", controller.Status.ReadyReplicas, numReadyReplicas) +
 | 
			
		||||
			fmt.Sprintf("sequence No: %v->%v", controller.Status.ObservedGeneration, generation))
 | 
			
		||||
 | 
			
		||||
		rc.Status = api.ReplicationControllerStatus{Replicas: int32(numReplicas), FullyLabeledReplicas: int32(numFullyLabeledReplicas), ObservedGeneration: generation}
 | 
			
		||||
		rc.Status = api.ReplicationControllerStatus{
 | 
			
		||||
			Replicas:             int32(numReplicas),
 | 
			
		||||
			FullyLabeledReplicas: int32(numFullyLabeledReplicas),
 | 
			
		||||
			ReadyReplicas:        int32(numReadyReplicas),
 | 
			
		||||
			ObservedGeneration:   generation,
 | 
			
		||||
		}
 | 
			
		||||
		_, updateErr = rcClient.UpdateStatus(rc)
 | 
			
		||||
		if updateErr == nil || i >= statusUpdateRetries {
 | 
			
		||||
			return updateErr
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user