From b273ee1f8aca76182b99f73c7014fe93378dbe1d Mon Sep 17 00:00:00 2001 From: Blake Rouse Date: Thu, 13 May 2021 12:28:31 -0400 Subject: [PATCH] Handle case where policy doesn't contain Fleet connection information. --- .../actions/handlers/handler_action_policy_change.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/x-pack/elastic-agent/pkg/agent/application/pipeline/actions/handlers/handler_action_policy_change.go b/x-pack/elastic-agent/pkg/agent/application/pipeline/actions/handlers/handler_action_policy_change.go index a82b39b6763..d05be4a57b5 100644 --- a/x-pack/elastic-agent/pkg/agent/application/pipeline/actions/handlers/handler_action_policy_change.go +++ b/x-pack/elastic-agent/pkg/agent/application/pipeline/actions/handlers/handler_action_policy_change.go @@ -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 {