Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions models/tier_azure.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions models/tier_gcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions models/tier_s3.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,36 @@ const ListTiersConfiguration = ({
return "";
};

const renderTierUsage = (item: ITierElement) => {
const endpoint = get(item, `${item.type}.usage`, "");

if (endpoint !== null) {
return endpoint;
}

return "";
};

const renderTierObjects = (item: ITierElement) => {
const endpoint = get(item, `${item.type}.objects`, "");

if (endpoint !== null) {
return endpoint;
}

return "";
};

const renderTierVersions = (item: ITierElement) => {
const endpoint = get(item, `${item.type}.versions`, "");

if (endpoint !== null) {
return endpoint;
}

return "";
};

const closeTierCredentials = () => {
setUpdateCredentialsOpen(false);
};
Expand Down Expand Up @@ -330,6 +360,24 @@ const ListTiersConfiguration = ({
renderFunction: renderTierRegion,
renderFullObject: true,
},
{
label: "Usage",
elementKey: "type",
renderFunction: renderTierUsage,
renderFullObject: true,
},
{
label: "Objects",
elementKey: "type",
renderFunction: renderTierObjects,
renderFullObject: true,
},
{
label: "Versions",
elementKey: "type",
renderFunction: renderTierVersions,
renderFullObject: true,
},
]}
isLoading={isLoading}
records={filteredRecords}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export interface ITierS3 {
prefix: string;
region: string;
storageclass: string;
usage: string;
objects: string;
versions: string;
}

export interface ITierGCS {
Expand All @@ -33,6 +36,9 @@ export interface ITierGCS {
prefix: string;
region: string;
storageclass: string;
usage: string;
objects: string;
versions: string;
}

export interface ITierAzure {
Expand All @@ -44,6 +50,9 @@ export interface ITierAzure {
prefix: string;
region: string;
storageclass: string;
usage: string;
objects: string;
versions: string;
}

export interface ITierElement {
Expand Down
17 changes: 15 additions & 2 deletions restapi/admin_tiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ package restapi
import (
"context"
"encoding/base64"
"strconv"
"time"

"github.com/dustin/go-humanize"
"github.com/minio/madmin-go"

"github.com/go-openapi/runtime/middleware"
Expand Down Expand Up @@ -71,10 +73,12 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
if err != nil {
return nil, err
}

tierInfo, err := client.tierStats(ctx)
if err != nil {
return nil, err
}
var tiersList []*models.Tier
for i := range tiers {

switch tiers[i].Type {
case madmin.S3:
tiersList = append(tiersList, &models.Tier{
Expand All @@ -88,6 +92,9 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
Region: tiers[i].S3.Region,
Secretkey: tiers[i].S3.SecretKey,
Storageclass: tiers[i].S3.StorageClass,
Usage: humanize.IBytes(tierInfo[i+1].Stats.TotalSize),
Objects: strconv.Itoa(tierInfo[i+1].Stats.NumObjects),
Versions: strconv.Itoa(tierInfo[i+1].Stats.NumVersions),
},
})
case madmin.GCS:
Expand All @@ -100,6 +107,9 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
Name: tiers[i].Name,
Prefix: tiers[i].GCS.Prefix,
Region: tiers[i].GCS.Region,
Usage: humanize.IBytes(tierInfo[i+1].Stats.TotalSize),
Objects: strconv.Itoa(tierInfo[i+1].Stats.NumObjects),
Versions: strconv.Itoa(tierInfo[i+1].Stats.NumVersions),
},
})
case madmin.Azure:
Expand All @@ -113,6 +123,9 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
Name: tiers[i].Name,
Prefix: tiers[i].Azure.Prefix,
Region: tiers[i].Azure.Region,
Usage: humanize.IBytes(tierInfo[i+1].Stats.TotalSize),
Objects: strconv.Itoa(tierInfo[i+1].Stats.NumObjects),
Versions: strconv.Itoa(tierInfo[i+1].Stats.NumVersions),
},
})
case madmin.Unsupported:
Expand Down
28 changes: 28 additions & 0 deletions restapi/admin_tiers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ func (ac adminClientMock) listTiers(ctx context.Context) ([]*madmin.TierConfig,
return minioListTiersMock(ctx)
}

// assigning mock at runtime instead of compile time
var minioTierStatsMock func(ctx context.Context) ([]madmin.TierInfo, error)

// mock function of tierStats()
func (ac adminClientMock) tierStats(ctx context.Context) ([]madmin.TierInfo, error) {
return minioTierStatsMock(ctx)
}

// assigning mock at runtime instead of compile time
var minioAddTiersMock func(ctx context.Context, tier *madmin.TierConfig) error

Expand Down Expand Up @@ -79,6 +87,19 @@ func TestGetTiers(t *testing.T) {
},
}

returnStatsMock := []madmin.TierInfo{
{
Name: "STANDARD",
Type: "internal",
Stats: madmin.TierStats{NumObjects: 2, NumVersions: 2, TotalSize: 228915},
},
{
Name: "S3 Tier",
Type: "s3",
Stats: madmin.TierStats{NumObjects: 0, NumVersions: 0, TotalSize: 0},
},
}

expectedOutput := &models.TierListResponse{
Items: []*models.Tier{
{
Expand All @@ -92,6 +113,9 @@ func TestGetTiers(t *testing.T) {
Prefix: "pref1",
Region: "us-west-1",
Storageclass: "TT1",
Usage: "0 B",
Objects: "0",
Versions: "0",
},
},
},
Expand All @@ -101,6 +125,10 @@ func TestGetTiers(t *testing.T) {
return returnListMock, nil
}

minioTierStatsMock = func(ctx context.Context) ([]madmin.TierInfo, error) {
return returnStatsMock, nil
}

tiersList, err := getTiers(ctx, adminClient)

if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions restapi/client-admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ type MinioAdmin interface {
serverHealthInfo(ctx context.Context, healthDataTypes []madmin.HealthDataType, deadline time.Duration) (interface{}, string, error)
// List Tiers
listTiers(ctx context.Context) ([]*madmin.TierConfig, error)
// Tier Info
tierStats(ctx context.Context) ([]madmin.TierInfo, error)
// Add Tier
addTier(ctx context.Context, tier *madmin.TierConfig) error
// Edit Tier Credentials
Expand Down Expand Up @@ -412,6 +414,11 @@ func (ac AdminClient) listTiers(ctx context.Context) ([]*madmin.TierConfig, erro
return ac.Client.ListTiers(ctx)
}

// implements madmin.tierStats()
func (ac AdminClient) tierStats(ctx context.Context) ([]madmin.TierInfo, error) {
return ac.Client.TierStats(ctx)
}

// implements madmin.AddTier()
func (ac AdminClient) addTier(ctx context.Context, cfg *madmin.TierConfig) error {
return ac.Client.AddTier(ctx, cfg)
Expand Down
Loading