fix link to volume server; display volume space usage

This commit is contained in:
chrislu
2025-07-04 13:52:28 -07:00
parent e85fbd29a1
commit d8da465cd3
10 changed files with 330 additions and 178 deletions

View File

@@ -83,11 +83,12 @@ type VolumeWithTopology struct {
}
type ClusterVolumesData struct {
Username string `json:"username"`
Volumes []VolumeWithTopology `json:"volumes"`
TotalVolumes int `json:"total_volumes"`
TotalSize int64 `json:"total_size"`
LastUpdated time.Time `json:"last_updated"`
Username string `json:"username"`
Volumes []VolumeWithTopology `json:"volumes"`
TotalVolumes int `json:"total_volumes"`
TotalSize int64 `json:"total_size"`
VolumeSizeLimit uint64 `json:"volume_size_limit"`
LastUpdated time.Time `json:"last_updated"`
// Pagination
CurrentPage int `json:"current_page"`

View File

@@ -119,6 +119,21 @@ func (s *AdminServer) GetClusterVolumes(page int, pageSize int, sortBy string, s
// Sort volumes
s.sortVolumes(volumes, sortBy, sortOrder)
// Get volume size limit from master
var volumeSizeLimit uint64
err = s.WithMasterClient(func(client master_pb.SeaweedClient) error {
resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
if err != nil {
return err
}
volumeSizeLimit = uint64(resp.VolumeSizeLimitMB) * 1024 * 1024 // Convert MB to bytes
return nil
})
if err != nil {
// If we can't get the limit, set a default
volumeSizeLimit = 30 * 1024 * 1024 * 1024 // 30GB default
}
// Calculate pagination
totalVolumes := len(volumes)
totalPages := (totalVolumes + pageSize - 1) / pageSize
@@ -195,6 +210,7 @@ func (s *AdminServer) GetClusterVolumes(page int, pageSize int, sortBy string, s
Volumes: volumes,
TotalVolumes: totalVolumes,
TotalSize: totalSize,
VolumeSizeLimit: volumeSizeLimit,
LastUpdated: time.Now(),
CurrentPage: page,
TotalPages: totalPages,