Add erasure info support (#2446)

Make it easier for user to see backend properties like backend-type,
Standard storage class Parity and Reduced Redundancy storage class
Parity
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
This commit is contained in:
dilverse
2022-11-10 22:54:39 +05:30
committed by GitHub
parent 86361b630e
commit 7b389fc323
7 changed files with 270 additions and 34 deletions

View File

@@ -42,6 +42,9 @@ type AdminInfoResponse struct {
// Enum: [not configured available unavailable]
AdvancedMetricsStatus string `json:"advancedMetricsStatus,omitempty"`
// backend
Backend *BackendProperties `json:"backend,omitempty"`
// buckets
Buckets int64 `json:"buckets,omitempty"`
@@ -66,6 +69,10 @@ func (m *AdminInfoResponse) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateBackend(formats); err != nil {
res = append(res, err)
}
if err := m.validateServers(formats); err != nil {
res = append(res, err)
}
@@ -125,6 +132,25 @@ func (m *AdminInfoResponse) validateAdvancedMetricsStatus(formats strfmt.Registr
return nil
}
func (m *AdminInfoResponse) validateBackend(formats strfmt.Registry) error {
if swag.IsZero(m.Backend) { // not required
return nil
}
if m.Backend != nil {
if err := m.Backend.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("backend")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("backend")
}
return err
}
}
return nil
}
func (m *AdminInfoResponse) validateServers(formats strfmt.Registry) error {
if swag.IsZero(m.Servers) { // not required
return nil
@@ -181,6 +207,10 @@ func (m *AdminInfoResponse) validateWidgets(formats strfmt.Registry) error {
func (m *AdminInfoResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateBackend(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateServers(ctx, formats); err != nil {
res = append(res, err)
}
@@ -195,6 +225,22 @@ func (m *AdminInfoResponse) ContextValidate(ctx context.Context, formats strfmt.
return nil
}
func (m *AdminInfoResponse) contextValidateBackend(ctx context.Context, formats strfmt.Registry) error {
if m.Backend != nil {
if err := m.Backend.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("backend")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("backend")
}
return err
}
}
return nil
}
func (m *AdminInfoResponse) contextValidateServers(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Servers); i++ {

View File

@@ -0,0 +1,73 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// BackendProperties backend properties
//
// swagger:model BackendProperties
type BackendProperties struct {
// backend type
BackendType string `json:"backendType,omitempty"`
// rr s c parity
RrSCParity int64 `json:"rrSCParity,omitempty"`
// standard s c parity
StandardSCParity int64 `json:"standardSCParity,omitempty"`
}
// Validate validates this backend properties
func (m *BackendProperties) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this backend properties based on context it is used
func (m *BackendProperties) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *BackendProperties) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *BackendProperties) UnmarshalBinary(b []byte) error {
var res BackendProperties
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import React from "react";
import { Box } from "@mui/material";
import { Box, Grid } from "@mui/material";
import {
ArrowRightIcon,
BucketsIcon,
@@ -25,6 +25,8 @@ import {
ServersIcon,
TotalObjectsIcon,
UptimeIcon,
FormatDrivesIcon,
StorageIcon,
} from "../../../../icons";
import HelpBox from "../../../../common/HelpBox";
import { calculateBytes, representationNumber } from "../../../../common/utils";
@@ -276,6 +278,41 @@ const BasicDashboard = ({ usage }: IDashboardProps) => {
</Box>
</Box>
</Box>
<Grid container spacing={1}>
<Grid item xs={4}>
<TimeStatItem
icon={<StorageIcon />}
label={"Backend type"}
value={
usage?.backend?.backendType
? usage.backend.backendType
: "Unknown"
}
/>
</Grid>
<Grid item xs={4}>
<TimeStatItem
icon={<FormatDrivesIcon />}
label={"Standard storage class parity"}
value={
usage?.backend?.standardSCParity
? usage.backend.standardSCParity.toString()
: "n/a"
}
/>
</Grid>
<Grid item xs={4}>
<TimeStatItem
icon={<FormatDrivesIcon />}
label={"Reduced redundancy storage class parity"}
value={
usage?.backend?.standardSCParity
? usage.backend.rrSCParity.toString()
: "n/a"
}
/>
</Grid>
</Grid>
<Box
sx={{

View File

@@ -23,12 +23,19 @@ export interface Usage {
advancedMetricsStatus: "available" | "unavailable" | "not configured";
widgets?: any;
servers: ServerInfo[];
backend: Backend;
//TODO
lastScan: any;
lastHeal: any;
upTime: any;
}
export interface Backend {
backendType: string;
standardSCParity: number;
rrSCParity: number;
}
export interface ServerInfo {
state: string;
endpoint: string;

View File

@@ -61,6 +61,7 @@ type UsageInfo struct {
DisksUsage int64
Servers []*models.ServerProperties
EndpointNotReady bool
Backend *models.BackendProperties
}
// GetAdminInfo invokes admin info and returns a parsed `UsageInfo` structure
@@ -72,6 +73,25 @@ func GetAdminInfo(ctx context.Context, client MinioAdmin) (*UsageInfo, error) {
// we are trimming uint64 to int64 this will report an incorrect measurement for numbers greater than
// 9,223,372,036,854,775,807
var backendType string
var rrSCParity float64
var standardSCParity float64
if v, success := serverInfo.Backend.(map[string]interface{}); success {
bt, ok := v["backendType"]
if ok {
backendType = bt.(string)
}
rp, ok := v["rrSCParity"]
if ok {
rrSCParity = rp.(float64)
}
sp, ok := v["standardSCParity"]
if ok {
standardSCParity = sp.(float64)
}
}
var usedSpace int64
for _, serv := range serverInfo.Servers {
for _, disk := range serv.Disks {
@@ -113,12 +133,19 @@ func GetAdminInfo(ctx context.Context, client MinioAdmin) (*UsageInfo, error) {
serverArray = append(serverArray, newServer)
}
backendData := &models.BackendProperties{
BackendType: backendType,
RrSCParity: int64(rrSCParity),
StandardSCParity: int64(standardSCParity),
}
return &UsageInfo{
Buckets: int64(serverInfo.Buckets.Count),
Objects: int64(serverInfo.Objects.Count),
Usage: int64(serverInfo.Usage.Size),
DisksUsage: usedSpace,
Servers: serverArray,
Backend: backendData,
}, nil
}
@@ -913,6 +940,7 @@ func getUsageWidgetsForDeployment(ctx context.Context, prometheusURL string, mAd
sessionResp.Objects = usage.Objects
sessionResp.Usage = usage.Usage
sessionResp.Servers = usage.Servers
sessionResp.Backend = usage.Backend
}
}()

View File

@@ -4864,6 +4864,20 @@ func init() {
}
},
"definitions": {
"BackendProperties": {
"type": "object",
"properties": {
"backendType": {
"type": "string"
},
"rrSCParity": {
"type": "integer"
},
"standardSCParity": {
"type": "integer"
}
}
},
"SubnetRegTokenResponse": {
"type": "object",
"properties": {
@@ -5129,6 +5143,9 @@ func init() {
"unavailable"
]
},
"backend": {
"$ref": "#/definitions/BackendProperties"
},
"buckets": {
"type": "integer"
},
@@ -13002,6 +13019,20 @@ func init() {
}
},
"definitions": {
"BackendProperties": {
"type": "object",
"properties": {
"backendType": {
"type": "string"
},
"rrSCParity": {
"type": "integer"
},
"standardSCParity": {
"type": "integer"
}
}
},
"BucketDetails": {
"type": "object",
"properties": {
@@ -13393,6 +13424,9 @@ func init() {
"unavailable"
]
},
"backend": {
"$ref": "#/definitions/BackendProperties"
},
"buckets": {
"type": "integer"
},

View File

@@ -4248,6 +4248,8 @@ definitions:
type: array
items:
$ref: "#/definitions/serverProperties"
backend:
$ref: "#/definitions/BackendProperties"
serverProperties:
type: object
properties:
@@ -4294,6 +4296,15 @@ definitions:
type: integer
availableSpace:
type: integer
BackendProperties:
type: object
properties:
backendType:
type: string
rrSCParity:
type: integer
standardSCParity:
type: integer
arnsResponse:
type: object
properties:
@@ -5437,40 +5448,40 @@ definitions:
type: string
kmsDescribeIdentityResponse:
type: object
properties:
policy:
type: string
identity:
type: string
admin:
type: boolean
createdAt:
type: string
createdBy:
type: string
type: object
properties:
policy:
type: string
identity:
type: string
admin:
type: boolean
createdAt:
type: string
createdBy:
type: string
kmsDescribeSelfIdentityResponse:
type: object
properties:
identity:
type: string
policyName:
type: string
admin:
type: boolean
createdAt:
type: string
createdBy:
type: string
policy:
$ref: "#/definitions/kmsGetPolicyResponse"
type: object
properties:
identity:
type: string
policyName:
type: string
admin:
type: boolean
createdAt:
type: string
createdBy:
type: string
policy:
$ref: "#/definitions/kmsGetPolicyResponse"
kmsListIdentitiesResponse:
type: object
properties:
results:
type: array
items:
$ref: "#/definitions/kmsIdentityInfo"
type: object
properties:
results:
type: array
items:
$ref: "#/definitions/kmsIdentityInfo"
kmsIdentityInfo:
type: object
properties:
@@ -5514,7 +5525,7 @@ definitions:
errorEvents:
type: integer
latencyHistogram:
$ref: "#/definitions/kmsLatencyHistogram"
$ref: "#/definitions/kmsLatencyHistogram"
uptime:
type: integer
cpus: