-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
managed-agent will periodically call dispatcher.Dispatch #2344
Conversation
🌐 Coverage report
|
While this change will have the desired effect of scheduled actions being dequed and dispatched even when no subsequent actions are received from Fleet Server, I have two concerns/comments:
An alternative design might be for the |
@ycombinator |
case <-t.C: // periodically call the dispatcher to handle scheduled actions. | ||
m.dispatcher.Dispatch(ctx, actionAcker) | ||
t.Reset(dispatchFlushInterval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍. I think this is a slightly better approach because it at least decouples the processing of the dispatcher's action queue from the Fleet Checkin call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can have an even more efficient implementation of "when to re-dispatch" by deciding to process the action queue either:
- when new actions are added to it (already handled by the
case
below this line), or - just-in-time for the next scheduled action (by looking at the next scheduled action's time and setting up a
time.Timer
accordingly) rather than on a fixed interval like we are doing here. But we can make this change in a separate PR if it's too complicated for this one.
Just to confirm, the check in requests do use long polling but fleet-server is responsible for holding the request open. The short 1 - 1.5s request durations on the agent only come into play when the server has terminated the long poll request. Big thanks to @ycombinator for suggesting that we decouple the execution of scheduled actions from the checkin period regardless. This is a much better approach and avoids the possibility of hard to find side effects as we start increasing the checkin duration significantly for scalability reasons (from 5 to 30 minutes). |
* Allow fleet-gateway to return empty action lists * Change fix to periodically call the dispatcher * Fix comment * Fix changelog, add unit tests (cherry picked from commit 2c8877e)
* Allow fleet-gateway to return empty action lists * Change fix to periodically call the dispatcher * Fix comment * Fix changelog, add unit tests (cherry picked from commit 2c8877e)
* Allow fleet-gateway to return empty action lists * Change fix to periodically call the dispatcher * Fix comment * Fix changelog, add unit tests (cherry picked from commit 2c8877e) Co-authored-by: Michel Laterman <[email protected]>
* Allow fleet-gateway to return empty action lists * Change fix to periodically call the dispatcher * Fix comment * Fix changelog, add unit tests (cherry picked from commit 2c8877e) Co-authored-by: Michel Laterman <[email protected]>
What does this PR do?
Add a timer in the goroutine that passes actions from fleet-gateway to the dispatcher that calls dispatch with no actions.
Why is it important?
Scheduled actions are only ran when the
dispatch.Dispatch()
method is called.Currently this method is only called when an action list is received from the fleet-gateway.
If the gateway does not send any actions after a checkin, the dispatcher is not called and scheduled actions are not checked (until a new action is received).
Checklist
I have made corresponding change to the default configuration files./changelog/fragments
using the changelog toolHow to test this PR locally
Related issues