Skip to content

Add cancelations to policy monitor dispatches#5111

Merged
michel-laterman merged 6 commits intoelastic:mainfrom
michel-laterman:cancel-policy-dispatch
Jul 10, 2025
Merged

Add cancelations to policy monitor dispatches#5111
michel-laterman merged 6 commits intoelastic:mainfrom
michel-laterman:cancel-policy-dispatch

Conversation

@michel-laterman
Copy link
Contributor

@michel-laterman michel-laterman commented Jul 7, 2025

What is the problem this PR solves?

Add support for canceling dispatching policies to agents. This occurs whenever a new policy is recieved by the policy monitor. This allows the monitor to stop sending revision N when N+1 is recieved.

How does this PR solve the problem?

Policy dispatches now occur in a goroutine. If a new doc is detected by the dispatch, the routine is canceled and another is launched.

Design Checklist

  • I have ensured my design is stateless and will work when multiple fleet-server instances are behind a load balancer.
  • I have or intend to scale test my changes, ensuring it will work reliably with 100K+ agents connected.
  • I have included fail safe mechanisms to limit the load on fleet-server: rate limiting, circuit breakers, caching, load shedding, etc.

Checklist

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool

Related issues

Add support for canceling dispatching policies to agents. This occurs
whenever a new policy is recieved by the policy monitor. This allows the
monitor to stop sending revision N when N+1 is recieved.
@michel-laterman michel-laterman requested a review from a team as a code owner July 7, 2025 18:38
@michel-laterman michel-laterman added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Jul 7, 2025
@prodsecmachine
Copy link

prodsecmachine commented Jul 7, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@mergify
Copy link
Contributor

mergify bot commented Jul 7, 2025

This pull request does not have a backport label. Could you fix it @michel-laterman? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@michel-laterman
Copy link
Contributor Author

buildkite run perf-tests

@michel-laterman michel-laterman marked this pull request as draft July 7, 2025 19:45
@michel-laterman
Copy link
Contributor Author

buildkite run perf-tests

@michel-laterman michel-laterman marked this pull request as ready for review July 8, 2025 00:13
Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Overall this looks good and is a nice improvement. See inline comment about checking the error type.

Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Looks good.

@elastic-sonarqube
Copy link

@michel-laterman michel-laterman merged commit e747bc1 into elastic:main Jul 10, 2025
9 checks passed
@michel-laterman michel-laterman deleted the cancel-policy-dispatch branch July 10, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants