blob: 7a648d1b25202135489a34d43d06fd0102b2d4a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package server
import (
"context"
"fmt"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
)
// DiskStatistics sends DiskStatisticsRequest to all of a praefect server's internal gitaly nodes and aggregates the
// results into a response
func (s *Server) DiskStatistics(ctx context.Context, _ *gitalypb.DiskStatisticsRequest) (*gitalypb.DiskStatisticsResponse, error) {
var storageStatuses [][]*gitalypb.DiskStatisticsResponse_StorageStatus
for _, storages := range s.conns {
for storage, conn := range storages {
client := gitalypb.NewServerServiceClient(conn)
resp, err := client.DiskStatistics(ctx, &gitalypb.DiskStatisticsRequest{})
if err != nil {
return nil, fmt.Errorf("error when requesting disk statistics from internal storage %v", storage)
}
storageStatuses = append(storageStatuses, resp.GetStorageStatuses())
}
}
var response gitalypb.DiskStatisticsResponse
for _, storageStatus := range storageStatuses {
response.StorageStatuses = append(response.StorageStatuses, storageStatus...)
}
return &response, nil
}
|