From 5addd4c717d8cd5c2e8f6c12f99991ed6fcdaccd Mon Sep 17 00:00:00 2001 From: Bogdan Kanivets Date: Thu, 1 Sep 2022 11:00:18 -0700 Subject: [PATCH] server: removed 'experimental' from warning-unary-request-duration flag experimental-warning-unary-request-duration flag is still present for compatibility until next version, but all vars are updated fixes https://github.com/etcd-io/etcd/issues/13783 Signed-off-by: Bogdan Kanivets --- server/embed/config.go | 7 +++-- server/embed/etcd.go | 2 +- server/etcdmain/config.go | 3 +- server/etcdmain/help.go | 6 ++-- tests/e2e/warning_logging_test.go | 50 +++++++++++++++++++++++++++++++ tests/framework/e2e/cluster.go | 12 +++++--- 6 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 tests/e2e/warning_logging_test.go diff --git a/server/embed/config.go b/server/embed/config.go index 587cf642b31f..061d2fae00c4 100644 --- a/server/embed/config.go +++ b/server/embed/config.go @@ -342,8 +342,11 @@ type Config struct { // ExperimentalBootstrapDefragThresholdMegabytes is the minimum number of megabytes needed to be freed for etcd server to // consider running defrag during bootstrap. Needs to be set to non-zero value to take effect. ExperimentalBootstrapDefragThresholdMegabytes uint `json:"experimental-bootstrap-defrag-threshold-megabytes"` - // ExperimentalWarningUnaryRequestDuration is the time duration after which a warning is generated if applying + // WarningUnaryRequestDuration is the time duration after which a warning is generated if applying // unary request takes more time than this value. + WarningUnaryRequestDuration time.Duration `json:"warning-unary-request-duration"` + // ExperimentalWarningUnaryRequestDuration is the time duration after which a warning is generated if applying + // unary request takes more time than this value. Duplicate of WarningUnaryRequestDuration for compatibility ExperimentalWarningUnaryRequestDuration time.Duration `json:"experimental-warning-unary-request-duration"` // ExperimentalMaxLearners sets a limit to the number of learner members that can exist in the cluster membership. ExperimentalMaxLearners int `json:"experimental-max-learners"` @@ -474,7 +477,7 @@ func NewConfig() *Config { MaxConcurrentStreams: DefaultMaxConcurrentStreams, ExperimentalWarningApplyDuration: DefaultWarningApplyDuration, - ExperimentalWarningUnaryRequestDuration: DefaultWarningUnaryRequestDuration, + WarningUnaryRequestDuration: DefaultWarningUnaryRequestDuration, GRPCKeepAliveMinTime: DefaultGRPCKeepAliveMinTime, GRPCKeepAliveInterval: DefaultGRPCKeepAliveInterval, diff --git a/server/embed/etcd.go b/server/embed/etcd.go index 88178afc67a9..e3863ee62bc9 100644 --- a/server/embed/etcd.go +++ b/server/embed/etcd.go @@ -217,7 +217,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) { WatchProgressNotifyInterval: cfg.ExperimentalWatchProgressNotifyInterval, DowngradeCheckTime: cfg.ExperimentalDowngradeCheckTime, WarningApplyDuration: cfg.ExperimentalWarningApplyDuration, - WarningUnaryRequestDuration: cfg.ExperimentalWarningUnaryRequestDuration, + WarningUnaryRequestDuration: cfg.WarningUnaryRequestDuration, ExperimentalMemoryMlock: cfg.ExperimentalMemoryMlock, ExperimentalTxnModeWriteWithSharedBuffer: cfg.ExperimentalTxnModeWriteWithSharedBuffer, ExperimentalBootstrapDefragThresholdMegabytes: cfg.ExperimentalBootstrapDefragThresholdMegabytes, diff --git a/server/etcdmain/config.go b/server/etcdmain/config.go index b14191a95cb8..fdd4d880cf3c 100644 --- a/server/etcdmain/config.go +++ b/server/etcdmain/config.go @@ -270,7 +270,8 @@ func newConfig() *config { fs.DurationVar(&cfg.ec.ExperimentalWatchProgressNotifyInterval, "experimental-watch-progress-notify-interval", cfg.ec.ExperimentalWatchProgressNotifyInterval, "Duration of periodic watch progress notifications.") fs.DurationVar(&cfg.ec.ExperimentalDowngradeCheckTime, "experimental-downgrade-check-time", cfg.ec.ExperimentalDowngradeCheckTime, "Duration of time between two downgrade status check.") fs.DurationVar(&cfg.ec.ExperimentalWarningApplyDuration, "experimental-warning-apply-duration", cfg.ec.ExperimentalWarningApplyDuration, "Time duration after which a warning is generated if request takes more time.") - fs.DurationVar(&cfg.ec.ExperimentalWarningUnaryRequestDuration, "experimental-warning-unary-request-duration", cfg.ec.ExperimentalWarningUnaryRequestDuration, "Time duration after which a warning is generated if a unary request takes more time.") + fs.DurationVar(&cfg.ec.WarningUnaryRequestDuration, "warning-unary-request-duration", cfg.ec.WarningUnaryRequestDuration, "Time duration after which a warning is generated if a unary request takes more time.") + fs.DurationVar(&cfg.ec.ExperimentalWarningUnaryRequestDuration, "experimental-warning-unary-request-duration", cfg.ec.ExperimentalWarningUnaryRequestDuration, "Time duration after which a warning is generated if a unary request takes more time. Duplicate of --warning-unary-request-duration") fs.BoolVar(&cfg.ec.ExperimentalMemoryMlock, "experimental-memory-mlock", cfg.ec.ExperimentalMemoryMlock, "Enable to enforce etcd pages (in particular bbolt) to stay in RAM.") fs.BoolVar(&cfg.ec.ExperimentalTxnModeWriteWithSharedBuffer, "experimental-txn-mode-write-with-shared-buffer", true, "Enable the write transaction to use a shared buffer in its readonly check operations.") fs.UintVar(&cfg.ec.ExperimentalBootstrapDefragThresholdMegabytes, "experimental-bootstrap-defrag-threshold-megabytes", 0, "Enable the defrag during etcd server bootstrap on condition that it will free at least the provided threshold of disk space. Needs to be set to non-zero value to take effect.") diff --git a/server/etcdmain/help.go b/server/etcdmain/help.go index a7f569a8e668..14546c991b61 100644 --- a/server/etcdmain/help.go +++ b/server/etcdmain/help.go @@ -227,7 +227,9 @@ Logging: --enable-log-rotation 'false' Enable log rotation of a single log-outputs file target. --log-rotation-config-json '{"maxsize": 100, "maxage": 0, "maxbackups": 0, "localtime": false, "compress": false}' - Configures log rotation if enabled with a JSON logger config. MaxSize(MB), MaxAge(days,0=no limit), MaxBackups(0=no limit), LocalTime(use computers local time), Compress(gzip)". + Configures log rotation if enabled with a JSON logger config. MaxSize(MB), MaxAge(days,0=no limit), MaxBackups(0=no limit), LocalTime(use computers local time), Compress(gzip)". + --warning-unary-request-duration '300ms' + Set time duration after which a warning is logged if a unary request takes more than this duration. Experimental distributed tracing: --experimental-enable-distributed-tracing 'false' @@ -261,7 +263,7 @@ Experimental feature: --experimental-bootstrap-defrag-threshold-megabytes Enable the defrag during etcd server bootstrap on condition that it will free at least the provided threshold of disk space. Needs to be set to non-zero value to take effect. --experimental-warning-unary-request-duration '300ms' - Set time duration after which a warning is generated if a unary request takes more than this duration. + Set time duration after which a warning is generated if a unary request takes more than this duration. Duplicate of --warning-unary-request-duration for compatibility. --experimental-max-learners '1' Set the max number of learner members allowed in the cluster membership. --experimental-wait-cluster-ready-timeout '5s' diff --git a/tests/e2e/warning_logging_test.go b/tests/e2e/warning_logging_test.go new file mode 100644 index 000000000000..85c36ba3cc94 --- /dev/null +++ b/tests/e2e/warning_logging_test.go @@ -0,0 +1,50 @@ +// Copyright 2022 The etcd Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package e2e + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "go.etcd.io/etcd/tests/v3/framework/config" + "go.etcd.io/etcd/tests/v3/framework/e2e" +) + +func TestWarningApplyDuration(t *testing.T) { + e2e.BeforeTest(t) + + epc, err := e2e.NewEtcdProcessCluster(context.TODO(), t, &e2e.EtcdProcessClusterConfig{ + ClusterSize: 1, + //Set very small duration to trigger warning + WarningUnaryRequestDuration: time.Microsecond, + }) + if err != nil { + t.Fatalf("could not start etcd process cluster (%v)", err) + } + t.Cleanup(func() { + if errC := epc.Close(); errC != nil { + t.Fatalf("error closing etcd processes (%v)", errC) + } + }) + + cc := e2e.NewEtcdctl(epc.Cfg, epc.EndpointsV3()) + err = cc.Put(context.TODO(), "foo", "bar", config.PutOptions{}) + assert.NoError(t, err, "error on put") + + // verify warning + e2e.AssertProcessLogs(t, epc.Procs[0], "request stats") +} diff --git a/tests/framework/e2e/cluster.go b/tests/framework/e2e/cluster.go index 5096df714f51..6b18bcd1bf4e 100644 --- a/tests/framework/e2e/cluster.go +++ b/tests/framework/e2e/cluster.go @@ -178,10 +178,11 @@ type EtcdProcessClusterConfig struct { DiscoveryToken string LogLevel string - MaxConcurrentStreams uint32 // default is math.MaxUint32 - CorruptCheckTime time.Duration - CompactHashCheckEnabled bool - CompactHashCheckTime time.Duration + MaxConcurrentStreams uint32 // default is math.MaxUint32 + CorruptCheckTime time.Duration + CompactHashCheckEnabled bool + CompactHashCheckTime time.Duration + WarningUnaryRequestDuration time.Duration } // NewEtcdProcessCluster launches a new cluster from etcd processes, returning @@ -388,6 +389,9 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in if cfg.CompactHashCheckTime != 0 { args = append(args, "--experimental-compact-hash-check-time", cfg.CompactHashCheckTime.String()) } + if cfg.WarningUnaryRequestDuration != 0 { + args = append(args, "--warning-unary-request-duration", cfg.WarningUnaryRequestDuration.String()) + } return &EtcdServerProcessConfig{ lg: cfg.Logger,