From 116d7670b9bfe73477a5c0c8883ae7dabd31a1d2 Mon Sep 17 00:00:00 2001 From: Blake Rouse Date: Wed, 14 Oct 2020 13:03:44 -0400 Subject: [PATCH] [Elastic Agent] Update path from policy change for Kibana connection. (#21804) * Update path from policy change for kibana connection. * Add changelog. --- x-pack/elastic-agent/CHANGELOG.next.asciidoc | 1 + .../pkg/agent/application/handler_action_policy_change.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/x-pack/elastic-agent/CHANGELOG.next.asciidoc b/x-pack/elastic-agent/CHANGELOG.next.asciidoc index c2a723d552a..51081c2c7a7 100644 --- a/x-pack/elastic-agent/CHANGELOG.next.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.next.asciidoc @@ -36,4 +36,5 @@ - Add `elastic.agent.id` and `elastic.agent.version` to published events from filebeat and metricbeat {pull}21543[21543] - Add `upgrade` subcommand to perform upgrade of installed Elastic Agent {pull}21425[21425] - Update `fleet.yml` and Kibana hosts when a policy change updates the Kibana hosts {pull}21599[21599] +- Update `fleet.kibana.path` from a POLICY_CHANGE {pull}21804[21804] - Removed `install-service.ps1` and `uninstall-service.ps1` from Windows .zip packaging {pull}21694[21694] diff --git a/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change.go b/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change.go index 8821700ee74..30a163a7b5e 100644 --- a/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change.go +++ b/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change.go @@ -73,14 +73,17 @@ func (h *handlerPolicyChange) handleKibanaHosts(c *config.Config) (err error) { // only set protocol/hosts as that is all Fleet currently sends prevProtocol := h.config.Fleet.Kibana.Protocol + prevPath := h.config.Fleet.Kibana.Path prevHosts := h.config.Fleet.Kibana.Hosts h.config.Fleet.Kibana.Protocol = cfg.Fleet.Kibana.Protocol + h.config.Fleet.Kibana.Path = cfg.Fleet.Kibana.Path h.config.Fleet.Kibana.Hosts = cfg.Fleet.Kibana.Hosts // rollback on failure defer func() { if err != nil { h.config.Fleet.Kibana.Protocol = prevProtocol + h.config.Fleet.Kibana.Path = prevPath h.config.Fleet.Kibana.Hosts = prevHosts } }() @@ -113,6 +116,9 @@ func kibanaEqual(k1 *kibana.Config, k2 *kibana.Config) bool { if k1.Protocol != k2.Protocol { return false } + if k1.Path != k2.Path { + return false + } sort.Strings(k1.Hosts) sort.Strings(k2.Hosts)