mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
improve validation for replication resync API (#15964)
This commit is contained in:
parent
6e4acf0504
commit
d765b89a63
@ -276,7 +276,13 @@ func (api objectAPIHandlers) ResetBucketReplicationStartHandler(w http.ResponseW
|
|||||||
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !config.HasExistingObjectReplication(arn) {
|
hasARN, hasExistingObjEnabled := config.HasExistingObjectReplication(arn)
|
||||||
|
if !hasARN {
|
||||||
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrRemoteTargetNotFoundError), r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hasExistingObjEnabled {
|
||||||
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrReplicationNoExistingObjects), r.URL)
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrReplicationNoExistingObjects), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -162,15 +162,18 @@ type ObjectOpts struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HasExistingObjectReplication returns true if any of the rule returns 'ExistingObjects' replication.
|
// HasExistingObjectReplication returns true if any of the rule returns 'ExistingObjects' replication.
|
||||||
func (c Config) HasExistingObjectReplication(arn string) bool {
|
func (c Config) HasExistingObjectReplication(arn string) (hasARN, isEnabled bool) {
|
||||||
for _, rule := range c.Rules {
|
for _, rule := range c.Rules {
|
||||||
if rule.Destination.ARN == arn || c.RoleArn == arn {
|
if rule.Destination.ARN == arn || c.RoleArn == arn {
|
||||||
|
if !hasARN {
|
||||||
|
hasARN = true
|
||||||
|
}
|
||||||
if rule.ExistingObjectReplication.Status == Enabled {
|
if rule.ExistingObjectReplication.Status == Enabled {
|
||||||
return true
|
return true, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return hasARN, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// FilterActionableRules returns the rules actions that need to be executed
|
// FilterActionableRules returns the rules actions that need to be executed
|
||||||
|
Loading…
Reference in New Issue
Block a user