Skip to content

Commit

Permalink
[Elastic Agent] Handle case where policy doesn't contain Fleet connec…
Browse files Browse the repository at this point in the history
…tion information (#25707)

* Handle case where policy doesn't contain Fleet connection information.

* Add changelog entry.
  • Loading branch information
blakerouse authored May 14, 2021
1 parent 52f2265 commit e86109e
Show file tree
Hide file tree
Showing 2 changed files with 9 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 @@ -65,6 +65,7 @@
- Fixed Elastic Agent: expecting Dict and received *transpiler.Key for '0' {issue}24453[24453]
- Fix AckBatch to do nothing when no actions passed {pull}25562[25562]
- Add error log entry when listener creation fails {issue}23483[23482]
- Handle case where policy doesn't contain Fleet connection information {pull}25707[25707]

==== New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ func (h *PolicyChange) handleFleetServerHosts(ctx context.Context, c *config.Con
if len(h.setters) == 0 {
return nil
}
data, err := c.ToMapStr()
if err != nil {
return errors.New(err, "could not convert the configuration from the policy", errors.TypeConfig)
}
if _, ok := data["fleet"]; !ok {
// no fleet information in the configuration (skip checking client)
return nil
}

cfg, err := configuration.NewFromConfig(c)
if err != nil {
Expand Down

0 comments on commit e86109e

Please sign in to comment.