Skip to content

Conversation

@dimuon
Copy link
Contributor

@dimuon dimuon commented Dec 11, 2025

Fixes #1116

Plus some follow-up fixes for #984

@dimuon dimuon marked this pull request as ready for review December 12, 2025 15:13
@dimuon dimuon requested review from Copilot and tobio December 12, 2025 15:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for configuring advanced settings in Fleet agent policies, enabling control over agent logging, resource limits, and download behavior. The implementation follows the established pattern for advanced monitoring options and includes comprehensive version validation.

Key changes:

  • Introduces advanced_settings attribute to the agent policy resource with 10 configurable fields
  • Implements version checking to ensure the feature is only used with Elasticsearch 8.17.0+
  • Updates the API conversion logic to align with the behavior for advanced monitoring options (sending default values to allow resets)

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/fleet/agent_policy/schema.go Defines the advanced_settings schema with logging, CPU limit, and download configuration fields; adds UseStateForUnknown plan modifiers to existing attributes
internal/fleet/agent_policy/models.go Implements advancedSettingsModel struct, API conversion methods, and populates state from API responses
internal/fleet/agent_policy/resource.go Adds minimum version constant (8.17.0) and feature detection for advanced settings support
internal/fleet/agent_policy/models_test.go Contains unit tests for advanced settings conversion and updates existing tests to validate sending default values
internal/fleet/agent_policy/version_test.go Validates version checking behavior for advanced settings in create and update operations
internal/fleet/agent_policy/acc_test.go Provides end-to-end acceptance tests covering creation, updates, removal, and default value scenarios
internal/fleet/agent_policy/testdata/* Terraform configuration files for acceptance test scenarios
docs/resources/fleet_agent_policy.md Documents the new advanced_settings attribute and its nested fields
CHANGELOG.md Records the feature addition

@dimuon dimuon requested a review from nick-benoit December 12, 2025 15:14
Copy link
Member

@tobio tobio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

// populateAdvancedSettingsFromAPI populates the advanced settings from API response
func (model *agentPolicyModel) populateAdvancedSettingsFromAPI(ctx context.Context, data *kbapi.AgentPolicy) diag.Diagnostics {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is getting pretty big. WDYT about pulling these out to models_advanced_settings.go etc?

settings := advancedSettingsModel{}

// Logging level
if data.AdvancedSettings.AgentLoggingLevel != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we open an issue in the Kibana repo to fixup the typing in the openapi spec for these fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Configure advanced settings (logging level, CPU limits) in Agent policies

2 participants