Skip to content
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

Add start_time and minimum_execution_duration fields to actions #1381

Merged
merged 9 commits into from
May 24, 2022

Conversation

michel-laterman
Copy link
Contributor

@michel-laterman michel-laterman commented Apr 22, 2022

What is the problem this PR solves?

Fleet-server should be able to inform agents of actions that are scheduled to start at a later time.
Fleet-server should also be able to spread the start time that different agents within the window of start:expiration.

This should help with ensuring that hundreds (or thousands) of agents don't exhaust the network when upgrading (for instance).

How does this PR solve the problem?

Add start_time and minimum_execution_duration fields to action
definition. When start_time and expiration are defined the fleet-server
will schedule agent actions within [start:expiration], if the
minimum_execution_duration s defined the scheduling range is
[start:expiration-minimum_execution_duration]. An agent's scheduled time
within the range depends on the agent id's position within the list.

How to test this PR locally

See testing in elastic/elastic-agent#419

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.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

@michel-laterman michel-laterman added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Apr 22, 2022
@elasticmachine
Copy link
Collaborator

elasticmachine commented Apr 22, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-05-24T02:17:56.953+0000

  • Duration: 11 min 36 sec

Test stats 🧪

Test Results
Failed 0
Passed 304
Skipped 1
Total 305

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@mergify
Copy link
Contributor

mergify bot commented Apr 22, 2022

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-v/d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Apr 22, 2022
@michel-laterman michel-laterman force-pushed the rolling-update branch 2 times, most recently from e9093e0 to 4f68eac Compare April 25, 2022 17:43
Add start_time and minimum_execution_duration fields to action
definition. When start_time and expiration are defined the fleet-server
will schedule agent actions within [start:expiration], if the
minimum_execution_duration s defined the scheduling range is
[start:expiration-minimum_execution_duration]. An agent's scheduled time
within the range depends on the agent id's position within the list.
@michel-laterman michel-laterman marked this pull request as ready for review April 25, 2022 23:52
@michel-laterman michel-laterman requested a review from a team as a code owner April 25, 2022 23:52
Copy link
Member

@AndersonQ AndersonQ left a comment

Choose a reason for hiding this comment

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

I left a question. But LGTM

internal/pkg/action/dispatcher.go Outdated Show resolved Hide resolved
@ph
Copy link
Contributor

ph commented Apr 26, 2022

requires elastic/elasticsearch#8616 right?

if start == "" || exp == "" {
return ""
}
startTS, err := time.Parse(time.RFC3339, start) // TODO what format does a date-time string use?
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we move the validation to the original unpack of the action instead? If there is an unserialization error this means that the contract between fleet and fleet-server is broken. I don't think we should even try to process that event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To summarize a quick conversation. We should catch this on the json unpacking, however the model.Action is generated by elastic/go-json-schema-generate which does not support mapping a (json) string/date-time to go's time.Time. The upstream generator we forked our code from has this as an open issue a-h/generate#69 so if we get around to it we should contribute it back

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

@michel-laterman Changes LGTM, it's there a way to test it end to end with Elasticsearch with an integration test?

@mergify
Copy link
Contributor

mergify bot commented May 6, 2022

This pull request is now in conflicts. Could you fix it @michel-laterman? 🙏
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 rolling-update upstream/rolling-update
git merge upstream/main
git push upstream rolling-update

@mergify
Copy link
Contributor

mergify bot commented May 9, 2022

This pull request is now in conflicts. Could you fix it @michel-laterman? 🙏
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 rolling-update upstream/rolling-update
git merge upstream/main
git push upstream rolling-update

@mergify
Copy link
Contributor

mergify bot commented May 11, 2022

This pull request is now in conflicts. Could you fix it @michel-laterman? 🙏
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 rolling-update upstream/rolling-update
git merge upstream/main
git push upstream rolling-update

@jlind23 jlind23 requested review from a team and removed request for lykkin May 23, 2022 06:29
@jlind23 jlind23 requested review from narph and removed request for a team May 23, 2022 06:29
@michel-laterman michel-laterman merged commit 5be0551 into elastic:main May 24, 2022
@michel-laterman michel-laterman deleted the rolling-update branch April 12, 2023 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify 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.

Fleet server should be able to schedule future actions
4 participants