diff --git a/pkg/raft/BUILD.bazel b/pkg/raft/BUILD.bazel index d4cdc81d1711..92a25008e32f 100644 --- a/pkg/raft/BUILD.bazel +++ b/pkg/raft/BUILD.bazel @@ -24,6 +24,7 @@ go_library( "//pkg/raft/quorum", "//pkg/raft/raftpb", "//pkg/raft/tracker", + "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/raft/bootstrap.go b/pkg/raft/bootstrap.go index ace18ef75177..a362921ffac3 100644 --- a/pkg/raft/bootstrap.go +++ b/pkg/raft/bootstrap.go @@ -18,9 +18,8 @@ package raft import ( - "errors" - pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" + "github.com/cockroachdb/errors" ) // Bootstrap initializes the RawNode for first use by appending configuration diff --git a/pkg/raft/confchange/BUILD.bazel b/pkg/raft/confchange/BUILD.bazel index f3869cbead2d..0aa0aaa172ea 100644 --- a/pkg/raft/confchange/BUILD.bazel +++ b/pkg/raft/confchange/BUILD.bazel @@ -12,6 +12,7 @@ go_library( "//pkg/raft/quorum", "//pkg/raft/raftpb", "//pkg/raft/tracker", + "@com_github_cockroachdb_errors//:errors", ], ) @@ -28,5 +29,6 @@ go_test( "//pkg/raft/raftpb", "//pkg/raft/tracker", "@com_github_cockroachdb_datadriven//:datadriven", + "@com_github_cockroachdb_errors//:errors", ], ) diff --git a/pkg/raft/confchange/confchange.go b/pkg/raft/confchange/confchange.go index cd15d2d9e409..d0d3d618bc4b 100644 --- a/pkg/raft/confchange/confchange.go +++ b/pkg/raft/confchange/confchange.go @@ -18,13 +18,13 @@ package confchange import ( - "errors" "fmt" "strings" "github.com/cockroachdb/cockroach/pkg/raft/quorum" pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" "github.com/cockroachdb/cockroach/pkg/raft/tracker" + "github.com/cockroachdb/errors" ) // Changer facilitates configuration changes. It exposes methods to handle diff --git a/pkg/raft/confchange/datadriven_test.go b/pkg/raft/confchange/datadriven_test.go index b9f5fff835ca..bdbaec4f94dd 100644 --- a/pkg/raft/confchange/datadriven_test.go +++ b/pkg/raft/confchange/datadriven_test.go @@ -18,7 +18,6 @@ package confchange import ( - "errors" "fmt" "strconv" "strings" @@ -27,6 +26,7 @@ import ( pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" "github.com/cockroachdb/cockroach/pkg/raft/tracker" "github.com/cockroachdb/datadriven" + "github.com/cockroachdb/errors" ) func TestConfChangeDataDriven(t *testing.T) { diff --git a/pkg/raft/node.go b/pkg/raft/node.go index 181169f97cff..89ec506937b7 100644 --- a/pkg/raft/node.go +++ b/pkg/raft/node.go @@ -19,9 +19,9 @@ package raft import ( "context" - "errors" pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" + "github.com/cockroachdb/errors" ) type SnapshotStatus int diff --git a/pkg/raft/raft.go b/pkg/raft/raft.go index 696f1758fd82..3dadec548a95 100644 --- a/pkg/raft/raft.go +++ b/pkg/raft/raft.go @@ -20,7 +20,6 @@ package raft import ( "bytes" "crypto/rand" - "errors" "fmt" "math" "math/big" @@ -32,6 +31,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/raft/quorum" pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" "github.com/cockroachdb/cockroach/pkg/raft/tracker" + "github.com/cockroachdb/errors" ) const ( diff --git a/pkg/raft/rafttest/BUILD.bazel b/pkg/raft/rafttest/BUILD.bazel index 59500c9dd09d..01f5b710a638 100644 --- a/pkg/raft/rafttest/BUILD.bazel +++ b/pkg/raft/rafttest/BUILD.bazel @@ -37,6 +37,7 @@ go_library( "//pkg/raft/raftpb", "//pkg/raft/tracker", "@com_github_cockroachdb_datadriven//:datadriven", + "@com_github_cockroachdb_errors//:errors", "@com_github_stretchr_testify//require", ], ) diff --git a/pkg/raft/rafttest/interaction_env_handler_add_nodes.go b/pkg/raft/rafttest/interaction_env_handler_add_nodes.go index bc6565091d33..9ae0600e38a5 100644 --- a/pkg/raft/rafttest/interaction_env_handler_add_nodes.go +++ b/pkg/raft/rafttest/interaction_env_handler_add_nodes.go @@ -18,7 +18,6 @@ package rafttest import ( - "errors" "fmt" "reflect" "testing" @@ -26,6 +25,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/raft" pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" "github.com/cockroachdb/datadriven" + "github.com/cockroachdb/errors" ) func (env *InteractionEnv) handleAddNodes(t *testing.T, d datadriven.TestData) error { diff --git a/pkg/raft/rafttest/interaction_env_handler_process_append_thread.go b/pkg/raft/rafttest/interaction_env_handler_process_append_thread.go index 2409800a6833..6298683978de 100644 --- a/pkg/raft/rafttest/interaction_env_handler_process_append_thread.go +++ b/pkg/raft/rafttest/interaction_env_handler_process_append_thread.go @@ -18,13 +18,13 @@ package rafttest import ( - "errors" "fmt" "testing" "github.com/cockroachdb/cockroach/pkg/raft" "github.com/cockroachdb/cockroach/pkg/raft/raftpb" "github.com/cockroachdb/datadriven" + "github.com/cockroachdb/errors" ) func (env *InteractionEnv) handleProcessAppendThread(t *testing.T, d datadriven.TestData) error { diff --git a/pkg/raft/rafttest/interaction_env_handler_report_unreachable.go b/pkg/raft/rafttest/interaction_env_handler_report_unreachable.go index 6c8e310be9fd..496f3ccef858 100644 --- a/pkg/raft/rafttest/interaction_env_handler_report_unreachable.go +++ b/pkg/raft/rafttest/interaction_env_handler_report_unreachable.go @@ -18,10 +18,10 @@ package rafttest import ( - "errors" "testing" "github.com/cockroachdb/datadriven" + "github.com/cockroachdb/errors" ) func (env *InteractionEnv) handleReportUnreachable(t *testing.T, d datadriven.TestData) error { diff --git a/pkg/raft/rawnode.go b/pkg/raft/rawnode.go index ac6e629f0474..a9e409aba813 100644 --- a/pkg/raft/rawnode.go +++ b/pkg/raft/rawnode.go @@ -18,10 +18,9 @@ package raft import ( - "errors" - pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" "github.com/cockroachdb/cockroach/pkg/raft/tracker" + "github.com/cockroachdb/errors" ) // ErrStepLocalMsg is returned when try to step a local raft message diff --git a/pkg/raft/storage.go b/pkg/raft/storage.go index 50e7db30afe8..f9702f5e72ba 100644 --- a/pkg/raft/storage.go +++ b/pkg/raft/storage.go @@ -18,10 +18,10 @@ package raft import ( - "errors" "sync" pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb" + "github.com/cockroachdb/errors" ) // ErrCompacted is returned by Storage.Entries/Compact when a requested diff --git a/pkg/testutils/lint/lint_test.go b/pkg/testutils/lint/lint_test.go index 31416664fc84..03316ba30863 100644 --- a/pkg/testutils/lint/lint_test.go +++ b/pkg/testutils/lint/lint_test.go @@ -1776,12 +1776,19 @@ func TestLint(t *testing.T) { pkgs, err := packages.Load( &packages.Config{ Mode: packages.NeedImports | packages.NeedName, + Dir: crdbDir, }, pkgPath, ) if err != nil { return errors.Wrapf(err, "error loading package %s", pkgPath) } + // NB: if no packages were found, this API confusingly + // returns no error, so we need to explicitly check that + // something was returned. + if len(pkgs) == 0 { + return errors.Newf("could not list packages under %s", pkgPath) + } for _, pkg := range pkgs { for _, s := range pkg.Imports { arg.Out <- pkg.PkgPath + ": " + s.PkgPath @@ -1801,6 +1808,7 @@ func TestLint(t *testing.T) { stream.GrepNot(`cockroach/pkg/util/sysutil: syscall$`), stream.GrepNot(`cockroachdb/cockroach/pkg/build/bazel/util/tinystringer: errors$`), stream.GrepNot(`cockroachdb/cockroach/pkg/build/engflow: github\.com/golang/protobuf/proto$`), + stream.GrepNot(`cockroachdb/cockroach/pkg/build/engflow: log$`), stream.GrepNot(`cockroachdb/cockroach/pkg/util/grpcutil: github\.com/cockroachdb\/errors\/errbase$`), stream.GrepNot(`cockroachdb/cockroach/pkg/util/future: github\.com/cockroachdb\/errors\/errbase$`), stream.GrepNot(`cockroach/pkg/roachprod/install: syscall$`), // TODO: switch to sysutil @@ -1814,6 +1822,11 @@ func TestLint(t *testing.T) { stream.GrepNot(`cockroachdb/cockroach/pkg/kv/kvpb/gen: log$`), stream.GrepNot(`cockroachdb/cockroach/pkg/util/log/gen: log$`), stream.GrepNot(`cockroach/pkg/util/uuid: github\.com/satori/go\.uuid$`), + // See #132262. + stream.GrepNot(`github.com/cockroachdb/cockroach/pkg/raft: log$`), + stream.GrepNot(`github.com/cockroachdb/cockroach/pkg/raft/raftlogger: log$`), + stream.GrepNot(`github.com/cockroachdb/cockroach/pkg/raft/rafttest: log$`), + stream.GrepNot(`github.com/cockroachdb/cockroach/pkg/workload/debug: log$`), ), func(s string) { pkgStr := strings.Split(s, ": ") importingPkg, importedPkg := pkgStr[0], pkgStr[1]