[9.5](backport #7422) [Fleet] Write policy_base_id field at agent enrollment - #7477
Merged
Conversation
Contributor
Author
|
This pull request is now in conflicts. Could you fix it @mergify[bot]? 🙏 |
Contributor
|
@ycombinator Could you help merge this backport? |
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
force-pushed
the
mergify/bp/9.5/pr-7422
branch
from
July 29, 2026 13:41
b2424ba to
37642d4
Compare
ycombinator
approved these changes
Jul 29, 2026
ycombinator
enabled auto-merge (squash)
July 29, 2026 13:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a denormalized
policy_base_idfield written at agent enrollment to enable cheapterm/termsqueries in place of expensive prefix/wildcard queries.Background
Fleet supports version-specific agent policies where
policy_idgets a#major.minorsuffix (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_idfield stores the canonical base ID (suffix stripped), enabling a singleterm: { policy_base_id: "my-policy" }query instead.Changes
internal/pkg/dl/constants.go: AddFieldPolicyBaseID = "policy_base_id"constantinternal/pkg/model/schema.go: AddPolicyBaseID string json:"policy_base_id,omitempty"field to theAgentmodelinternal/pkg/api/handleEnroll.go: SetPolicyBaseID: policyBaseID(policyID)in the agent struct at enrollment; addpolicyBaseIDhelper that strips the#versionsuffixNotes
agent_policy_idvia partial update — no change needed there;policy_base_idtrackspolicy_id, notagent_policy_idupdate_by_queryduring Fleet setup (companion PR: [Fleet] Add policy_base_id field to eliminate prefix/wildcard agent policy queries (B2) kibana#279716)Part of elastic/ingest-dev#8624 (Workstream B2).
This is an automatic backport of pull request #7422 done by Mergify.