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

[Fleet] Implement preconditions in packages install state machine #190986

Merged

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Aug 21, 2024

Closes #189353

Summary

Small change that implements a precondition function for package install state machine. This is needed for the subsequent work planned in #169147.

Note that this code is added and tested, but it's not currently used and it will actually be used only when #175597 will be implemented.

Checklist

@criamico criamico self-assigned this Aug 21, 2024
@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label Aug 21, 2024
@obltmachine
Copy link

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@criamico criamico added release_note:skip Skip the PR/issue when compiling release notes v8.16.0 labels Aug 21, 2024
@criamico criamico marked this pull request as ready for review August 21, 2024 13:31
@criamico criamico requested a review from a team as a code owner August 21, 2024 13:31
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@nchaulet nchaulet self-requested a review August 23, 2024 15:51
@criamico
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @criamico

@@ -63,6 +67,10 @@ export async function handleState(
let currentStatus = 'pending';
let stateResult;
let updatedContext = { ...context };

// execute pre transition function, if available
await executePreTransition(logger, updatedContext, currentState);
Copy link
Member

Choose a reason for hiding this comment

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

For my understanding, do you have an example behavior of what will fo into that pre-transition function? (trying to understand what is the difference between the preTransation and the actual transition)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My idea was to use it to pass a separate function that verifies if a transition can be executed or not: https://github.com/elastic/kibana/pull/190986/files#diff-b10bba63aaadda84089fe825d4653fa82908e20a3e795c91a2f005169c2d8fffR420-R445

Surely we could also add a check at the beginning of each transition and throw an error in that case, but I think that this approach would be more modular. Let me know what you think :)

Copy link
Member

Choose a reason for hiding this comment

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

It probably can help to separate concerns thanks for the explanation 👍

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

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

🚀

@criamico criamico merged commit 5075b04 into elastic:main Aug 27, 2024
21 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Aug 27, 2024
@criamico criamico deleted the 189353_packages_state_machine_precondition branch August 27, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Implement executePreCondition for packages state machine functionality
6 participants