diff --git a/internal/metarepos/raft_test.go b/internal/metarepos/raft_test.go index 2bfadfbcc..2ca8b3c60 100644 --- a/internal/metarepos/raft_test.go +++ b/internal/metarepos/raft_test.go @@ -10,6 +10,7 @@ import ( . "github.com/smartystreets/goconvey/convey" "go.etcd.io/etcd/raft/raftpb" + "go.uber.org/multierr" "go.uber.org/zap" "github.com/kakao/varlog/pkg/types" @@ -129,13 +130,13 @@ func (clus *cluster) close(i int) (err error) { func (clus *cluster) Close() (err error) { for i := range clus.peers { if erri := clus.close(i); erri != nil { - err = erri + err = multierr.Append(err, erri) } } os.RemoveAll("raftdata") //nolint:errcheck,revive // TODO:: Handle an error returned. - return clus.portLease.Release() + return multierr.Append(err, clus.portLease.Release()) } func (clus *cluster) closeNoErrors(t *testing.T) { diff --git a/internal/storagenode/logstream/replicate_task.go b/internal/storagenode/logstream/replicate_task.go index 052c45f02..1bcddc619 100644 --- a/internal/storagenode/logstream/replicate_task.go +++ b/internal/storagenode/logstream/replicate_task.go @@ -91,5 +91,5 @@ func newReplicateTaskSlice() []*replicateTask { func releaseReplicateTaskSlice(rts []*replicateTask) { rts = rts[0:0] - replicateTaskSlicePool.Put(rts) + replicateTaskSlicePool.Put(rts) //nolint:staticcheck } diff --git a/internal/storagenode/logstream/sequencer.go b/internal/storagenode/logstream/sequencer.go index 3e4acd7c4..149be111f 100644 --- a/internal/storagenode/logstream/sequencer.go +++ b/internal/storagenode/logstream/sequencer.go @@ -108,6 +108,7 @@ func (sq *sequencer) sequenceLoopInternal(ctx context.Context, st *sequenceTask) // NOTE: Use "append" since the length of st.rts is not enough to use index. Its capacity is enough because it is created to be reused. st.rts[replicaIdx].llsnList = append(st.rts[replicaIdx].llsnList, sq.llsn) } + //nolint:staticcheck if err := st.wb.Set(sq.llsn, st.dataBatch[dataIdx]); err != nil { // TODO: handle error } diff --git a/internal/stress/stress.go b/internal/stress/stress.go index 2d5b6ce64..990933b83 100644 --- a/internal/stress/stress.go +++ b/internal/stress/stress.go @@ -10,6 +10,7 @@ import ( "time" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "github.com/kakao/varlog/pkg/types" "github.com/kakao/varlog/pkg/varlog" @@ -124,7 +125,7 @@ func Append(config Config) error { go func() { defer wg.Done() vlog, err := varlog.Open(ctx, config.ClusterID, config.MRAddrs, varlog.WithGRPCDialOptions( - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithReadBufferSize(1<<20), grpc.WithWriteBufferSize(32<<20), )) diff --git a/internal/varlogcli/append.go b/internal/varlogcli/append.go index 82a82dfce..965de726b 100644 --- a/internal/varlogcli/append.go +++ b/internal/varlogcli/append.go @@ -82,7 +82,6 @@ func appendInternal(mrAddrs []string, clusterID types.ClusterID, batchSize int, batch = batch[0:0] case <-ctx.Done(): return ctx.Err() - default: } } if len(batch) > 0 { diff --git a/internal/varlogctl/controller_test.go b/internal/varlogctl/controller_test.go index 548ca513c..e0a589faa 100644 --- a/internal/varlogctl/controller_test.go +++ b/internal/varlogctl/controller_test.go @@ -3,7 +3,6 @@ package varlogctl_test import ( "context" "flag" - "io/ioutil" "os" "testing" "time" @@ -416,7 +415,7 @@ func TestController(t *testing.T) { return } - want, err := ioutil.ReadFile(path) + want, err := os.ReadFile(path) assert.NoError(t, err) if len(got) > 0 || len(want) > 0 { diff --git a/pkg/rpc/rpc_conn.go b/pkg/rpc/rpc_conn.go index cd70a2857..59608b02b 100644 --- a/pkg/rpc/rpc_conn.go +++ b/pkg/rpc/rpc_conn.go @@ -6,10 +6,11 @@ import ( "github.com/pkg/errors" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) var ( - defaultDialOption = []grpc.DialOption{grpc.WithInsecure()} + defaultDialOption = []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())} ) type Conn struct { diff --git a/pkg/util/fputil/dirsize_test.go b/pkg/util/fputil/dirsize_test.go index 429d64a5a..3b9f390ee 100644 --- a/pkg/util/fputil/dirsize_test.go +++ b/pkg/util/fputil/dirsize_test.go @@ -2,7 +2,7 @@ package fputil import ( "io/fs" - "io/ioutil" + "os" "path/filepath" "testing" @@ -18,7 +18,7 @@ func TestDirectorySize(t *testing.T) { path := t.TempDir() assert.Zero(t, DirectorySize(path)) - assert.NoError(t, ioutil.WriteFile(filepath.Join(path, "foo"), []byte{'a'}, fs.FileMode(777))) + assert.NoError(t, os.WriteFile(filepath.Join(path, "foo"), []byte{'a'}, fs.FileMode(0777))) assert.EqualValues(t, 1, DirectorySize(path)) } diff --git a/pkg/util/fputil/filepath.go b/pkg/util/fputil/filepath.go index c7c60ccd2..d054d90f4 100644 --- a/pkg/util/fputil/filepath.go +++ b/pkg/util/fputil/filepath.go @@ -1,7 +1,6 @@ package fputil import ( - "io/ioutil" "os" "path/filepath" @@ -19,7 +18,7 @@ func IsWritableDir(dir string) error { return errors.WithStack(err) } filename := filepath.Join(dir, touchFileName) - if err := ioutil.WriteFile(filename, []byte(""), touchFileMode); err != nil { + if err := os.WriteFile(filename, []byte(""), touchFileMode); err != nil { return errors.WithStack(err) } err = os.Remove(filename) diff --git a/pkg/util/testutil/conveyutil/conveyutil.go b/pkg/util/testutil/conveyutil/conveyutil.go index a19be02ec..152518543 100644 --- a/pkg/util/testutil/conveyutil/conveyutil.go +++ b/pkg/util/testutil/conveyutil/conveyutil.go @@ -5,6 +5,7 @@ import ( "github.com/smartystreets/goconvey/convey" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "github.com/kakao/varlog/pkg/util/netutil" ) @@ -35,7 +36,11 @@ func WithServiceServer(s service, testf func(server *grpc.Server, addr string)) // addr := testutil.GetLocalAddress(lis) ctx, cancel := context.WithCancel(context.Background()) defer cancel() - conn, err := grpc.DialContext(ctx, addr, grpc.WithInsecure(), grpc.WithBlock(), grpc.FailOnNonTempDialError(true)) + conn, err := grpc.DialContext(ctx, addr, + grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithBlock(), + grpc.FailOnNonTempDialError(true), + ) convey.So(err, convey.ShouldBeNil) convey.So(conn.Close(), convey.ShouldBeNil) diff --git a/pkg/varlog/options.go b/pkg/varlog/options.go index bda4957f1..2f090f1d0 100644 --- a/pkg/varlog/options.go +++ b/pkg/varlog/options.go @@ -5,6 +5,7 @@ import ( "go.uber.org/zap" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) const ( @@ -36,7 +37,7 @@ func defaultOptions() options { expireDenyInterval: defaultExpireDenyInterval, logger: zap.NewNop(), grpcDialOptions: []grpc.DialOption{ - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithReadBufferSize(1 << 20), grpc.WithWriteBufferSize(1 << 20), }, diff --git a/pkg/varlogtest/log.go b/pkg/varlogtest/log.go index 025eb06b5..cb8ed5f42 100644 --- a/pkg/varlogtest/log.go +++ b/pkg/varlogtest/log.go @@ -292,7 +292,7 @@ func (c *testLog) LogStreamMetadata(_ context.Context, topicID types.TopicID, lo logStreamDesc = *proto.Clone(&logStreamDesc).(*varlogpb.LogStreamDescriptor) head, tail := c.vt.peek(topicID, logStreamID) - logStreamDesc.Head = head + logStreamDesc.Head = head //nolint:staticcheck logStreamDesc.Tail = tail return logStreamDesc, nil } diff --git a/pkg/varlogtest/varlogtest_test.go b/pkg/varlogtest/varlogtest_test.go index 07bb89b24..5c29b9708 100644 --- a/pkg/varlogtest/varlogtest_test.go +++ b/pkg/varlogtest/varlogtest_test.go @@ -145,7 +145,7 @@ func TestVarlogTest(t *testing.T) { require.Equal(t, varlogpb.LogEntryMeta{ TopicID: topicID, LogStreamID: logStreamID, - }, logStreamDesc.Head) + }, logStreamDesc.Head) //nolint:staticcheck require.Equal(t, varlogpb.LogEntryMeta{ TopicID: topicID, LogStreamID: logStreamID, @@ -326,8 +326,8 @@ func TestVarlogTest(t *testing.T) { for _, lsID := range topicLogStreamsMap[tpID] { lsDesc, err := vlg.LogStreamMetadata(context.Background(), tpID, lsID) require.NoError(t, err) - require.GreaterOrEqual(t, lsDesc.Tail.LLSN, lsDesc.Head.LLSN) - subscribeTo(tpID, lsID, lsDesc.Head.LLSN, lsDesc.Tail.LLSN+1) + require.GreaterOrEqual(t, lsDesc.Tail.LLSN, lsDesc.Head.LLSN) //nolint:staticcheck + subscribeTo(tpID, lsID, lsDesc.Head.LLSN, lsDesc.Tail.LLSN+1) //nolint:staticcheck lsd, err := adm.Unseal(context.Background(), tpID, lsID) require.NoError(t, err) @@ -345,8 +345,8 @@ func TestVarlogTest(t *testing.T) { for _, lsID := range lsIDs { lsDesc, err := vlg.LogStreamMetadata(context.Background(), tpID, lsID) require.NoError(t, err) - require.GreaterOrEqual(t, lsDesc.Tail.LLSN, lsDesc.Head.LLSN) - subscribeTo(tpID, lsID, lsDesc.Head.LLSN, lsDesc.Tail.LLSN+1) + require.GreaterOrEqual(t, lsDesc.Tail.LLSN, lsDesc.Head.LLSN) //nolint:staticcheck + subscribeTo(tpID, lsID, lsDesc.Head.LLSN, lsDesc.Tail.LLSN+1) //nolint:staticcheck } } @@ -356,7 +356,7 @@ func TestVarlogTest(t *testing.T) { lsDesc, err := vlg.LogStreamMetadata(context.Background(), tpID, lsID) require.NoError(t, err) - require.Equal(t, types.MinLLSN, lsDesc.Head.LLSN) + require.Equal(t, types.MinLLSN, lsDesc.Head.LLSN) //nolint:staticcheck require.GreaterOrEqual(t, lsDesc.Tail.LLSN, types.LLSN(minLogsPerTopic)) ctx1, cancel1 := context.WithCancel(context.Background()) @@ -523,15 +523,15 @@ func TestVarlogTest_Trim(t *testing.T) { lsd, err := vlg.LogStreamMetadata(context.Background(), td.TopicID, lsds[0].LogStreamID) assert.NoError(t, err) - assert.Equal(t, types.LLSN(3), lsd.Head.LLSN) - assert.Equal(t, types.GLSN(5), lsd.Head.GLSN) + assert.Equal(t, types.LLSN(3), lsd.Head.LLSN) //nolint:staticcheck + assert.Equal(t, types.GLSN(5), lsd.Head.GLSN) //nolint:staticcheck assert.Equal(t, types.LLSN(5), lsd.Tail.LLSN) assert.Equal(t, types.GLSN(9), lsd.Tail.GLSN) lsd, err = vlg.LogStreamMetadata(context.Background(), td.TopicID, lsds[1].LogStreamID) assert.NoError(t, err) - assert.Equal(t, types.LLSN(2), lsd.Head.LLSN) - assert.Equal(t, types.GLSN(4), lsd.Head.GLSN) + assert.Equal(t, types.LLSN(2), lsd.Head.LLSN) //nolint:staticcheck + assert.Equal(t, types.GLSN(4), lsd.Head.GLSN) //nolint:staticcheck assert.Equal(t, types.LLSN(5), lsd.Tail.LLSN) assert.Equal(t, types.GLSN(10), lsd.Tail.GLSN) diff --git a/tests/ee/k8s/vault/vault.go b/tests/ee/k8s/vault/vault.go index 8c075523b..35d2e44df 100644 --- a/tests/ee/k8s/vault/vault.go +++ b/tests/ee/k8s/vault/vault.go @@ -3,7 +3,7 @@ package vault import ( "encoding/json" "flag" - "io/ioutil" + "io" "net/http" "os" "testing" @@ -51,7 +51,7 @@ func GetClusterConnectionInfo(t *testing.T) ClusterConnectionInfo { assert.NoError(t, err) }() - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) var response Response diff --git a/tests/it/cluster/client_test.go b/tests/it/cluster/client_test.go index e00588ad7..66956c841 100644 --- a/tests/it/cluster/client_test.go +++ b/tests/it/cluster/client_test.go @@ -208,10 +208,10 @@ func TestClientAppend(t *testing.T) { require.Equal(t, topicID, lsd.TopicID) require.Equal(t, logStreamID, lsd.LogStreamID) - require.Equal(t, types.MinLLSN, lsd.Head.LLSN) - require.GreaterOrEqual(t, lsd.Head.GLSN, types.MinGLSN) - require.Equal(t, topicID, lsd.Head.TopicID) - require.Equal(t, logStreamID, lsd.Head.LogStreamID) + require.Equal(t, types.MinLLSN, lsd.Head.LLSN) //nolint:staticcheck + require.GreaterOrEqual(t, lsd.Head.GLSN, types.MinGLSN) //nolint:staticcheck + require.Equal(t, topicID, lsd.Head.TopicID) //nolint:staticcheck + require.Equal(t, logStreamID, lsd.Head.LogStreamID) //nolint:staticcheck require.GreaterOrEqual(t, lsd.Tail.LLSN, types.MinLLSN) require.GreaterOrEqual(t, lsd.Tail.GLSN, types.MinGLSN) diff --git a/tests/it/management/management_test.go b/tests/it/management/management_test.go index e91562b56..3f8a54824 100644 --- a/tests/it/management/management_test.go +++ b/tests/it/management/management_test.go @@ -526,7 +526,7 @@ func TestSealLogStreamSealedIncompletely(t *testing.T) { So(err, ShouldBeNil) So(testutil.CompareWaitN(100, func() bool { - meta, err := env.GetVMS().Metadata(context.TODO()) + meta, err := env.GetVMS().Metadata(context.TODO()) //nolint:staticcheck if err != nil { return false } diff --git a/tests/it/testenv.go b/tests/it/testenv.go index 80e3049aa..228902d7b 100644 --- a/tests/it/testenv.go +++ b/tests/it/testenv.go @@ -1563,7 +1563,7 @@ func (clus *VarlogCluster) WaitCommit(t *testing.T, lsID types.LogStreamID, vers func (clus *VarlogCluster) WaitSealed(t *testing.T, lsID types.LogStreamID) { // FIXME: do not use vms.RELOAD_INTERVAL require.Eventually(t, func() bool { - vmsMeta, err := clus.vmsServer.Metadata(context.Background()) + vmsMeta, err := clus.vmsServer.Metadata(context.Background()) //nolint:staticcheck return err == nil && vmsMeta.GetLogStream(lsID) != nil }, mrmanager.ReloadInterval*10, 100*time.Millisecond)