From fd9fe462abc09cb0a473976e31c5e9976420fb5a Mon Sep 17 00:00:00 2001 From: James Rasell Date: Fri, 13 May 2022 09:28:43 +0200 Subject: [PATCH] agent: fix panic when logging about protocol version config use. (#12962) The log line comes before the agent logger has been setup, therefore we need to use the UI logging to avoid panic. --- .changelog/12962.txt | 3 +++ command/agent/command.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .changelog/12962.txt diff --git a/.changelog/12962.txt b/.changelog/12962.txt new file mode 100644 index 00000000000..d8a2e2c81a8 --- /dev/null +++ b/.changelog/12962.txt @@ -0,0 +1,3 @@ +```release-note:bug +agent: fixed a panic on startup when the `server.protocol_version` config parameter was set +``` diff --git a/command/agent/command.go b/command/agent/command.go index 137eb08ef5d..880cb0a92e5 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -441,7 +441,7 @@ func (c *Command) IsValidConfig(config, cmdConfig *Config) bool { // ProtocolVersion has never been used. Warn if it is set as someone // has probably made a mistake. if config.Server.ProtocolVersion != 0 { - c.agent.logger.Warn("Please remove deprecated protocol_version field from config.") + c.Ui.Warn("Please remove deprecated protocol_version field from config.") } return true