Skip to content

Commit

Permalink
[Elastic Agent] Update path from policy change for Kibana connection. (
Browse files Browse the repository at this point in the history
…elastic#21804)

* Update path from policy change for kibana connection.

* Add changelog.
  • Loading branch information
blakerouse authored Oct 14, 2020
1 parent de88c55 commit 116d767
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 116d767

Please sign in to comment.