From 080d0074572a22273eed0499bf11428b8fc0f0b2 Mon Sep 17 00:00:00 2001 From: Violet Hynes Date: Fri, 13 Jan 2023 09:49:36 -0500 Subject: [PATCH] VAULT-12542 Add info encouraging users to upgrade if agent version is different to server (#18684) * VAULT-12542 Add info encouraging users to upgrade if agent version is different to server * VAULT-12542 Changelog * VAULT-12542 Language update --- changelog/18684.txt | 3 +++ command/agent.go | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelog/18684.txt diff --git a/changelog/18684.txt b/changelog/18684.txt new file mode 100644 index 000000000000..803c7cc571f9 --- /dev/null +++ b/changelog/18684.txt @@ -0,0 +1,3 @@ +```release-note:improvement +agent: Add note in logs when starting Vault Agent indicating if the version differs to the Vault Server. +``` diff --git a/command/agent.go b/command/agent.go index 75ae5acdc45e..4fbcd6ba278b 100644 --- a/command/agent.go +++ b/command/agent.go @@ -250,7 +250,7 @@ func (c *AgentCommand) Run(args []string) int { return 0 } - // Ignore any setting of agent's address. This client is used by the agent + // Ignore any setting of Agent's address. This client is used by the Agent // to reach out to Vault. This should never loop back to agent. c.flagAgentAddress = "" client, err := c.Client() @@ -261,6 +261,17 @@ func (c *AgentCommand) Run(args []string) int { return 1 } + serverHealth, err := client.Sys().Health() + if err == nil { + // We don't exit on error here, as this is not worth stopping Agent over + serverVersion := serverHealth.Version + agentVersion := version.GetVersion().VersionNumber() + if serverVersion != agentVersion { + c.UI.Info("==> Note: Vault Agent version does not match Vault server version. " + + fmt.Sprintf("Vault Agent version: %s, Vault server version: %s", agentVersion, serverVersion)) + } + } + // ctx and cancelFunc are passed to the AuthHandler, SinkServer, and // TemplateServer that periodically listen for ctx.Done() to fire and shut // down accordingly.