Skip to content

Commit 2f708dd

Browse files
authored
Merge branch 'master' into inspect-v2-format
2 parents 048a212 + 83a6129 commit 2f708dd

File tree

6 files changed

+44
-45
lines changed

6 files changed

+44
-45
lines changed

models/tier.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/src/common/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export const erasureCodeCalc = (
471471

472472
const fourVar = parityValidValues.find((element) => element === "EC:4");
473473

474-
if (totalDisks >= 8 && totalNodes > 16 && fourVar) {
474+
if (fourVar) {
475475
defaultEC = "EC:4";
476476
}
477477

portal-ui/src/screens/Console/Configurations/TiersConfiguration/ListTiersConfiguration.tsx

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ const ListTiersConfiguration = ({ classes }: IListTiersConfig) => {
106106
const [records, setRecords] = useState<ITierElement[]>([]);
107107
const [filter, setFilter] = useState<string>("");
108108
const [isLoading, setIsLoading] = useState<boolean>(true);
109-
const [checkTierStatus, setcheckTierStatus] = useState<boolean>(false);
110109
const [updateCredentialsOpen, setUpdateCredentialsOpen] =
111110
useState<boolean>(false);
112111
const [selectedTier, setSelectedTier] = useState<ITierElement>({
@@ -117,46 +116,6 @@ const ListTiersConfiguration = ({ classes }: IListTiersConfig) => {
117116
IAM_SCOPES.ADMIN_SET_TIER,
118117
]);
119118

120-
useEffect(() => {
121-
if (checkTierStatus) {
122-
records.forEach((tier: ITierElement) => {
123-
var endpoint: string;
124-
switch (tier.type) {
125-
case "minio":
126-
endpoint = tier.minio?.endpoint + "/" + tier.minio?.bucket || "";
127-
break;
128-
case "s3":
129-
endpoint = tier.s3?.endpoint + "/" + tier.s3?.bucket || "";
130-
break;
131-
case "gcs":
132-
endpoint = tier.gcs?.endpoint + "/" + tier.gcs?.bucket || "";
133-
break;
134-
case "azure":
135-
endpoint = tier.azure?.endpoint + "/" + tier.azure?.bucket || "";
136-
break;
137-
default:
138-
endpoint = "";
139-
}
140-
const xhr = new XMLHttpRequest();
141-
xhr.open("HEAD", endpoint);
142-
xhr.send();
143-
xhr.onreadystatechange = () => {
144-
if (xhr.readyState === 4 || xhr.readyState === 2) {
145-
tier.status = true;
146-
} else {
147-
tier.status = false;
148-
}
149-
};
150-
xhr.onerror = () => {
151-
tier.status = false;
152-
};
153-
});
154-
setRecords(records);
155-
setcheckTierStatus(false);
156-
}
157-
// eslint-disable-next-line react-hooks/exhaustive-deps
158-
}, [checkTierStatus]);
159-
160119
useEffect(() => {
161120
if (isLoading) {
162121
if (distributedSetup) {
@@ -166,7 +125,6 @@ const ListTiersConfiguration = ({ classes }: IListTiersConfig) => {
166125
.then((res: ITierResponse) => {
167126
setRecords(res.items || []);
168127
setIsLoading(false);
169-
setcheckTierStatus(true);
170128
})
171129
.catch((err: ErrorResponseHandler) => {
172130
dispatch(setErrorSnackMessage(err));

restapi/admin_tiers.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ package restapi
1919
import (
2020
"context"
2121
"encoding/base64"
22+
"log"
23+
"regexp"
2224
"strconv"
25+
"strings"
2326

2427
"github.com/dustin/go-humanize"
2528
"github.com/go-openapi/runtime/middleware"
2629
"github.com/minio/console/models"
2730
"github.com/minio/console/restapi/operations"
2831
tieringApi "github.com/minio/console/restapi/operations/tiering"
2932
"github.com/minio/madmin-go"
33+
34+
"github.com/minio/minio-go/v7"
35+
"github.com/minio/minio-go/v7/pkg/credentials"
3036
)
3137

3238
func registerAdminTiersHandlers(api *operations.ConsoleAPI) {
@@ -109,6 +115,7 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
109115
Objects: strconv.Itoa(stats.NumObjects),
110116
Versions: strconv.Itoa(stats.NumVersions),
111117
},
118+
Status: false,
112119
})
113120
case madmin.MinIO:
114121
tiersList = append(tiersList, &models.Tier{
@@ -125,6 +132,7 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
125132
Objects: strconv.Itoa(stats.NumObjects),
126133
Versions: strconv.Itoa(stats.NumVersions),
127134
},
135+
Status: checkTierStatus(tierData.MinIO.Endpoint, tierData.MinIO.AccessKey, tierData.MinIO.SecretKey, tierData.MinIO.Bucket),
128136
})
129137
case madmin.GCS:
130138
tiersList = append(tiersList, &models.Tier{
@@ -140,6 +148,7 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
140148
Objects: strconv.Itoa(stats.NumObjects),
141149
Versions: strconv.Itoa(stats.NumVersions),
142150
},
151+
Status: false,
143152
})
144153
case madmin.Azure:
145154
tiersList = append(tiersList, &models.Tier{
@@ -156,15 +165,16 @@ func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse,
156165
Objects: strconv.Itoa(stats.NumObjects),
157166
Versions: strconv.Itoa(stats.NumVersions),
158167
},
168+
Status: false,
159169
})
160170
case madmin.Unsupported:
161171
tiersList = append(tiersList, &models.Tier{
162-
Type: models.TierTypeUnsupported,
172+
Type: models.TierTypeUnsupported,
173+
Status: false,
163174
})
164175

165176
}
166177
}
167-
168178
// build response
169179
return &models.TierListResponse{
170180
Items: tiersList,
@@ -407,3 +417,23 @@ func getEditTierCredentialsResponse(session *models.Principal, params tieringApi
407417
}
408418
return nil
409419
}
420+
421+
func checkTierStatus(endpoint string, accessKey string, secretKey string, bucketName string) bool {
422+
// Initialize minio client object.
423+
re := regexp.MustCompile(`(^\w+:|^)\/\/`)
424+
s := re.ReplaceAllString(endpoint, "")
425+
minioClient, err := minio.New(s, &minio.Options{
426+
Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
427+
Secure: false,
428+
})
429+
if err != nil {
430+
log.Println(err)
431+
return false
432+
}
433+
bucketTest, err := minioClient.BucketExists(context.Background(), bucketName)
434+
if err != nil {
435+
log.Println(err)
436+
return strings.Contains(err.Error(), "The request signature we calculated does not match the signature you provided. Check your key and signing method.")
437+
}
438+
return bucketTest
439+
}

restapi/embedded_spec.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

swagger-console.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5119,6 +5119,8 @@ definitions:
51195119
tier:
51205120
type: object
51215121
properties:
5122+
status:
5123+
type: boolean
51225124
type:
51235125
type: string
51245126
enum:

0 commit comments

Comments
 (0)