Add current state to replica controller.
This commit is contained in:
@@ -92,7 +92,7 @@ func (rs *REST) Get(id string) (runtime.Object, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rs.fillCurrentState(&controller)
|
||||
rs.fillCurrentState(controller)
|
||||
return controller, err
|
||||
}
|
||||
|
||||
@@ -149,7 +149,11 @@ func (rs *REST) Watch(label, field labels.Selector, resourceVersion uint64) (wat
|
||||
}
|
||||
return watch.Filter(incoming, func(e watch.Event) (watch.Event, bool) {
|
||||
repController := e.Object.(*api.ReplicationController)
|
||||
return e, label.Matches(labels.Set(repController.Labels))
|
||||
match := label.Matches(labels.Set(repController.Labels))
|
||||
if match {
|
||||
rs.fillCurrentState(repController)
|
||||
}
|
||||
return e, match
|
||||
}), nil
|
||||
}
|
||||
|
||||
@@ -168,9 +172,13 @@ func (rs *REST) waitForController(ctrl *api.ReplicationController) (runtime.Obje
|
||||
}
|
||||
|
||||
func (rs *REST) fillCurrentState(ctrl *api.ReplicationController) error {
|
||||
list, err := rs.podLister.ListPods(ctrl.DesiredState.ReplicaSelector)
|
||||
if rs.podLister == nil {
|
||||
return nil
|
||||
}
|
||||
list, err := rs.podLister.ListPods(labels.Set(ctrl.DesiredState.ReplicaSelector).AsSelector())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctrl.CurrentState.Replicas = len(list.Items)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user