mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-11 14:11:14 +00:00
Insert the current state of a replica controller.
This commit is contained in:
@@ -92,6 +92,7 @@ func (rs *REST) Get(id string) (runtime.Object, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rs.fillCurrentState(&controller)
|
||||
return controller, err
|
||||
}
|
||||
|
||||
@@ -104,6 +105,7 @@ func (rs *REST) List(selector labels.Selector) (runtime.Object, error) {
|
||||
filtered := []api.ReplicationController{}
|
||||
for _, controller := range controllers.Items {
|
||||
if selector.Matches(labels.Set(controller.Labels)) {
|
||||
rs.fillCurrentState(&controller)
|
||||
filtered = append(filtered, controller)
|
||||
}
|
||||
}
|
||||
@@ -164,3 +166,11 @@ func (rs *REST) waitForController(ctrl *api.ReplicationController) (runtime.Obje
|
||||
}
|
||||
return ctrl, nil
|
||||
}
|
||||
|
||||
func (rs *REST) fillCurrentState(ctrl *api.ReplicationController) error {
|
||||
list, err := rs.podLister.ListPods(ctrl.DesiredState.ReplicaSelector)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctrl.CurrentState.Replicas = len(list.Items)
|
||||
}
|
||||
|
Reference in New Issue
Block a user