Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Review Comments Addressed ✅

All review feedback has been implemented:

1. Float32 to Int32 Conversion (Comment 2516972762)

  • Updated conversion in populateFromAPI() to properly round float32 percentages to nearest integer
  • Latest update (Comment 2521413270): Changed from int32(rv.Percentage + 0.5) to int32(math.Round(float64(rv.Percentage))) for explicit rounding semantics and better edge case handling

2. Version Check for Required Versions (Comment 2517041678)

  • Added MinVersionRequiredVersions = version.Must(version.NewVersion("9.1.0")) constant
  • Added SupportsRequiredVersions feature flag to the features struct
  • Updated buildFeatures() to check for 9.1.0+ support
  • Updated convertRequiredVersions() to validate version support and return appropriate error
  • Updated acceptance tests to use minVersionRequiredVersions and skip on older versions

3. Empty Map Clears Upgrades (Comment 2517045478)

  • Fixed convertRequiredVersions() to return empty array (not nil) when required_versions = {}
  • This properly clears any configured automatic upgrades in the API

Changes Summary

Files Modified:

  • internal/fleet/agent_policy/resource.go - Added MinVersionRequiredVersions constant and feature detection
  • internal/fleet/agent_policy/models.go - Added SupportsRequiredVersions to features, improved conversions with math.Round(), added version validation
  • internal/fleet/agent_policy/acc_test.go - Added minVersionRequiredVersions variable and updated test skip conditions

Key Improvements:

  • Uses math.Round() for proper, explicit rounding semantics instead of + 0.5 truncation
  • Version validation ensures feature is only used on 9.1.0+ stacks
  • Empty map {} now properly clears automatic upgrades
  • Tests automatically skip on unsupported versions

All tests pass and linter is happy!

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature] Parameter for AutoUgrade Agent at FleetPolicy</issue_title>
<issue_description>Plan

  • Add a new required_versions set nested attribute to the existing elasticstack_fleet_agent_policy resource.
  • The required_versions nested object should:
    • Contain two attributes:
      • version - A StringAttribute
      • percentage - An Int32Attribute
    • Be a custom type, overriding the Equals behaviour to only compare the value of the version attribute. That is required_versions should not allow multiple elements with the same version.
  • Ensure the new required_versions attribute is consistent with the RequiredVersions field in the Fleet agent policy API.
  • Add new acceptance tests verifying the new attribute behaviour, that required versions can be added, removed, and the percentage of an existing version updated.
  • Make sure to always follow the instructions

Original issue

At big automated Environments it is important to do that with terraform

could looks like this

resource "elasticstack_fleet_agent_policy" "autoagent" {
  name            = "autoagent"
  namespace       = "base"
  description     = "Policy for autoagent"
  sys_monitoring  = true
  required_versions = {
    "version" = {
       "string_value" = "8.19.2"
    }
    "percentage" = {
        "value" = 100
     }
  }
}

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add required versions attribute to fleet policy Add required_versions attribute to fleet_agent_policy for automatic agent upgrades Nov 12, 2025
Copilot AI requested a review from tobio November 12, 2025 04:10
Copilot finished work on behalf of tobio November 12, 2025 04:10
tobio

This comment was marked as resolved.

Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot follow up with the review comments

All review comments have been addressed. Simplified to use MapAttribute structure for better UX and automatic uniqueness. Removed all custom type files. Commit: 8f05705

Copilot AI requested a review from tobio November 12, 2025 04:44
Copilot finished work on behalf of tobio November 12, 2025 04:44
@tobio tobio requested a review from Copilot November 12, 2025 05:59

This comment was marked as outdated.

tobio

This comment was marked as resolved.

Copy link
Contributor Author

Copilot AI commented Nov 12, 2025

@copilot follow up with the review comments.

All review comments addressed in commit e858db4:

  • Float32 to int32 conversion now uses proper rounding
  • Version check added for 9.1.0+ with feature flag validation
  • Empty map now clears upgrades by returning empty array

Copilot AI requested a review from tobio November 12, 2025 06:38
Copilot finished work on behalf of tobio November 12, 2025 06:38
…versions-attribute

* origin/main:
  Extract agent policy test config (#1439)
  chore(deps): update golang:1.25.4 docker digest to e68f6a0 (#1437)
@tobio tobio requested a review from Copilot November 13, 2025 04:42

This comment was marked as resolved.

Copilot finished work on behalf of tobio November 13, 2025 04:55
@tobio tobio marked this pull request as ready for review November 17, 2025 03:57
@tobio tobio requested a review from nick-benoit November 17, 2025 03:57
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] Parameter for AutoUgrade Agent at FleetPolicy

2 participants