Skip to content

Commit

Permalink
remove TODO:parallize health check
Browse files Browse the repository at this point in the history
  • Loading branch information
mqliang committed Dec 2, 2015
1 parent 3cc588b commit 70cce28
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkg/registry/componentstatus/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/apiserver"
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/runtime"
"sync"
)

type REST struct {
Expand Down Expand Up @@ -53,11 +54,22 @@ func (rs *REST) NewList() runtime.Object {
func (rs *REST) List(ctx api.Context, options *unversioned.ListOptions) (runtime.Object, error) {
servers := rs.GetServersToValidate()

// TODO: This should be parallelized.
wait := sync.WaitGroup{}
wait.Add(len(servers))
statuses := make(chan api.ComponentStatus, len(servers))
for k, v := range servers {
go func(name string, server apiserver.Server) {
defer wait.Done()
status := rs.getComponentStatus(name, server)
statuses <- *status
}(k, v)
}
wait.Wait()
close(statuses)

reply := []api.ComponentStatus{}
for name, server := range servers {
status := rs.getComponentStatus(name, server)
reply = append(reply, *status)
for status := range statuses {
reply = append(reply, status)
}
return &api.ComponentStatusList{Items: reply}, nil
}
Expand Down

0 comments on commit 70cce28

Please sign in to comment.