Skip to content

Commit 1409569

Browse files
committed
Revert "Deprecated Site Replication in UI (minio#3469)"
This reverts commit 4e5dcf0.
1 parent e0e9c5f commit 1409569

File tree

53 files changed

+6438
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6438
-3
lines changed

.github/workflows/jobs.yaml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,88 @@ jobs:
902902
- name: Run tests
903903
working-directory: ./web-app
904904
run: yarn test --passWithNoTests
905+
replication:
906+
name: Site Replication Test
907+
needs:
908+
- lint-job
909+
- ui-assets
910+
- semgrep-static-code-analysis
911+
- latest-minio
912+
runs-on: [ubuntu-latest]
913+
914+
strategy:
915+
matrix:
916+
go-version: [1.24.x]
917+
918+
steps:
919+
- name: Check out code
920+
uses: actions/checkout@v3
921+
922+
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
923+
uses: actions/setup-go@v5
924+
with:
925+
go-version: ${{ matrix.go-version }}
926+
id: go
927+
928+
- name: Clone github.com/minio/minio
929+
uses: actions/checkout@master
930+
with:
931+
repository: minio/minio
932+
path: "minio_repository"
933+
- name: Check-out matching MinIO branch
934+
env:
935+
GH_BRANCH: ${{ github.head_ref || github.ref_name }}
936+
GH_PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
937+
run: |
938+
GH_PR_ACCOUNT=`echo $GH_PR_REPO | sed "s/\\/.*//"`
939+
if [ ! -z "$GH_PR_ACCOUNT" ] && [ ! "$GH_PR_ACCOUNT" = "minio" ]; then
940+
ALTREPO="https://github.com/$GH_PR_ACCOUNT/minio.git"
941+
echo "Attempting to fetch $ALTREPO..."
942+
git remote add alt $ALTREPO
943+
(git fetch alt && git checkout "alt/$GH_BRANCH") || echo "$ALTREPO ($GH_BRANCH) not available, so keeping default repository/branch"
944+
fi
945+
- uses: actions/cache@v4
946+
id: minio-latest-cache
947+
name: MinIO Latest Cache
948+
with:
949+
path: |
950+
./minio
951+
key: ${{ runner.os }}-minio-latest-${{ hashFiles('./minio_repository/go.sum') }}
905952

953+
- name: Build on ${{ matrix.os }}
954+
run: |
955+
echo "The idea is to build minio image from downloaded repository";
956+
cd $GITHUB_WORKSPACE/minio_repository;
957+
echo "Get git version to build MinIO Image";
958+
VERSION=`git rev-parse HEAD`;
959+
echo $VERSION;
960+
echo "Create MinIO image";
961+
make docker VERSION=$VERSION;
962+
963+
docker build -q --no-cache -t minio/minio:$VERSION . -f Dockerfile
964+
echo "Jumping back to console repository to run the integration test"
965+
cd $GITHUB_WORKSPACE;
966+
967+
echo "We are going to use the built image on test-integration";
968+
MINIO_VERSION="minio/minio:$VERSION";
969+
echo $MINIO_VERSION;
970+
971+
make test-replication MINIO_VERSION=$MINIO_VERSION;
972+
- uses: actions/cache@v4
973+
id: coverage-cache-replication
974+
name: Coverage Cache Replication
975+
with:
976+
path: |
977+
./replication/coverage/
978+
key: ${{ runner.os }}-replication-coverage-2-${{ github.run_id }}
979+
980+
# To save our replication.out file into an artifact.
981+
# By default, GitHub stores build logs and artifacts for 90 days.
982+
- uses: actions/upload-artifact@v4
983+
with:
984+
name: replication-artifact
985+
path: ./replication/coverage/replication.out
986+
if-no-files-found: error
906987
sso-integration:
907988
name: SSO Integration Test
908989
needs:
@@ -995,6 +1076,7 @@ jobs:
9951076
- test-api-on-go
9961077
- test-pkg-on-go
9971078
- sso-integration
1079+
- replication
9981080
runs-on: ${{ matrix.os }}
9991081
strategy:
10001082
matrix:
@@ -1030,6 +1112,14 @@ jobs:
10301112
./sso-integration/coverage/
10311113
key: ${{ runner.os }}-sso-coverage-2-${{ github.run_id }}
10321114

1115+
- uses: actions/cache@v4
1116+
id: coverage-cache-replication
1117+
name: Coverage Cache Replication
1118+
with:
1119+
path: |
1120+
./replication/coverage/
1121+
key: ${{ runner.os }}-replication-coverage-2-${{ github.run_id }}
1122+
10331123
- uses: actions/cache@v4
10341124
id: coverage-cache-api
10351125
name: Coverage Cache API
@@ -1046,6 +1136,12 @@ jobs:
10461136
./pkg/coverage/
10471137
key: ${{ runner.os }}-coverage-pkg-2-${{ github.run_id }}
10481138

1139+
# Get the replication.out file from the artifact since this is working for self host runner.
1140+
- uses: actions/download-artifact@v4
1141+
with:
1142+
name: replication-artifact
1143+
path: replication/coverage
1144+
10491145
- name: Get coverage
10501146
run: |
10511147
echo "change directory to gocovmerge"
@@ -1057,7 +1153,7 @@ jobs:
10571153
echo "go build gocoverage.go"
10581154
go build gocovmerge.go
10591155
echo "put together the outs for final coverage resolution"
1060-
./gocovmerge ../integration/coverage/system.out ../sso-integration/coverage/sso-system.out ../api/coverage/coverage.out ../pkg/coverage/coverage-pkg.out > all.out
1156+
./gocovmerge ../integration/coverage/system.out ../replication/coverage/replication.out ../sso-integration/coverage/sso-system.out ../api/coverage/coverage.out ../pkg/coverage/coverage-pkg.out > all.out
10611157
echo "grep to obtain the result"
10621158
go tool cover -func=all.out | grep total > tmp2
10631159
result=`cat tmp2 | awk 'END {print $3}'`

api/admin_replication_status.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2022 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
package api
18+
19+
import (
20+
"context"
21+
22+
"github.com/go-openapi/runtime/middleware"
23+
"github.com/minio/console/api/operations"
24+
siteRepApi "github.com/minio/console/api/operations/site_replication"
25+
"github.com/minio/console/models"
26+
"github.com/minio/madmin-go/v3"
27+
)
28+
29+
func registerSiteReplicationStatusHandler(api *operations.ConsoleAPI) {
30+
api.SiteReplicationGetSiteReplicationStatusHandler = siteRepApi.GetSiteReplicationStatusHandlerFunc(func(params siteRepApi.GetSiteReplicationStatusParams, session *models.Principal) middleware.Responder {
31+
rInfo, err := getSRStatusResponse(session, params)
32+
if err != nil {
33+
return siteRepApi.NewGetSiteReplicationStatusDefault(err.Code).WithPayload(err.APIError)
34+
}
35+
return siteRepApi.NewGetSiteReplicationStatusOK().WithPayload(rInfo)
36+
})
37+
}
38+
39+
func getSRStatusResponse(session *models.Principal, params siteRepApi.GetSiteReplicationStatusParams) (*models.SiteReplicationStatusResponse, *CodedAPIError) {
40+
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
41+
defer cancel()
42+
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
43+
if err != nil {
44+
return nil, ErrorWithContext(ctx, err)
45+
}
46+
adminClient := AdminClient{Client: mAdmin}
47+
res, err := getSRStats(ctx, adminClient, params)
48+
if err != nil {
49+
return nil, ErrorWithContext(ctx, err)
50+
}
51+
return res, nil
52+
}
53+
54+
func getSRStats(ctx context.Context, client MinioAdmin, params siteRepApi.GetSiteReplicationStatusParams) (info *models.SiteReplicationStatusResponse, err error) {
55+
srParams := madmin.SRStatusOptions{
56+
Buckets: *params.Buckets,
57+
Policies: *params.Policies,
58+
Users: *params.Users,
59+
Groups: *params.Groups,
60+
}
61+
if params.EntityType != nil && params.EntityValue != nil {
62+
srParams.Entity = madmin.GetSREntityType(*params.EntityType)
63+
srParams.EntityValue = *params.EntityValue
64+
}
65+
66+
srInfo, err := client.getSiteReplicationStatus(ctx, srParams)
67+
68+
retInfo := models.SiteReplicationStatusResponse{
69+
BucketStats: &srInfo.BucketStats,
70+
Enabled: srInfo.Enabled,
71+
GroupStats: srInfo.GroupStats,
72+
MaxBuckets: int64(srInfo.MaxBuckets),
73+
MaxGroups: int64(srInfo.MaxGroups),
74+
MaxPolicies: int64(srInfo.MaxPolicies),
75+
MaxUsers: int64(srInfo.MaxUsers),
76+
PolicyStats: &srInfo.PolicyStats,
77+
Sites: &srInfo.Sites,
78+
StatsSummary: srInfo.StatsSummary,
79+
UserStats: &srInfo.UserStats,
80+
}
81+
82+
if err != nil {
83+
return nil, err
84+
}
85+
return &retInfo, nil
86+
}

0 commit comments

Comments
 (0)