Fixed issues in Replication rules screens (#2145)

This commit is contained in:
Alex
2022-06-23 23:35:50 -05:00
committed by GitHub
parent 2830022ede
commit beeb188d7e
3 changed files with 25 additions and 28 deletions

View File

@@ -2787,10 +2787,7 @@ func TestReplication(t *testing.T) {
}
finalResponse := inspectHTTPResponse(response)
if response != nil {
// https://github.com/minio/minio/pull/14972
// Disallow deletion of arn when active replication config
// no longer 204 is expected due to above change
assert.Equal(500, response.StatusCode, finalResponse)
assert.Equal(204, response.StatusCode, finalResponse)
}
// 6. Delete 2nd rule only with dedicated end point for single rules:
@@ -2825,10 +2822,7 @@ func TestReplication(t *testing.T) {
}
finalResponse = inspectHTTPResponse(response)
if response != nil {
// https://github.com/minio/minio/pull/14972
// Disallow deletion of arn when active replication config
// 204 is no longer expected but 500
assert.Equal(500, response.StatusCode, finalResponse)
assert.Equal(204, response.StatusCode, finalResponse)
}
// 8. Get replication, at this point zero rules are expected
@@ -2850,7 +2844,7 @@ func TestReplication(t *testing.T) {
log.Println(err)
assert.Nil(err)
}
expected := 3 // none got deleted due to https://github.com/minio/minio/pull/14972
expected := 0
actual := len(structBucketRepl.Rules)
assert.Equal(expected, actual, "Delete failed")
}

View File

@@ -170,10 +170,10 @@ const AddReplicationModal = ({
setAddLoading(false);
if (itemVal.errorString && itemVal.errorString !== "") {
setModalErrorSnackMessage({
dispatch(setModalErrorSnackMessage({
errorMessage: itemVal.errorString,
detailedError: "",
});
}));
return;
}
@@ -181,10 +181,10 @@ const AddReplicationModal = ({
return;
}
setModalErrorSnackMessage({
dispatch(setModalErrorSnackMessage({
errorMessage: "No changes applied",
detailedError: "",
});
}));
})
.catch((err: ErrorResponseHandler) => {
setAddLoading(false);

View File

@@ -614,10 +614,6 @@ func deleteReplicationRule(ctx context.Context, session *models.Principal, bucke
}
admClient := AdminClient{Client: mAdmin}
err3 := deleteRemoteBucket(ctx, admClient, bucketName, getARNFromID(&cfg, ruleID))
if err3 != nil {
return err3
}
// create a mc S3Client interface implementation
// defining the client to be used
mcClient := mcClient{client: s3Client}
@@ -632,6 +628,12 @@ func deleteReplicationRule(ctx context.Context, session *models.Principal, bucke
return err2.Cause
}
// Replication rule was successfully deleted. We remove remote bucket
err3 := deleteRemoteBucket(ctx, admClient, bucketName, getARNFromID(&cfg, ruleID))
if err3 != nil {
return err3
}
return nil
}
@@ -663,6 +665,12 @@ func deleteAllReplicationRules(ctx context.Context, session *models.Principal, b
}
admClient := AdminClient{Client: mAdmin}
err2 := mcClient.deleteAllReplicationRules(ctx)
if err2 != nil {
return err
}
for i := range cfg.Rules {
err3 := deleteRemoteBucket(ctx, admClient, bucketName, cfg.Rules[i].Destination.Bucket)
if err3 != nil {
@@ -670,12 +678,6 @@ func deleteAllReplicationRules(ctx context.Context, session *models.Principal, b
}
}
err2 := mcClient.deleteAllReplicationRules(ctx)
if err2 != nil {
return err
}
return nil
}
@@ -710,11 +712,6 @@ func deleteSelectedReplicationRules(ctx context.Context, session *models.Princip
ARNs := getARNsFromIDs(&cfg, rules)
for i := range rules {
err3 := deleteRemoteBucket(ctx, admClient, bucketName, ARNs[i])
if err3 != nil {
return err3
}
opts := replication.Options{
ID: rules[i],
Op: replication.RemoveOption,
@@ -723,6 +720,12 @@ func deleteSelectedReplicationRules(ctx context.Context, session *models.Princip
if err2 != nil {
return err2.Cause
}
// In case replication rule was deleted successfully, we remove the remote bucket ARN
err3 := deleteRemoteBucket(ctx, admClient, bucketName, ARNs[i])
if err3 != nil {
return err3
}
}
return nil
}