Skip to content

Commit

Permalink
Improve names and code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
belimawr committed Jul 5, 2024
1 parent 9e5360b commit 60d8618
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ func (h *PolicyChangeHandler) handlePolicyChange(ctx context.Context, c *config.
if err != nil {
return errors.New(err, "could not parse the configuration from the policy", errors.TypeConfig)
}
loggingHasChanged := h.eventLoggingHasChanged(cfg)
if loggingHasChanged {
hasEventLoggingOutputChanged := h.hasEventLoggingOutputChanged(cfg)
if hasEventLoggingOutputChanged {
h.config.Settings.EventLoggingConfig = cfg.Settings.EventLoggingConfig
}

Expand All @@ -329,17 +329,20 @@ func (h *PolicyChangeHandler) handlePolicyChange(ctx context.Context, c *config.
return fmt.Errorf("applying FleetClientConfig: %w", err)
}

if loggingHasChanged {
// The only way to update the logging configuration
// is to re-start the Elastic-Agent
// If the event logging output has changed, we need to
// re-exec the Elastic-Agent to apply the new logging
// output.
// The new logging configuration has already been persisted
// to the disk, the Elastic-Agent will pick it up once it starts.
if hasEventLoggingOutputChanged {
h.coordinator.ReExec(nil)
}

return nil
}

// eventLoggingHasChanged returns true if the output of the event logger has changed
func (p *PolicyChangeHandler) eventLoggingHasChanged(new *configuration.Configuration) bool {
// hasEventLoggingOutputChanged returns true if the output of the event logger has changed
func (p *PolicyChangeHandler) hasEventLoggingOutputChanged(new *configuration.Configuration) bool {
switch {
case p.config.Settings.EventLoggingConfig.ToFiles != new.Settings.EventLoggingConfig.ToFiles:
return true
Expand Down

0 comments on commit 60d8618

Please sign in to comment.