From 895357607a37af7b2ec43fd5469d09536c68b5e8 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 18 Aug 2022 11:10:49 -0700 Subject: [PATCH] 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 --- .nancy-ignore | 2 ++ cmd/site-replication.go | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.nancy-ignore b/.nancy-ignore index 58a249af8..28eb67a71 100644 --- a/.nancy-ignore +++ b/.nancy-ignore @@ -2,3 +2,5 @@ CVE-2020-26160 CVE-2020-15136 CVE-2020-15115 CVE-2020-15114 +CVE-2022-2835 +CVE-2022-2837 diff --git a/cmd/site-replication.go b/cmd/site-replication.go index e63514010..30304947e 100644 --- a/cmd/site-replication.go +++ b/cmd/site-replication.go @@ -2005,7 +2005,7 @@ func (c *SiteReplicationSys) isEnabled() bool { 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. 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 } 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 } errs[pi.DeploymentID] = errSRPeerResp(fmt.Errorf("unable to update peer %s: %w", pi.Name, err))