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

[Cloud Posture] Initialize plugin on package creation and on start if installed #130649

Merged
merged 10 commits into from
Apr 25, 2022

Conversation

kfirpeled
Copy link
Contributor

Summary

In this PR we are installing needed assets (mainly indices and Transforms) only when adding the package.
Incase the plugin is already installed, initialization process takes place as well.
As it verifies prerequisite state for the cspm solution to work correctly

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@kfirpeled kfirpeled added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:Cloud Security Cloud Security team related v8.3.0 labels Apr 20, 2022

// If package is installed we want to make sure all needed assets are installed
if (packageInfo) {
this.initialize(core);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

be aware, there's a use case that the package is installed without adding it to agent-policy.
That means packagePolicyPostCreate event is not being called.

so there's a case that the assets would be installed only on next server start - which is fine

@kfirpeled kfirpeled marked this pull request as ready for review April 20, 2022 14:01
@kfirpeled kfirpeled requested a review from a team as a code owner April 20, 2022 14:01
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security Posture)

@kfirpeled kfirpeled requested a review from CohenIdo April 20, 2022 14:01
public stop() {}

initialize(core: CoreStart): Promise<unknown> {
Copy link
Contributor

Choose a reason for hiding this comment

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

The return value contains an unknown type. Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

): Promise<PackagePolicy> => {
if (packagePolicy.package?.name === CIS_KUBERNETES_PACKAGE_NAME) {
await this.initialize(core);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:
I would consider consolidating all the post create functions into one method, so maybe initialize should include onPackagePolicyPostCreateCallback as well?
wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the callback of onPackagePolicyPostCreateCallback is not part of the initialize of the plugin.
how do you see they relate?

@kfirpeled kfirpeled enabled auto-merge (squash) April 25, 2022 12:22
@kfirpeled kfirpeled disabled auto-merge April 25, 2022 12:23
@kfirpeled kfirpeled enabled auto-merge (squash) April 25, 2022 12:23
@kfirpeled kfirpeled merged commit d5a84e1 into elastic:main Apr 25, 2022
@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

@kfirpeled kfirpeled deleted the create_assets_on_install branch April 26, 2022 07:32
kertal pushed a commit to kertal/kibana that referenced this pull request May 24, 2022
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:Cloud Security Cloud Security team related v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants