Skip to content

Commit

Permalink
Etcd 3.4 & Go 1.16 upgrades (#4229)
Browse files Browse the repository at this point in the history
  • Loading branch information
amdprophet authored Apr 6, 2021
1 parent 20b92d9 commit f802cc7
Show file tree
Hide file tree
Showing 95 changed files with 1,504 additions and 306 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cache:

environment:
GOPATH: c:\gopath
GOVERSION: 1.13.15
GOVERSION: 1.16
GO111MODULE: 'on'
GOPROXY: 'https://proxy.golang.org'

Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ orbs:

sensu_go_build_env: &sensu_go_build_env
docker:
- image: cimg/go:1.13.15
- image: cimg/go:1.16
auth:
username: $DOCKER_USERNAME
password: $DOCKER_PASSWORD
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.13.15
go-version: 1.16
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand All @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.13.15
go-version: 1.16
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand All @@ -44,7 +44,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.13.15
go-version: 1.16
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand All @@ -58,7 +58,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.13.15
go-version: 1.16
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand All @@ -72,7 +72,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.13.15
go-version: 1.16
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ namespaces with initial resources.
- Add `EntityServiceClass` constant to the `corev2` package, representing BSM Services.
- Added ResourceTemplate instantiation on namespace creation.
- Added more context when logging JavaScript filter evaluation errors.
- Added `etcd-log-level` configuration flag for setting the log level of the
embedded etcd server.

### Changed
- Upgraded Go version from 1.13.15 to 1.16.
- Upgraded Etcd version from 3.3.22 to 3.4.15.

### Fixed
- Both V2 & V3 resources are now validated when used with storev2.
Expand Down
5 changes: 3 additions & 2 deletions api/core/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ module github.com/sensu/sensu-go/api/core/v2

go 1.13

replace go.etcd.io/etcd => go.etcd.io/etcd v0.0.0-20210226220824-aa7126864d82

require (
github.com/coreos/etcd v3.3.22+incompatible
github.com/coreos/go-semver v0.3.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/echlebek/crock v1.0.1
Expand All @@ -16,7 +17,7 @@ require (
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.6.0
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect
go.etcd.io/etcd v3.4.15+incompatible
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
193 changes: 183 additions & 10 deletions api/core/v2/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/core/v2/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/coreos/etcd/etcdserver/etcdserverpb"
"go.etcd.io/etcd/etcdserver/etcdserverpb"
)

// ClusterHealth holds cluster member status info.
Expand Down
2 changes: 1 addition & 1 deletion api/core/v2/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v2

import (
etcdVersion "github.com/coreos/etcd/version"
etcdVersion "go.etcd.io/etcd/version"
)

// Version holds the current etcd server and cluster version, and the sensu-backend version.
Expand Down
1 change: 1 addition & 0 deletions api/core/v3/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.13
replace (
github.com/sensu/sensu-go/api/core/v2 => ../v2
github.com/sensu/sensu-go/types => ../../../types
go.etcd.io/etcd => go.etcd.io/etcd v0.0.0-20210226220824-aa7126864d82
)

require (
Expand Down
186 changes: 186 additions & 0 deletions api/core/v3/go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion backend/agentd/agentd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"sync/atomic"
"time"

"github.com/coreos/etcd/clientv3"
"github.com/gogo/protobuf/proto"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
Expand All @@ -33,6 +32,7 @@ import (
"github.com/sensu/sensu-go/backend/store/v2/etcdstore"
"github.com/sensu/sensu-go/transport"
"github.com/sirupsen/logrus"
"go.etcd.io/etcd/clientv3"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion backend/agentd/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"

"github.com/coreos/etcd/clientv3"
"github.com/gogo/protobuf/proto"
corev2 "github.com/sensu/sensu-go/api/core/v2"
corev3 "github.com/sensu/sensu-go/api/core/v3"
Expand All @@ -13,6 +12,7 @@ import (
storev2 "github.com/sensu/sensu-go/backend/store/v2"
etcdstorev2 "github.com/sensu/sensu-go/backend/store/v2/etcdstore"
"github.com/sensu/sensu-go/backend/store/v2/wrap"
"go.etcd.io/etcd/clientv3"
)

// GetEntityConfigWatcher watches changes to EntityConfig in etcd and publish them
Expand Down
2 changes: 1 addition & 1 deletion backend/apid/actions/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package actions
import (
"context"

"github.com/coreos/etcd/clientv3"
"github.com/sensu/sensu-go/backend/store"
"go.etcd.io/etcd/clientv3"
)

// ClusterController is a thin wrapper around clientv3.Cluster. It exists
Expand Down
9 changes: 8 additions & 1 deletion backend/apid/actions/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"errors"
"testing"

"github.com/coreos/etcd/clientv3"
"github.com/google/uuid"
"github.com/sensu/sensu-go/backend/store"
"github.com/sensu/sensu-go/testing/mockstore"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"go.etcd.io/etcd/clientv3"
"golang.org/x/net/context"
)

Expand All @@ -30,7 +30,14 @@ func (mockCluster) MemberRemove(context.Context, uint64) (*clientv3.MemberRemove

func (mockCluster) MemberUpdate(context.Context, uint64, []string) (*clientv3.MemberUpdateResponse, error) {
return new(clientv3.MemberUpdateResponse), nil
}

func (mockCluster) MemberPromote(context.Context, uint64) (*clientv3.MemberPromoteResponse, error) {
return new(clientv3.MemberPromoteResponse), nil
}

func (mockCluster) MemberAddAsLearner(context.Context, []string) (*clientv3.MemberAddResponse, error) {
return new(clientv3.MemberAddResponse), nil
}

var _ clientv3.Cluster = mockCluster{}
Expand Down
2 changes: 1 addition & 1 deletion backend/apid/actions/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package actions
import (
"crypto/tls"

"github.com/coreos/etcd/clientv3"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/backend/store"
"go.etcd.io/etcd/clientv3"
"golang.org/x/net/context"
)

Expand Down
2 changes: 1 addition & 1 deletion backend/apid/actions/version.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package actions

import (
etcdVersion "github.com/coreos/etcd/version"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/version"
etcdVersion "go.etcd.io/etcd/version"
"golang.org/x/net/context"
)

Expand Down
2 changes: 1 addition & 1 deletion backend/apid/apid.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"sync/atomic"
"time"

"github.com/coreos/etcd/clientv3"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.etcd.io/etcd/clientv3"

"github.com/sensu/sensu-go/backend/apid/actions"
"github.com/sensu/sensu-go/backend/apid/graphql"
Expand Down
2 changes: 1 addition & 1 deletion backend/apid/graphql/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package graphql
import (
"strconv"

"github.com/coreos/etcd/etcdserver/etcdserverpb"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/backend/apid/graphql/schema"
"github.com/sensu/sensu-go/graphql"
"go.etcd.io/etcd/etcdserver/etcdserverpb"
)

var _ schema.ClusterHealthFieldResolvers = (*clusterHealthImpl)(nil)
Expand Down
2 changes: 1 addition & 1 deletion backend/apid/graphql/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"strconv"
"testing"

"github.com/coreos/etcd/etcdserver/etcdserverpb"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/backend/apid/graphql/schema"
"github.com/sensu/sensu-go/graphql"
"go.etcd.io/etcd/etcdserver/etcdserverpb"
)

func Test_clusterHealthImpl_Etcd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion backend/apid/routers/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strings"
"time"

"github.com/coreos/etcd/clientv3"
"github.com/gorilla/mux"
"go.etcd.io/etcd/clientv3"
)

const defaultTimeout = 3
Expand Down
2 changes: 1 addition & 1 deletion backend/apid/routers/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"net/http/httptest"
"testing"

"github.com/coreos/etcd/clientv3"
"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/stretchr/testify/mock"
"go.etcd.io/etcd/clientv3"
)

type mockClusterController struct {
Expand Down
5 changes: 3 additions & 2 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"syscall"
"time"

"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/pkg/transport"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/viper"
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/pkg/transport"
"golang.org/x/time/rate"
"google.golang.org/grpc"

Expand Down Expand Up @@ -134,6 +134,7 @@ func newClient(ctx context.Context, config *Config, backend *Backend) (*clientv3
cfg.Discovery = config.EtcdDiscovery
cfg.DiscoverySrv = config.EtcdDiscoverySrv
cfg.Name = config.EtcdName
cfg.LogLevel = config.EtcdLogLevel

// Heartbeat interval
if config.EtcdHeartbeatInterval > 0 {
Expand Down
1 change: 1 addition & 0 deletions backend/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func TestBackendHTTPListener(t *testing.T) {
EtcdClientTLSInfo: tlsInfo,
EtcdPeerTLSInfo: tlsInfo,
EtcdUseEmbeddedClient: true,
EtcdLogLevel: "info",
}
ctx, cancel := context.WithCancel(context.Background())
b, err := Initialize(ctx, cfg)
Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
"time"

"github.com/AlecAivazis/survey"
"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/pkg/transport"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/backend"
"github.com/sensu/sensu-go/backend/etcd"
"github.com/sensu/sensu-go/backend/seeds"
etcdstore "github.com/sensu/sensu-go/backend/store/etcd"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/pkg/transport"
)

const (
Expand Down
6 changes: 5 additions & 1 deletion backend/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const (
flagEtcdAdvertiseClientURLs = "etcd-advertise-client-urls"
flagEtcdHeartbeatInterval = "etcd-heartbeat-interval"
flagEtcdElectionTimeout = "etcd-election-timeout"
flagEtcdLogLevel = "etcd-log-level"

// Etcd TLS flag constants
flagEtcdCertFile = "etcd-cert-file"
Expand Down Expand Up @@ -216,6 +217,7 @@ func StartCommand(initialize InitializeFunc) *cobra.Command {
EtcdMaxRequestBytes: viper.GetUint(flagEtcdMaxRequestBytes),
EtcdHeartbeatInterval: viper.GetUint(flagEtcdHeartbeatInterval),
EtcdElectionTimeout: viper.GetUint(flagEtcdElectionTimeout),
EtcdLogLevel: viper.GetString(flagEtcdLogLevel),
NoEmbedEtcd: viper.GetBool(flagNoEmbedEtcd),
Labels: viper.GetStringMapString(flagLabels),
Annotations: viper.GetStringMapString(flagAnnotations),
Expand Down Expand Up @@ -373,6 +375,7 @@ func handleConfig(cmd *cobra.Command, arguments []string, server bool) error {
viper.SetDefault(flagEtcdMaxRequestBytes, etcd.DefaultMaxRequestBytes)
viper.SetDefault(flagEtcdHeartbeatInterval, etcd.DefaultTickMs)
viper.SetDefault(flagEtcdElectionTimeout, etcd.DefaultElectionMs)
viper.SetDefault(flagEtcdLogLevel, "warn")

if server {
viper.SetDefault(flagNoEmbedEtcd, false)
Expand Down Expand Up @@ -467,7 +470,8 @@ func flagSet(server bool) *pflag.FlagSet {
flagSet.String(flagTrustedCAFile, viper.GetString(flagTrustedCAFile), "TLS CA certificate bundle in PEM format")
flagSet.Bool(flagInsecureSkipTLSVerify, viper.GetBool(flagInsecureSkipTLSVerify), "skip TLS verification (not recommended!)")
flagSet.Bool(flagDebug, false, "enable debugging and profiling features")
flagSet.String(flagLogLevel, viper.GetString(flagLogLevel), "logging level [panic, fatal, error, warn, info, debug]")
flagSet.String(flagLogLevel, viper.GetString(flagLogLevel), "logging level [panic, fatal, error, warn, info, debug, trace]")
flagSet.String(flagEtcdLogLevel, viper.GetString(flagEtcdLogLevel), "etcd logging level [panic, fatal, error, warn, info, debug]")
flagSet.Int(backend.FlagEventdWorkers, viper.GetInt(backend.FlagEventdWorkers), "number of workers spawned for processing incoming events")
flagSet.Int(backend.FlagEventdBufferSize, viper.GetInt(backend.FlagEventdBufferSize), "number of incoming events that can be buffered")
flagSet.Int(backend.FlagKeepalivedWorkers, viper.GetInt(backend.FlagKeepalivedWorkers), "number of workers spawned for processing incoming keepalives")
Expand Down
4 changes: 2 additions & 2 deletions backend/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"time"

"github.com/AlecAivazis/survey"
"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/pkg/transport"
corev2 "github.com/sensu/sensu-go/api/core/v2"
"github.com/sensu/sensu-go/backend"
"github.com/sensu/sensu-go/backend/etcd"
etcdstore "github.com/sensu/sensu-go/backend/store/etcd"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/pkg/transport"
)

const (
Expand Down
3 changes: 3 additions & 0 deletions backend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ type Config struct {
EtcdQuotaBackendBytes int64

TLS *corev2.TLSOptions

LogLevel string
EtcdLogLevel string
}
Loading

0 comments on commit f802cc7

Please sign in to comment.