server: added duplicate warning-unary-request-duration flag
--warning-unary-request-duration is a duplicate of --experimental-warning-unary-request-duration experimental-warning-unary-request-duration will be removed in v3.7. fixes https://github.com/etcd-io/etcd/issues/13783 Signed-off-by: Bogdan Kanivets <bkanivets@apple.com>
This commit is contained in:

committed by
Benjamin Wang

parent
07a3cfe22e
commit
7e8ebf7727
@ -17,10 +17,12 @@
|
||||
package etcdmain
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"go.etcd.io/etcd/api/v3/version"
|
||||
"go.etcd.io/etcd/client/pkg/v3/logutil"
|
||||
@ -270,7 +272,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. It's already deprecated, and will be decommissioned in v3.7. Use --warning-unary-request-duration instead.")
|
||||
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.")
|
||||
@ -335,6 +338,11 @@ func (cfg *config) parse(arguments []string) error {
|
||||
cfg.ec.V2Deprecation = cconfig.V2_DEPR_DEFAULT
|
||||
}
|
||||
|
||||
cfg.ec.WarningUnaryRequestDuration, perr = cfg.parseWarningUnaryRequestDuration()
|
||||
if perr != nil {
|
||||
return perr
|
||||
}
|
||||
|
||||
// now logger is set up
|
||||
return err
|
||||
}
|
||||
@ -422,3 +430,24 @@ func (cfg *config) validate() error {
|
||||
}
|
||||
return cfg.ec.Validate()
|
||||
}
|
||||
|
||||
func (cfg *config) parseWarningUnaryRequestDuration() (time.Duration, error) {
|
||||
if cfg.ec.ExperimentalWarningUnaryRequestDuration != 0 && cfg.ec.WarningUnaryRequestDuration != 0 {
|
||||
return 0, errors.New(
|
||||
"both --experimental-warning-unary-request-duration and --warning-unary-request-duration flags are set. " +
|
||||
"Use only --warning-unary-request-duration")
|
||||
}
|
||||
|
||||
if cfg.ec.WarningUnaryRequestDuration != 0 {
|
||||
return cfg.ec.WarningUnaryRequestDuration, nil
|
||||
}
|
||||
|
||||
if cfg.ec.ExperimentalWarningUnaryRequestDuration != 0 {
|
||||
cfg.ec.GetLogger().Warn(
|
||||
"--experimental-warning-unary-request-duration is deprecated, and will be decommissioned in v3.7. " +
|
||||
"Use --warning-unary-request-duration instead.")
|
||||
return cfg.ec.ExperimentalWarningUnaryRequestDuration, nil
|
||||
}
|
||||
|
||||
return embed.DefaultWarningUnaryRequestDuration, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user