From ec57e1174c29279dc32c8ff14adfdd19b5c16b65 Mon Sep 17 00:00:00 2001 From: ston1th Date: Sat, 10 Apr 2021 14:32:45 +0200 Subject: [PATCH] fixed reload bug --- pkg/haproxy/haproxy.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/haproxy/haproxy.go b/pkg/haproxy/haproxy.go index b299cc5..c7809ac 100644 --- a/pkg/haproxy/haproxy.go +++ b/pkg/haproxy/haproxy.go @@ -27,6 +27,7 @@ type HAProxyManager struct { svc ServiceManager template *template.Template hash []byte + reload bool } func NewHAProxyManager(configFile, service string) (ha *HAProxyManager, err error) { @@ -69,8 +70,10 @@ func (ha *HAProxyManager) updateConfig(ctx context.Context, lbs Config) error { return err } if bytes.Equal(ha.hash, hash) { + ha.reload = false return nil } + ha.reload = true file, err := os.OpenFile(ha.configFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil { return err @@ -92,7 +95,10 @@ func (ha *HAProxyManager) UpdateConfig(ctx context.Context, lbs Config) error { if err != nil { return err } - return ha.svc.Reload(ctx) + if ha.reload { + return ha.svc.Reload(ctx) + } + return nil } func (ha *HAProxyManager) Start(ctx context.Context) error {