diff --git a/server/etcdserver/api/v3rpc/lease.go b/server/etcdserver/api/v3rpc/lease.go index 86f35113cd99..e03953935b61 100644 --- a/server/etcdserver/api/v3rpc/lease.go +++ b/server/etcdserver/api/v3rpc/lease.go @@ -77,7 +77,7 @@ func (ls *LeaseServer) LeaseTimeToLive(ctx context.Context, rr *pb.LeaseTimeToLi func (ls *LeaseServer) LeaseLeases(ctx context.Context, rr *pb.LeaseLeasesRequest) (*pb.LeaseLeasesResponse, error) { resp, err := ls.le.LeaseLeases(ctx, rr) - if err != nil && err != lease.ErrLeaseNotFound { + if err != nil && !errors.Is(err, lease.ErrLeaseNotFound) { return nil, togRPCError(err) } if err == lease.ErrLeaseNotFound { diff --git a/server/etcdserver/api/v3rpc/maintenance.go b/server/etcdserver/api/v3rpc/maintenance.go index 7ca5d5abbcef..64544b2d1c81 100644 --- a/server/etcdserver/api/v3rpc/maintenance.go +++ b/server/etcdserver/api/v3rpc/maintenance.go @@ -17,6 +17,7 @@ package v3rpc import ( "context" "crypto/sha256" + errorspkg "errors" "io" "time" @@ -163,7 +164,7 @@ func (ms *maintenanceServer) Snapshot(sr *pb.SnapshotRequest, srv pb.Maintenance buf := make([]byte, snapshotSendBufferSize) n, err := io.ReadFull(pr, buf) - if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { + if err != nil && err != io.EOF && !errorspkg.Is(err, io.ErrUnexpectedEOF) { return togRPCError(err) } sent += int64(n) diff --git a/server/etcdserver/apply/uber_applier.go b/server/etcdserver/apply/uber_applier.go index 3c00c60efeef..82b7a6276698 100644 --- a/server/etcdserver/apply/uber_applier.go +++ b/server/etcdserver/apply/uber_applier.go @@ -16,6 +16,7 @@ package apply import ( "context" + "errors" "time" "go.uber.org/zap" @@ -123,7 +124,7 @@ func (a *uberApplier) dispatch(ctx context.Context, r *pb.InternalRaftRequest) * op := "unknown" ar := &Result{} defer func(start time.Time) { - success := ar.Err == nil || ar.Err == mvcc.ErrCompacted + success := ar.Err == nil || errors.Is(ar.Err, mvcc.ErrCompacted) txn.ApplySecObserve(v3Version, op, success, time.Since(start)) txn.WarnOfExpensiveRequest(a.lg, a.warningApplyDuration, start, &pb.InternalRaftStringer{Request: r}, ar.Resp, ar.Err) if !success { diff --git a/server/proxy/grpcproxy/health.go b/server/proxy/grpcproxy/health.go index b4a683242aaf..3bbfa9e2b0fb 100644 --- a/server/proxy/grpcproxy/health.go +++ b/server/proxy/grpcproxy/health.go @@ -16,6 +16,7 @@ package grpcproxy import ( "context" + "errors" "fmt" "net/http" "time" @@ -52,7 +53,7 @@ func checkHealth(c *clientv3.Client) etcdhttp.Health { ctx, cancel := context.WithTimeout(c.Ctx(), time.Second) _, err := c.Get(ctx, "a") cancel() - if err == nil || err == rpctypes.ErrPermissionDenied { + if err == nil || errors.Is(err, rpctypes.ErrPermissionDenied) { h.Health = "true" } else { h.Reason = fmt.Sprintf("GET ERROR:%s", err) diff --git a/server/storage/backend/batch_tx.go b/server/storage/backend/batch_tx.go index 5f9d1f913241..5af557cb4283 100644 --- a/server/storage/backend/batch_tx.go +++ b/server/storage/backend/batch_tx.go @@ -16,6 +16,7 @@ package backend import ( "bytes" + "errors" "math" "sync" "sync/atomic" @@ -125,7 +126,7 @@ func (t *batchTx) UnsafeCreateBucket(bucket Bucket) { func (t *batchTx) UnsafeDeleteBucket(bucket Bucket) { err := t.tx.DeleteBucket(bucket.Name()) - if err != nil && err != bolterrors.ErrBucketNotFound { + if err != nil && !errors.Is(err, bolterrors.ErrBucketNotFound) { t.backend.lg.Fatal( "failed to delete a bucket", zap.Stringer("bucket-name", bucket), diff --git a/server/storage/storage.go b/server/storage/storage.go index 21542f9eee2b..99a37a23d071 100644 --- a/server/storage/storage.go +++ b/server/storage/storage.go @@ -15,6 +15,7 @@ package storage import ( + "errors" "sync" "github.com/coreos/go-semver/semver" @@ -112,7 +113,7 @@ func (st *storage) MinimalEtcdVersion() *semver.Version { walsnap := walpb.Snapshot{} sn, err := st.s.Load() - if err != nil && err != snap.ErrNoSnapshot { + if err != nil && !errors.Is(err, snap.ErrNoSnapshot) { panic(err) } if sn != nil { diff --git a/server/storage/wal/wal_test.go b/server/storage/wal/wal_test.go index ed3a8893df55..5f9d1b169f88 100644 --- a/server/storage/wal/wal_test.go +++ b/server/storage/wal/wal_test.go @@ -853,7 +853,7 @@ func TestOpenOnTornWrite(t *testing.T) { p := t.TempDir() w, err := Create(zaptest.NewLogger(t), p, nil) defer func() { - if err = w.Close(); err != nil && err != os.ErrInvalid { + if err = w.Close(); err != nil && !errors.Is(os.ErrInvalid, err) { t.Fatal(err) } }()