Sync replication count with the api server on pod creation/deletion.

This commit is contained in:
Prashanth Balasubramanian
2015-02-13 11:57:27 -08:00
parent 1231e65829
commit 28d9260c0b
5 changed files with 149 additions and 129 deletions

View File

@@ -196,7 +196,8 @@ func (rm *ReplicationManager) syncReplicationController(controller api.Replicati
return err
}
filteredList := FilterActivePods(podList.Items)
diff := len(filteredList) - controller.Spec.Replicas
activePods := len(filteredList)
diff := activePods - controller.Spec.Replicas
if diff < 0 {
diff *= -1
wait := sync.WaitGroup{}
@@ -221,6 +222,13 @@ func (rm *ReplicationManager) syncReplicationController(controller api.Replicati
}
wait.Wait()
}
if controller.Status.Replicas != activePods {
controller.Status.Replicas = activePods
_, err = rm.kubeClient.ReplicationControllers(controller.Namespace).Update(&controller)
if err != nil {
return err
}
}
return nil
}