Skip to content

[9.5](backport #7422) [Fleet] Write policy_base_id field at agent enrollment - #7477

Merged
ycombinator merged 1 commit into
9.5from
mergify/bp/9.5/pr-7422
Jul 29, 2026
Merged

[9.5](backport #7422) [Fleet] Write policy_base_id field at agent enrollment#7477
ycombinator merged 1 commit into
9.5from
mergify/bp/9.5/pr-7422

Conversation

@mergify

@mergify mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a denormalized policy_base_id field written at agent enrollment to enable cheap term/terms queries in place of expensive prefix/wildcard queries.

Background

Fleet supports version-specific agent policies where policy_id gets a #major.minor suffix (e.g. my-policy#9.2). Querying agents by policy currently requires:

{ "bool": { "should": [{ "term": { "policy_id": "my-policy" } }, { "prefix": { "policy_id": "my-policy#" } }] } }

The policy_base_id field stores the canonical base ID (suffix stripped), enabling a single term: { policy_base_id: "my-policy" } query instead.

Changes

  • internal/pkg/dl/constants.go: Add FieldPolicyBaseID = "policy_base_id" constant
  • internal/pkg/model/schema.go: Add PolicyBaseID string json:"policy_base_id,omitempty" field to the Agent model
  • internal/pkg/api/handleEnroll.go: Set PolicyBaseID: policyBaseID(policyID) in the agent struct at enrollment; add policyBaseID helper that strips the #version suffix

Notes

Part of elastic/ingest-dev#8624 (Workstream B2).


This is an automatic backport of pull request #7422 done by Mergify.

@mergify mergify Bot added the backport label Jul 28, 2026
@mergify
mergify Bot requested a review from a team as a code owner July 28, 2026 15:48
@mergify
mergify Bot requested review from lorienhu and samuelvl July 28, 2026 15:48
@github-actions github-actions Bot added Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Jul 28, 2026
@mergify

mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

This pull request is now in conflicts. Could you fix it @mergify[bot]? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b mergify/bp/9.5/pr-7422 upstream/mergify/bp/9.5/pr-7422
git merge upstream/9.5
git push upstream mergify/bp/9.5/pr-7422

@juliaElastic

Copy link
Copy Markdown
Contributor

@ycombinator Could you help merge this backport?

ycombinator
ycombinator previously approved these changes Jul 29, 2026
* Add FieldPolicyBaseID constant

* Add PolicyBaseID field to Agent model

* Write policy_base_id at agent enrollment

* Add policy_base_id to agent schema (source for go generate)

* Regenerate schema.go (go generate ./...)

* chore: add Elastic license headers to generated Go files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: add unit tests for policyBaseID

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: add changelog fragment for policy_base_id enrollment feature

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: set policy_base_id in re-enrollment UpdateFields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: assert policy_base_id written in re-enrollment UpdateFields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit 761825e)
@ycombinator
ycombinator enabled auto-merge (squash) July 29, 2026 13:43
@ycombinator
ycombinator merged commit 36ad1ae into 9.5 Jul 29, 2026
12 checks passed
@ycombinator
ycombinator deleted the mergify/bp/9.5/pr-7422 branch July 29, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants