List Tenant Total Size (#211)

This commit is contained in:
Daniel Valdivia
2020-07-27 18:03:47 -07:00
committed by GitHub
parent 7bf25c897c
commit 1201dcf546
4 changed files with 15 additions and 8 deletions

View File

@@ -47,12 +47,12 @@ type TenantList struct {
// namespace
Namespace string `json:"namespace,omitempty"`
// total size
TotalSize int64 `json:"total_size,omitempty"`
// volume count
VolumeCount int64 `json:"volume_count,omitempty"`
// volume size
VolumeSize int64 `json:"volume_size,omitempty"`
// zone count
ZoneCount int64 `json:"zone_count,omitempty"`
}

View File

@@ -269,6 +269,8 @@ func listTenants(ctx context.Context, operatorClient OperatorClient, namespace s
var tenants []*models.TenantList
var totalSize int64
for _, minInst := range minTenants.Items {
var instanceCount int64
@@ -276,6 +278,10 @@ func listTenants(ctx context.Context, operatorClient OperatorClient, namespace s
for _, zone := range minInst.Spec.Zones {
instanceCount = instanceCount + int64(zone.Servers)
volumeCount = volumeCount + int64(zone.Servers*zone.VolumesPerServer)
if zone.VolumeClaimTemplate != nil {
zoneSize := int64(zone.VolumesPerServer) * int64(zone.Servers) * zone.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value()
totalSize = totalSize + zoneSize
}
}
tenants = append(tenants, &models.TenantList{
@@ -286,6 +292,7 @@ func listTenants(ctx context.Context, operatorClient OperatorClient, namespace s
VolumeCount: volumeCount,
CurrentState: minInst.Status.CurrentState,
Namespace: minInst.ObjectMeta.Namespace,
TotalSize: totalSize,
})
}

View File

@@ -2631,10 +2631,10 @@ func init() {
"namespace": {
"type": "string"
},
"volume_count": {
"total_size": {
"type": "integer"
},
"volume_size": {
"volume_count": {
"type": "integer"
},
"zone_count": {
@@ -5390,10 +5390,10 @@ func init() {
"namespace": {
"type": "string"
},
"volume_count": {
"total_size": {
"type": "integer"
},
"volume_size": {
"volume_count": {
"type": "integer"
},
"zone_count": {

View File

@@ -1746,7 +1746,7 @@ definitions:
type: integer
instance_count:
type: integer
volume_size:
total_size:
type: integer
volume_count:
type: integer