mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge branch 'master' into update
This commit is contained in:
@@ -40,6 +40,26 @@ func (cfg Config) GetLogger() *zap.Logger {
|
||||
// for testing
|
||||
var grpcLogOnce = new(sync.Once)
|
||||
|
||||
func setupGrpcLogging(debug bool, config zap.Config) {
|
||||
grpcLogOnce.Do(func() {
|
||||
// debug true, enable info, warning, error
|
||||
// debug false, only discard info
|
||||
if debug {
|
||||
var gl grpclog.LoggerV2
|
||||
gl, err := logutil.NewGRPCLoggerV2(config)
|
||||
if err == nil {
|
||||
grpclog.SetLoggerV2(gl)
|
||||
}
|
||||
} else {
|
||||
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func SetupGrpcLoggingForTest(debug bool) {
|
||||
setupGrpcLogging(debug, zap.NewDevelopmentConfig())
|
||||
}
|
||||
|
||||
// setupLogging initializes etcd logging.
|
||||
// Must be called after flag parsing or finishing configuring embed.Config.
|
||||
func (cfg *Config) setupLogging() error {
|
||||
@@ -106,19 +126,7 @@ func (cfg *Config) setupLogging() error {
|
||||
c.loggerConfig = &copied
|
||||
c.loggerCore = nil
|
||||
c.loggerWriteSyncer = nil
|
||||
grpcLogOnce.Do(func() {
|
||||
// debug true, enable info, warning, error
|
||||
// debug false, only discard info
|
||||
if cfg.LogLevel == "debug" {
|
||||
var gl grpclog.LoggerV2
|
||||
gl, err = logutil.NewGRPCLoggerV2(copied)
|
||||
if err == nil {
|
||||
grpclog.SetLoggerV2(gl)
|
||||
}
|
||||
} else {
|
||||
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
|
||||
}
|
||||
})
|
||||
setupGrpcLogging(cfg.LogLevel == "debug", copied)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ func (c *RaftCluster) IsReadyToAddVotingMember() bool {
|
||||
|
||||
if nstarted == 1 && nmembers == 2 {
|
||||
// a case of adding a new node to 1-member cluster for restoring cluster data
|
||||
// https://github.com/etcd-io/etcd/blob/master/Documentation/v2/admin_guide.md#restoring-the-cluster
|
||||
// https://github.com/etcd-io/website/blob/master/content/docs/v2/admin_guide.md#restoring-the-cluster
|
||||
c.lg.Debug("number of started member is 1; can accept add member request")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
// Package v2error describes errors in etcd project. When any change happens,
|
||||
// Documentation/v2/errorcode.md needs to be updated correspondingly.
|
||||
// https://github.com/etcd-io/website/blob/master/content/docs/v2/errorcode.md
|
||||
// needs to be updated correspondingly.
|
||||
// To be deprecated in favor of v3 APIs.
|
||||
package v2error
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"go.etcd.io/etcd/pkg/v3/testutil"
|
||||
)
|
||||
@@ -102,7 +101,7 @@ func TestNodeExternClone(t *testing.T) {
|
||||
}
|
||||
|
||||
func sameSlice(a, b []*NodeExtern) bool {
|
||||
ah := (*reflect.SliceHeader)(unsafe.Pointer(&a))
|
||||
bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
|
||||
return *ah == *bh
|
||||
va := reflect.ValueOf(a)
|
||||
vb := reflect.ValueOf(b)
|
||||
return va.Len() == vb.Len() && va.Pointer() == vb.Pointer()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: etcdserver/api/v3election/v3electionpb/v3election.proto
|
||||
// source: server/etcdserver/api/v3election/v3electionpb/v3election.proto
|
||||
|
||||
/*
|
||||
Package v3electionpb is a reverse proxy.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: etcdserver/api/v3lock/v3lockpb/v3lock.proto
|
||||
// source: server/etcdserver/api/v3lock/v3lockpb/v3lock.proto
|
||||
|
||||
/*
|
||||
Package v3lockpb is a reverse proxy.
|
||||
|
||||
@@ -419,6 +419,13 @@ func openWALFiles(lg *zap.Logger, dirpath string, names []string, nameIndex int,
|
||||
// TODO: detect not-last-snap error.
|
||||
// TODO: maybe loose the checking of match.
|
||||
// After ReadAll, the WAL will be ready for appending new records.
|
||||
//
|
||||
// ReadAll suppresses WAL entries that got overridden (i.e. a newer entry with the same index
|
||||
// exists in the log). Such a situation can happen in cases described in figure 7. of the
|
||||
// RAFT paper (http://web.stanford.edu/~ouster/cgi-bin/papers/raft-atc14.pdf).
|
||||
//
|
||||
// ReadAll may return uncommitted yet entries, that are subject to be overriden.
|
||||
// Do not apply entries that have index > state.commit, as they are subject to change.
|
||||
func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb.Entry, err error) {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
@@ -443,6 +450,7 @@ func (w *WAL) ReadAll() (metadata []byte, state raftpb.HardState, ents []raftpb.
|
||||
// return error before append call causes runtime panic
|
||||
return nil, state, nil, ErrSliceOutOfRange
|
||||
}
|
||||
// The line below is potentially overriding some 'uncommitted' entries.
|
||||
ents = append(ents[:up], e)
|
||||
}
|
||||
w.enti = e.Index
|
||||
|
||||
Reference in New Issue
Block a user