From cffa1302530eec549083cb5942dd565d47bf7ca1 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Tue, 28 Nov 2017 09:34:03 -0800 Subject: [PATCH] embed: error on zero heartbeat-interval, election-timeout Signed-off-by: Gyu-Ho Lee --- embed/config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/embed/config.go b/embed/config.go index e2be12c9e..0d23d03eb 100644 --- a/embed/config.go +++ b/embed/config.go @@ -409,6 +409,12 @@ func (cfg *Config) Validate() error { return ErrConflictBootstrapFlags } + if cfg.TickMs <= 0 { + return fmt.Errorf("--heartbeat-interval must be >0 (set to %dms)", cfg.TickMs) + } + if cfg.ElectionMs <= 0 { + return fmt.Errorf("--election-timeout must be >0 (set to %dms)", cfg.ElectionMs) + } if 5*cfg.TickMs > cfg.ElectionMs { return fmt.Errorf("--election-timeout[%vms] should be at least as 5 times as --heartbeat-interval[%vms]", cfg.ElectionMs, cfg.TickMs) }