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

[Rollups] Server NP migration #55606

Merged
merged 19 commits into from
Feb 7, 2020

Conversation

alisonelizabeth
Copy link
Contributor

@alisonelizabeth alisonelizabeth commented Jan 22, 2020

This PR starts the NP migration of the rollup jobs server code. It also converts the server code to TS.

Things to note:

  • In legacy world, there’s not a real initializer context, so I'm currently creating a NP plugin that calls this and then exposes the results to the legacy plugin
  • The index_patterns route was using server.inject(). I removed this and pulled in IndexPatternsFetcher directly from the index_patterns plugin.

What to test

What's left in order to migrate out of legacy

  • Dependent on the Index Management plugin, which has not been migrated yet (planned for 7.7)
  • Adopt NP license checker

@alisonelizabeth alisonelizabeth added v8.0.0 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes Feature:Rollups v7.7.0 labels Jan 22, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@alisonelizabeth alisonelizabeth marked this pull request as ready for review February 3, 2020 17:52
@alisonelizabeth alisonelizabeth changed the title [Rollups] [WIP] Server NP migration [Rollups] Server NP migration Feb 3, 2020
Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

TSVB and Visualize integrations still working fine 👍

usageCollection,
metrics,
__LEGACY: {
route: server.route.bind(server),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used anywhere? couldn't find a reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. You're right, it's not needed anymore.

const requests = request.body.map(({ index, query }: { index: string; query: any }) =>
callWithRequest('rollup.search', {
index,
rest_total_hits_as_int: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just as a side note - AFAIK rest_total_hits_as_int will get deprecated with 8.0, so this has to be handled differently in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up! Do you know if there is an issue open somewhere to track this?

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be the main one: #26356

@alisonelizabeth
Copy link
Contributor Author

@elasticmachine merge upstream

return elasticsearchService.createClient('rollup', config);
});

export const callWithRequestFactory = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this factory? In my PR, I've used it directly from the router context

https://github.com/elastic/kibana/pull/56829/files#diff-178c0726cd4b1e7299f257e5069b4a42R28

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for sharing! I'm going to leave as is for now, but will consider changing this in my next PR.

import { LICENSE_STATUS_VALID } from '../../../../../common/constants/license_status';
import { ServerShim } from '../../types';

export const licensePreRoutingFactory = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should first agree on the solution for this or if we should merge this PR and change it later.
I would think it would be good to first agree on a common pattern (probably a class exposed) to avoid copy/pasting this code + the tests in all our apps.

WDYT @alisonelizabeth @jloleysens @cjcenizal ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is a fair point. The logic for isEsError could probably be moved to a shared space too.

I don't think we need to block this PR though. This work will need to be updated again when the licensing plugin is used and then it can just use the new pattern we have adopted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with @jloleysens. I'd prefer not to block this PR and address when I finish the migration for rollups and adopt the NP licensing plugin.

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Code

Left non-blocker comments.

UX/UI

I tested CRUD of rollups and that seemed to work. Not sure how to test integration with Index Patterns?

Overall everything worked as expected!

import { LICENSE_STATUS_VALID } from '../../../../../common/constants/license_status';
import { ServerShim } from '../../types';

export const licensePreRoutingFactory = (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is a fair point. The logic for isEsError could probably be moved to a shared space too.

I don't think we need to block this PR though. This work will need to be updated again when the licensing plugin is used and then it can just use the new pattern we have adopted.

) =>
class RollupSearchStrategy extends AbstractSearchStrategy {
name = 'rollup';

constructor(server) {
constructor(server: ElasticsearchServiceSetup) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, we should consider renaming server to something else. Perhaps elasticsearchService, just to clean up what looks like a legacy reference.

deps.router.get(
{
path: '/api/index_patterns/rollup/_fields_for_wildcard',
validate: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit; If you would like to re-use the type information of the query validations you can move this object to outside of the register function:

import { TypeOf } from '@kbn/config-schema';
const queryValidation = schema.object({...});
type RouteQuery = TypeOf<typeof queryValidation>;
...
const handler: RequestHandler<unknown, RouteQuery> = ...
...
validate: { query: queryValidation },
...

try {
parsedFields = parseMetaFields(metaFields);
} catch (error) {
return response.badRequest();
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the above error have useful information we can send back in the response body?

this.log = initializerContext.logger.get();
}

async setup(
Copy link
Contributor

Choose a reason for hiding this comment

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

@rudolf informed me that async setup is going to be deprecated, so everything in setup phase for plugins should be synchronous. Not sure it is worth making the changes here though, just wanted to flag this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving as is for now.

@alisonelizabeth
Copy link
Contributor Author

@elasticmachine merge upstream

@alisonelizabeth
Copy link
Contributor Author

@elasticsearchmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

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

@elastic elastic deleted a comment from kibanamachine Feb 7, 2020
@alisonelizabeth alisonelizabeth merged commit 86e186c into elastic:master Feb 7, 2020
@alisonelizabeth alisonelizabeth deleted the np/rollups branch February 7, 2020 15:01
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Feb 7, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 9, 2020
…t-state

* upstream/master: (96 commits)
  top nav ts arg support (elastic#56984)
  [SIEM][detection engine] Limit network rules to filebeat source semantics (elastic#57130)
  Add docs for alerting and action settings (elastic#57035)
  Add Test to Verify Endpoint App Landing Page (elastic#57129)
  Update `markdown-to-jsx` (`6.9.3` → `6.11.0`) and `url-parse` (`1.4.4` → `1.4.7`) dependencies. (elastic#57126)
  chore(NA): removes use of parallel option in the terser minimizer (elastic#57077)
  [ML] New Platform server shim: update file data visualizer routes to use new platform router (elastic#56972)
  Specifying valid licenses for the Graph feature (elastic#55911)
  [APM][docs] Add troubleshooting for non-indexed fields (elastic#54948)
  [ML] DF Analytics creation: update schema definition for create route (elastic#56979)
  Remove Kibana a11y guide in favor of EUI (elastic#57021)
  [Logs UI] Set streamLive false in URL state when arriving from link-to (elastic#56329)
  [docs] Fix spaces api example json (elastic#50411)
  Add new config for filebeat index name (elastic#56920)
  [Metrics-UI] Fix toolbar popover for metrics table row (elastic#56796)
  Saved Objects testing (elastic#56965)
  Disabled categorization stats validation (elastic#57087)
  [Rollups] Server NP migration (elastic#55606)
  [Metrics UI] Limit group by selector to only 2 fields (elastic#56800)
  fix auto closing new vis modal when navigating to lens or when navigating away with browser history (elastic#56998)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Feb 9, 2020
* master: (96 commits)
  top nav ts arg support (elastic#56984)
  [SIEM][detection engine] Limit network rules to filebeat source semantics (elastic#57130)
  Add docs for alerting and action settings (elastic#57035)
  Add Test to Verify Endpoint App Landing Page (elastic#57129)
  Update `markdown-to-jsx` (`6.9.3` → `6.11.0`) and `url-parse` (`1.4.4` → `1.4.7`) dependencies. (elastic#57126)
  chore(NA): removes use of parallel option in the terser minimizer (elastic#57077)
  [ML] New Platform server shim: update file data visualizer routes to use new platform router (elastic#56972)
  Specifying valid licenses for the Graph feature (elastic#55911)
  [APM][docs] Add troubleshooting for non-indexed fields (elastic#54948)
  [ML] DF Analytics creation: update schema definition for create route (elastic#56979)
  Remove Kibana a11y guide in favor of EUI (elastic#57021)
  [Logs UI] Set streamLive false in URL state when arriving from link-to (elastic#56329)
  [docs] Fix spaces api example json (elastic#50411)
  Add new config for filebeat index name (elastic#56920)
  [Metrics-UI] Fix toolbar popover for metrics table row (elastic#56796)
  Saved Objects testing (elastic#56965)
  Disabled categorization stats validation (elastic#57087)
  [Rollups] Server NP migration (elastic#55606)
  [Metrics UI] Limit group by selector to only 2 fields (elastic#56800)
  fix auto closing new vis modal when navigating to lens or when navigating away with browser history (elastic#56998)
  ...
majagrubic pushed a commit to majagrubic/kibana that referenced this pull request Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration Feature:Rollups release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants