mirror of
https://github.com/minio/minio.git
synced 2025-05-21 09:33:50 -04:00
fix: site removal API error handling (#14870)
when the site is being removed is missing replication config. This can happen when a new deployment is brought in place of a site that is lost/destroyed and needs to delink old deployment from site replication.
This commit is contained in:
parent
35dea24ffd
commit
523670ba0d
@ -280,6 +280,7 @@ const (
|
|||||||
ErrSiteReplicationBucketConfigError
|
ErrSiteReplicationBucketConfigError
|
||||||
ErrSiteReplicationBucketMetaError
|
ErrSiteReplicationBucketMetaError
|
||||||
ErrSiteReplicationIAMError
|
ErrSiteReplicationIAMError
|
||||||
|
ErrSiteReplicationConfigMissing
|
||||||
|
|
||||||
// Bucket Quota error codes
|
// Bucket Quota error codes
|
||||||
ErrAdminBucketQuotaExceeded
|
ErrAdminBucketQuotaExceeded
|
||||||
@ -1340,7 +1341,11 @@ var errorCodes = errorCodeMap{
|
|||||||
Description: "Error while replicating an IAM item",
|
Description: "Error while replicating an IAM item",
|
||||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
HTTPStatusCode: http.StatusServiceUnavailable,
|
||||||
},
|
},
|
||||||
|
ErrSiteReplicationConfigMissing: {
|
||||||
|
Code: "XMinioSiteReplicationConfigMissingError",
|
||||||
|
Description: "Site not found in site replication configuration",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
ErrMaximumExpires: {
|
ErrMaximumExpires: {
|
||||||
Code: "AuthorizationQueryParametersError",
|
Code: "AuthorizationQueryParametersError",
|
||||||
Description: "X-Amz-Expires must be less than a week (in seconds); that is, the given X-Amz-Expires must be less than 604800 seconds",
|
Description: "X-Amz-Expires must be less than a week (in seconds); that is, the given X-Amz-Expires must be less than 604800 seconds",
|
||||||
|
File diff suppressed because one or more lines are too long
@ -126,6 +126,13 @@ func errSRIAMError(err error) SRError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func errSRConfigMissingError(err error) SRError {
|
||||||
|
return SRError{
|
||||||
|
Cause: err,
|
||||||
|
Code: ErrSiteReplicationConfigMissing,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var errSRObjectLayerNotReady = SRError{
|
var errSRObjectLayerNotReady = SRError{
|
||||||
Cause: fmt.Errorf("object layer not ready"),
|
Cause: fmt.Errorf("object layer not ready"),
|
||||||
Code: ErrServerNotInitialized,
|
Code: ErrServerNotInitialized,
|
||||||
@ -1848,6 +1855,8 @@ func (c *SiteReplicationSys) isEnabled() bool {
|
|||||||
return c.enabled
|
return c.enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errMissingSRConfig = fmt.Errorf("Site not found in site replication configuration")
|
||||||
|
|
||||||
// RemovePeerCluster - removes one or more clusters from site replication configuration.
|
// RemovePeerCluster - removes one or more clusters from site replication configuration.
|
||||||
func (c *SiteReplicationSys) RemovePeerCluster(ctx context.Context, objectAPI ObjectLayer, rreq madmin.SRRemoveReq) (st madmin.ReplicateRemoveStatus, err error) {
|
func (c *SiteReplicationSys) RemovePeerCluster(ctx context.Context, objectAPI ObjectLayer, rreq madmin.SRRemoveReq) (st madmin.ReplicateRemoveStatus, err error) {
|
||||||
if !c.isEnabled() {
|
if !c.isEnabled() {
|
||||||
@ -1872,7 +1881,7 @@ func (c *SiteReplicationSys) RemovePeerCluster(ctx context.Context, objectAPI Ob
|
|||||||
for _, s := range siteNames {
|
for _, s := range siteNames {
|
||||||
info, ok := peerMap[s]
|
info, ok := peerMap[s]
|
||||||
if !ok {
|
if !ok {
|
||||||
return st, errSRInvalidRequest(fmt.Errorf("Site %s not found in site replication configuration", s))
|
return st, errSRConfigMissingError(errMissingSRConfig)
|
||||||
}
|
}
|
||||||
rmvEndpoints = append(rmvEndpoints, info.Endpoint)
|
rmvEndpoints = append(rmvEndpoints, info.Endpoint)
|
||||||
delete(updatedPeers, info.DeploymentID)
|
delete(updatedPeers, info.DeploymentID)
|
||||||
@ -1898,6 +1907,9 @@ func (c *SiteReplicationSys) RemovePeerCluster(ctx context.Context, objectAPI Ob
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, err = admClient.SRPeerRemove(ctx, rreq); err != nil {
|
if _, err = admClient.SRPeerRemove(ctx, rreq); err != nil {
|
||||||
|
if errors.As(err, &errMissingSRConfig) {
|
||||||
|
return
|
||||||
|
}
|
||||||
errs[pi.DeploymentID] = errSRPeerResp(fmt.Errorf("unable to update peer %s: %w", pi.Name, err))
|
errs[pi.DeploymentID] = errSRPeerResp(fmt.Errorf("unable to update peer %s: %w", pi.Name, err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1937,6 +1949,10 @@ func (c *SiteReplicationSys) RemovePeerCluster(ctx context.Context, objectAPI Ob
|
|||||||
// InternalRemoveReq - sends an unlink request to peer cluster to remove one or more sites
|
// InternalRemoveReq - sends an unlink request to peer cluster to remove one or more sites
|
||||||
// from the site replication configuration.
|
// from the site replication configuration.
|
||||||
func (c *SiteReplicationSys) InternalRemoveReq(ctx context.Context, objectAPI ObjectLayer, rreq madmin.SRRemoveReq) error {
|
func (c *SiteReplicationSys) InternalRemoveReq(ctx context.Context, objectAPI ObjectLayer, rreq madmin.SRRemoveReq) error {
|
||||||
|
if !c.isEnabled() {
|
||||||
|
return errSRNotEnabled
|
||||||
|
}
|
||||||
|
|
||||||
ourName := ""
|
ourName := ""
|
||||||
peerMap := make(map[string]madmin.PeerInfo)
|
peerMap := make(map[string]madmin.PeerInfo)
|
||||||
updatedPeers := make(map[string]madmin.PeerInfo)
|
updatedPeers := make(map[string]madmin.PeerInfo)
|
||||||
@ -1958,7 +1974,7 @@ func (c *SiteReplicationSys) InternalRemoveReq(ctx context.Context, objectAPI Ob
|
|||||||
for _, s := range siteNames {
|
for _, s := range siteNames {
|
||||||
info, ok := peerMap[s]
|
info, ok := peerMap[s]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Site %s not found in site replication configuration", s)
|
return errMissingSRConfig
|
||||||
}
|
}
|
||||||
if info.DeploymentID == globalDeploymentID {
|
if info.DeploymentID == globalDeploymentID {
|
||||||
unlinkSelf = true
|
unlinkSelf = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user