From 1edbdfcdc5f5db23c09d57b42ed77f6634481046 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Tue, 7 May 2019 13:21:22 -0400 Subject: [PATCH 1/2] fix backward compatibility with client config --- pkg/promtail/client/config.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/pkg/promtail/client/config.go b/pkg/promtail/client/config.go index bcc3d04bd7013..9e960be30b9aa 100644 --- a/pkg/promtail/client/config.go +++ b/pkg/promtail/client/config.go @@ -37,17 +37,24 @@ func (c *Config) RegisterFlags(flags *flag.FlagSet) { // UnmarshalYAML implement Yaml Unmarshaler func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { type raw Config - // force sane defaults. - cfg := raw{ - BackoffConfig: util.BackoffConfig{ - MaxBackoff: 5 * time.Second, - MaxRetries: 5, - MinBackoff: 100 * time.Millisecond, - }, - BatchSize: 100 * 1024, - BatchWait: 1 * time.Second, - Timeout: 10 * time.Second, + var cfg raw + if c.URL.URL != nil { + // we used flags to set that value, it's the only way before + cfg = raw(*c) + } else { + // force sane defaults. + cfg = raw{ + BackoffConfig: util.BackoffConfig{ + MaxBackoff: 5 * time.Second, + MaxRetries: 5, + MinBackoff: 100 * time.Millisecond, + }, + BatchSize: 100 * 1024, + BatchWait: 1 * time.Second, + Timeout: 10 * time.Second, + } } + if err := unmarshal(&cfg); err != nil { return err } From 2766ed40fced9f3e0690c4b3b1882485b34557d2 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Tue, 7 May 2019 13:33:34 -0400 Subject: [PATCH 2/2] fix comment --- pkg/promtail/client/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/promtail/client/config.go b/pkg/promtail/client/config.go index 9e960be30b9aa..5bd38d2f9bec1 100644 --- a/pkg/promtail/client/config.go +++ b/pkg/promtail/client/config.go @@ -39,7 +39,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error { type raw Config var cfg raw if c.URL.URL != nil { - // we used flags to set that value, it's the only way before + // we used flags to set that value, which already has sane default. cfg = raw(*c) } else { // force sane defaults.