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

Ability to get scoped call cluster from alerting and action executors #64432

Merged
merged 8 commits into from
Apr 27, 2020

Conversation

mikecote
Copy link
Contributor

@mikecote mikecote commented Apr 24, 2020

Fixes #62886

In this PR, I'm adding a new alert and action executor service of getScopedCallCluster. This function allows you to pass instances of ClusterClient to get a scoped call cluster function that is tied to the user in context of the execution.

This PR also:

  • Makes use of service mocks to only have one or two places to modify when adding new services
  • Is missing unit tests due to the complexity of the code living in plugins.ts (relies only on API integration tests instead)

TODO:

  • Update README.md

@mikecote mikecote added Feature:Alerting v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v7.8.0 labels Apr 24, 2020
@mikecote mikecote self-assigned this Apr 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@mikecote mikecote changed the title Ability to create scoped cluster clients from alerting and action executors Ability to get scoped call cluster from alerting and action executors Apr 24, 2020
Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

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

From SIEM's end: I tested this functionality out with our existing ML integration and things work beautifully. Thank you!

@mikecote mikecote marked this pull request as ready for review April 27, 2020 14:09
@mikecote mikecote requested review from a team as code owners April 27, 2020 14:09
@gmmorris gmmorris self-requested a review April 27, 2020 14:35
Copy link
Contributor

@gmmorris gmmorris left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Comment on lines +34 to +44
const createServicesMock = () => {
const mock: jest.Mocked<Services & {
savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
}> = {
callCluster: elasticsearchServiceMock.createScopedClusterClient().callAsCurrentUser,
getScopedCallCluster: jest.fn(),
savedObjectsClient: savedObjectsClientMock.create(),
};
return mock;
};

Copy link
Contributor

Choose a reason for hiding this comment

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

good clean up 👍

@@ -26,7 +31,19 @@ const createStartMock = () => {
return mock;
};

const createServicesMock = () => {
const mock: jest.Mocked<Services & {
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 this just be jest.Mocked< AlertServices> ? 🤔

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 jest.Mocked<...> doesn't apply recursively. This was necessary to allow services.savedObjectsClient.get.mockResolvedValue(...).

@mikecote
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@YulNaumenko YulNaumenko left a comment

Choose a reason for hiding this comment

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

LGTM

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

Copy link
Contributor

@phillipb phillipb left a comment

Choose a reason for hiding this comment

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

LGTM!

@mikecote mikecote merged commit db374fc into elastic:master Apr 27, 2020
mikecote added a commit to mikecote/kibana that referenced this pull request Apr 27, 2020
…elastic#64432)

* Initial work

* Rename to getScopedCallCluster

* Fix typecheck

* Fix more type check issues

* Add tests

* Add docs

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
mikecote added a commit that referenced this pull request Apr 27, 2020
…#64432) (#64543)

* Initial work

* Rename to getScopedCallCluster

* Fix typecheck

* Fix more type check issues

* Add tests

* Add docs

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 28, 2020
…bana into pipeline-editor-part-mvp-2

* 'feature/ingest-node-pipelines' of github.com:elastic/kibana: (152 commits)
  [Ingest pipelines] Simulate pipeline (elastic#64223)
  Ability to get scoped call cluster from alerting and action executors (elastic#64432)
  Add editApp and editPath to embeddable (elastic#64297)
  TSVB validation: Allow numeric values for axes (elastic#63553)
  [ML] Fixing optional plugin dependency types (elastic#64450)
  [Logs UI] Alerting (elastic#62806)
  [Endpoint] Show Policy Status on Host Details using Policy Response API (elastic#64116)
  [Maps] update LayerWizard previewLayer to take layerDescriptor instead of ISource (elastic#64461)
  Remove SO root property index signature (elastic#64434)
  [ML] Functional tests - stabilize job row details validations (elastic#64503)
  [Ingest] Add Global settings flyout (elastic#64276)
  Bump cypress dev-dependency from 4.2.0 to 4.4.1 (elastic#64408)
  Migrate saved object of type url to kibana platform (elastic#64043)
  [NP] Migrate ui capabilities (elastic#64185)
  Bump karma-mocha dev-dependency from 1.3.0 to 2.0.0 (elastic#64407)
  Migrate kql_telemetry saved object registration to Kibana platform (elastic#64149)
  Remove SO autocreateindex error and error page (elastic#64037)
  Fix issue with yarn.lock (elastic#64496)
  Bump @hapi/boom dependency from 7.4.2 to 7.4.11 (elastic#64433)
  Bump gonzales-pe dev-dependency from 4.2.4 to 4.3.0 (elastic#64401)
  ...

# Conflicts:
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_form/pipeline_form.tsx
#	x-pack/plugins/ingest_pipelines/public/shared_imports.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Alerting release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Plugin support for scoped clients
7 participants