Optimized List objects v2 for metadata (#1175)

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2021-11-01 18:34:20 -07:00
committed by GitHub
parent dfd0d084d9
commit 2f917134e6
5 changed files with 28 additions and 35 deletions

View File

@@ -14,7 +14,7 @@
// 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/>.
import React, { useEffect, useState, Fragment } from "react";
import React, { Fragment, useEffect, useState } from "react";
import Grid from "@mui/material/Grid";
import {
Button,
@@ -74,6 +74,9 @@ const styles = (theme: Theme) =>
},
error: {
color: "#b53b4b",
border: "1px solid #b53b4b",
padding: 8,
borderRadius: 3,
},
...modalBasic,
});
@@ -298,10 +301,18 @@ const AddBucket = ({
<br />
{!distributedSetup && (
<Fragment>
<small className={classes.error}>
Some these features are disabled as server is running in
non-erasure coded mode.
</small>
<div className={classes.error}>
These features are unavailable in a single-disk setup.
<br />
Please deploy a server in{" "}
<a
href="https://docs.min.io/minio/baremetal/installation/deploy-minio-distributed.html?ref=con"
target="_blank"
>
Distributed Mode
</a>{" "}
to use these features.
</div>
<br />
<br />
</Fragment>

View File

@@ -254,7 +254,7 @@ const ObjectDetails = ({
const [versions, setVersions] = useState<IFileInfo[]>([]);
const [filterVersion, setFilterVersion] = useState<string>("");
const [deleteOpen, setDeleteOpen] = useState<boolean>(false);
const [metadataLoad, setMetadataLoad] = useState<boolean>(false);
const [metadataLoad, setMetadataLoad] = useState<boolean>(true);
const [metadata, setMetadata] = useState<any>({});
const [selectedTab, setSelectedTab] = useState<number>(0);
@@ -292,7 +292,6 @@ const ObjectDetails = ({
}
setLoadObjectData(false);
setMetadataLoad(true);
})
.catch((error: ErrorResponseHandler) => {
setErrorSnackMessage(error);

View File

@@ -96,9 +96,6 @@ func setBucketQuota(ctx context.Context, ac *AdminClient, bucket *string, bucket
}
func getBucketQuotaResponse(session *models.Principal, params user_api.GetBucketQuotaParams) (*models.BucketQuota, *models.Error) {
if !isErasureBackend() {
return &models.BucketQuota{}, nil
}
mAdmin, err := NewMinioAdminClient(session)
if err != nil {

View File

@@ -22,10 +22,8 @@ import (
"encoding/json"
"fmt"
"strings"
"sync"
"time"
"github.com/minio/madmin-go"
"github.com/minio/mc/cmd"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio-go/v7"
@@ -202,10 +200,6 @@ func setBucketVersioningResponse(session *models.Principal, bucketName string, p
}
func getBucketReplicationResponse(session *models.Principal, bucketName string) (*models.BucketReplicationResponse, error) {
if !isErasureBackend() {
return &models.BucketReplicationResponse{}, nil
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
defer cancel()
@@ -256,12 +250,6 @@ func getBucketReplicationResponse(session *models.Principal, bucketName string)
}
func getBucketVersionedResponse(session *models.Principal, bucketName string) (*models.BucketVersioningResponse, error) {
if !isErasureBackend() {
return &models.BucketVersioningResponse{
IsVersioned: false,
}, nil
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
defer cancel()
@@ -288,13 +276,6 @@ func getBucketVersionedResponse(session *models.Principal, bucketName string) (*
return bucketVResponse, nil
}
var serverBackendType madmin.BackendType
var serverBackendOnce sync.Once
func isErasureBackend() bool {
return serverBackendType == madmin.Erasure
}
// getAccountInfo fetches a list of all buckets allowed to that particular client from MinIO Servers
func getAccountInfo(ctx context.Context, client MinioAdmin) ([]*models.Bucket, error) {
info, err := client.AccountInfo(ctx)
@@ -302,10 +283,6 @@ func getAccountInfo(ctx context.Context, client MinioAdmin) ([]*models.Bucket, e
return []*models.Bucket{}, err
}
serverBackendOnce.Do(func() {
serverBackendType = info.Server.Type
})
var bucketInfos []*models.Bucket
for _, bucket := range info.Buckets {

View File

@@ -197,7 +197,7 @@ func getListObjectsResponse(session *models.Principal, params user_api.ListObjec
if params.Recursive != nil {
recursive = *params.Recursive
}
if isErasureBackend() && params.WithVersions != nil {
if params.WithVersions != nil {
withVersions = *params.WithVersions
}
if params.WithMetadata != nil {
@@ -230,7 +230,16 @@ func getListObjectsResponse(session *models.Principal, params user_api.ListObjec
// listBucketObjects gets an array of objects in a bucket
func listBucketObjects(ctx context.Context, client MinioClient, bucketName string, prefix string, recursive, withVersions bool, withMetadata bool) ([]*models.BucketObject, error) {
var objects []*models.BucketObject
for lsObj := range client.listObjects(ctx, bucketName, minio.ListObjectsOptions{Prefix: prefix, Recursive: recursive, WithVersions: withVersions, WithMetadata: withMetadata}) {
opts := minio.ListObjectsOptions{
Prefix: prefix,
Recursive: recursive,
WithVersions: withVersions,
WithMetadata: withMetadata,
}
if withMetadata {
opts.MaxKeys = 1
}
for lsObj := range client.listObjects(ctx, bucketName, opts) {
if lsObj.Err != nil {
return nil, lsObj.Err
}