From cd53120cd7496c21892494c27f234ef1d3623081 Mon Sep 17 00:00:00 2001 From: John Murret Date: Mon, 12 Dec 2022 12:24:39 -0700 Subject: [PATCH] agent: Fix assignment of error when auto-reloading cert and key file changes. (#15769) * Adding the setting of errors missing in config file watcher code in agent. * add changelog --- .changelog/15769.txt | 3 +++ agent/agent.go | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .changelog/15769.txt diff --git a/.changelog/15769.txt b/.changelog/15769.txt new file mode 100644 index 0000000000..f8fc27a28f --- /dev/null +++ b/.changelog/15769.txt @@ -0,0 +1,3 @@ +```release-note:bug +agent: Fix assignment of error when auto-reloading cert and key file changes. +``` diff --git a/agent/agent.go b/agent/agent.go index 52d799e7dd..be65616368 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "encoding/json" "fmt" - "github.com/hashicorp/consul/proto/pboperator" "io" "net" "net/http" @@ -18,6 +17,8 @@ import ( "sync" "time" + "github.com/hashicorp/consul/proto/pboperator" + "github.com/armon/go-metrics" "github.com/armon/go-metrics/prometheus" "github.com/hashicorp/go-connlimit" @@ -4026,13 +4027,13 @@ func (a *Agent) reloadConfig(autoReload bool) error { {a.config.TLS.HTTPS, newCfg.TLS.HTTPS}, } { if f.oldCfg.KeyFile != f.newCfg.KeyFile { - a.configFileWatcher.Replace(f.oldCfg.KeyFile, f.newCfg.KeyFile) + err = a.configFileWatcher.Replace(f.oldCfg.KeyFile, f.newCfg.KeyFile) if err != nil { return err } } if f.oldCfg.CertFile != f.newCfg.CertFile { - a.configFileWatcher.Replace(f.oldCfg.CertFile, f.newCfg.CertFile) + err = a.configFileWatcher.Replace(f.oldCfg.CertFile, f.newCfg.CertFile) if err != nil { return err }