avoid using errors.As for 'errors.New' use errors.Is (#15549)

Bonus: ignore coredns CVE, for now, there is no fix yet

https://github.com/coredns/coredns/issues/5574
This commit is contained in:
Harshavardhana 2022-08-18 11:10:49 -07:00 committed by GitHub
parent ac240a8477
commit 895357607a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -2,3 +2,5 @@ CVE-2020-26160
CVE-2020-15136 CVE-2020-15136
CVE-2020-15115 CVE-2020-15115
CVE-2020-15114 CVE-2020-15114
CVE-2022-2835
CVE-2022-2837

View File

@ -2005,7 +2005,7 @@ func (c *SiteReplicationSys) isEnabled() bool {
return c.enabled return c.enabled
} }
var errMissingSRConfig = fmt.Errorf("Site not found in site replication configuration") var errMissingSRConfig = fmt.Errorf("unable to find 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) {
@ -2057,7 +2057,8 @@ 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) { if errors.Is(err, errMissingSRConfig) {
// ignore if peer is already removed.
return 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))