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

Reporting: register a single ESQueue worker, simultaneous poll for all export types #32839

Merged
merged 14 commits into from
Mar 15, 2019

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Mar 9, 2019

Fixes #32089

Have a single ESQueue worker registered for Reporting. The single worker handles multiple export types by routing the claimed job details to the proper export type execute function, using a Map object (jobExecutors)

  • Change create_workers.js to create_worker.ts
  • Make an internal change to the logger (LevelLogger) used by create_worker

TODO:

  • Fix tests
  • Add more tests

@tsullivan tsullivan added v8.0.0 v7.2.0 review (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead and removed review labels Mar 9, 2019
@tsullivan tsullivan force-pushed the fix/reporting/job-worker-polling branch from e2b8128 to 169f791 Compare March 11, 2019 18:04
const conditions = get(body, conditionPath);
expect(conditions.must).to.eql({ term: { jobtype: jobtype } });
});

Copy link
Member Author

@tsullivan tsullivan Mar 11, 2019

Choose a reason for hiding this comment

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

This test is no longer relevant, because each search should now turn up a waiting job for any type

@@ -357,7 +362,6 @@ export class Worker extends events.EventEmitter {
filter: {
bool: {
minimum_should_match: 1,
must: { term: { jobtype: this.jobtype } },
Copy link
Member Author

Choose a reason for hiding this comment

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

@tsullivan
Copy link
Member Author

jenkins test this

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@chrisdavies chrisdavies left a comment

Choose a reason for hiding this comment

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

LGTM w/ tweaks. Just a code-review. It seems reasonable. I only had minor comments.

* you may not use this file except in compliance with the Elastic License.
*/

// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're ignoring due to the import being untyped, this should be:

// @ts-ignore untyped dependency

Otherwise, maybe add a comment about why these are ignored?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good to know! This is way more preferable, now it will complain if the module is not found.

I had a bad habit of this. I think I have a followup PR now to fix more of these :D

Copy link
Member Author

Choose a reason for hiding this comment

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

oh I misunderstood: that isn't a syntax that causes just that one type of error to be ignored ts

logger.debug(`Worker completed: (${res.job.id})`);
});
worker.on(esqueueEvents.EVENT_WORKER_JOB_EXECUTION_ERROR, (res: any) => {
logger.debug(`Worker error: (${res.job.id})`);
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 this should be higher than a debug message? Maybe not... could get spammy.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like these are redundant actually. It looks like the code usually logs a warning before firing one of the "bad" Esqueue events. We would probably not lose anything from removing these event handlers...

Probably best to leave them as debug for now, that was the original behavior since log was hardcoded to be debug in this file: https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/server/lib/create_workers.js#L21

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, there's a few events that get emitted/bound that no subscribers even listen to iirc.

@elastic elastic deleted a comment from elasticmachine Mar 14, 2019
@elastic elastic deleted a comment from elasticmachine Mar 14, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@@ -0,0 +1,99 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for going the distance on the tests!

Copy link
Contributor

@joelgriffith joelgriffith left a comment

Choose a reason for hiding this comment

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

LGTM

@tsullivan tsullivan merged commit 7a407d0 into elastic:master Mar 15, 2019
@tsullivan tsullivan deleted the fix/reporting/job-worker-polling branch March 15, 2019 19:27
tsullivan added a commit to tsullivan/kibana that referenced this pull request Mar 15, 2019
…ll export types (elastic#32839)

* Reporting: register a single ESQueue worker, simultaneous poll for all export types

* more typescript

* PLUGIN_ID constant

* move down log / internal state

* fix tests

* jest test for createWorker

* assert arguments to queue.registerWorker

* logic move

* make ts ignore specific

* minor reversion to fix some esqueue worker tests
@elasticmachine
Copy link
Contributor

💔 Build Failed

tsullivan added a commit that referenced this pull request Mar 20, 2019
…ll export types (#32839) (#33339)

* Reporting: register a single ESQueue worker, simultaneous poll for all export types

* more typescript

* PLUGIN_ID constant

* move down log / internal state

* fix tests

* jest test for createWorker

* assert arguments to queue.registerWorker

* logic move

* make ts ignore specific

* minor reversion to fix some esqueue worker tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead performance review v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants