-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] ReportingStore module #69426
Conversation
b552cfc
to
72a4540
Compare
72a4540
to
82a8525
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments about the diff
@@ -37,26 +36,25 @@ type GenericWorkerFn<JobParamsType> = ( | |||
...workerRestArgs: any[] | |||
) => void | Promise<TaskRunResult>; | |||
|
|||
export async function createQueueFactory<JobParamsType, JobPayloadType>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These generics were not used, so I removed them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pray I don't alter it further
_primary_term: number; | ||
} | ||
|
||
export type Job = EventEmitter & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type is no longer needed: replaced with Report
class
}; | ||
}; | ||
|
||
export type EnqueueJobFn = <JobParamsType>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling JobParamsType
isn't necessary since jobParams
is just pass-through
@@ -40,21 +37,6 @@ export class Esqueue extends EventEmitter { | |||
}); | |||
} | |||
|
|||
addJob(jobtype, payload, opts = {}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with ReportingStore.addJob
|
||
const puid = new Puid(); | ||
|
||
export class Job extends events.EventEmitter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with Report
class, minus the ES client stuff, which is part of ReportingStore
}) | ||
.then(() => true) | ||
.catch((err) => { | ||
/* FIXME creating the index will fail if there were multiple jobs staged in parallel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is carried over as-is from the ESQueue x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js
}); | ||
} | ||
|
||
private async saveReport(report: Report) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is moved over from ESQueue's Job class constructor
8e0fc11
to
29bf6a7
Compare
const isIndexExistsError = err.message.match(/resource_already_exists_exception/); | ||
if (isIndexExistsError) { | ||
// Do not fail a job if the job runner hits the race condition. | ||
this.logger.warn(`Automatic index creation failed: index already exists: ${err}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a bug that was a FIXME comment: https://github.com/elastic/kibana/blob/2f67cbf/x-pack/plugins/reporting/server/lib/esqueue/helpers/create_index.js#L93
Continuing from index creation failure, when the index already exists, is now actually logged
|
||
import { LevelLogger } from '../lib'; | ||
|
||
export function createMockLevelLogger() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would have been useful to have earlier :)
Pinging @elastic/kibana-reporting-services (Team:Reporting Services) |
const isPollingEnabled = config.get('queue', 'pollEnabled'); | ||
|
||
const elasticsearch = await reporting.getElasticsearchService(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not seeing if this changed from sync to async here. I'm assuming so...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method was never async, so this is a little cleanup. It's something that doesn't get warned about.
💚 Build SucceededBuild metricspage load asset sizebeta
History
To update your PR or re-run it, just comment with: |
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting to feel more like a "constant" to me since it's mostly static. Not sure on your thoughts there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to visit this more often than other constants. I think it's best to keep this easy to find.
|
||
const esqueue = await createQueueFactory(reportingCore, logger); // starts polling for pending jobs | ||
const enqueueJob = enqueueJobFactory(reportingCore, logger); // called from generation routes | ||
const store = new ReportingStore(reportingCore, logger); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you feel about adding an instance of the store to the reporting-core object, and having it be access via a getter like we do with the other utilities?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++.
We can shrink the options that get passed to pluginStart
and have the core instance provide those things for itself, and provide getters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, my take on this ended up with more refactoring than I intended. Right now, the reporting store is to be set up in a synchronization with:
- having the config available, to pass the constructor
- being made available from ReportingCore before
create_queue
gets called. It got harder to sync that when ESQueue gets the store from ReportingCore instead of receiving it as a parameter
A few PRs from now when ESQueue is gone, we can revisit this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a few thoughts on how we pass around the store object, otherwise looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will follow up with interface changes + exposing store via a core getter later. LETS GET THIS STARTED
* Add store class * fix tests * fix the createIndex bug * add reportingstore test * change function args * nits * add test for automatic index creation failure recovery # Conflicts: # x-pack/plugins/reporting/server/lib/esqueue/job.js
…t-pipelines/editor-error-messages * ingest-pipelines/editor-dropzone-refinement: (122 commits) Fixes for monaco XJSON grammar parser and update form copy Added cancel move button Refactor SCSS values to variables use classNames as it is intended to be used Remove box shadow on all nested tree items Rename variables and prefix booleans with "is" Fixes bug on color picker defaults on TSVB (elastic#69889) [DOCS] Fixes wording in Upload a CSV section (elastic#69969) [Discover] Validate timerange before submitting query to ES (elastic#69363) [Maps] avoid using MAP_SAVED_OBJECT_TYPE constant when defining URL paths (elastic#69723) [Maps] Fix icon palettes are not working (elastic#69937) [Ingest Manager] Fix typo in constant name (elastic#69919) [test] skip status.allowAnonymous tests on cloud (elastic#69017) Fix backport (elastic#70003) [Reporting] ReportingStore module (elastic#69426) Add reporting assets to the eslint ignore file (elastic#69968) [Discover] set minBarHeight for high cardinality data (elastic#69875) Add featureUsage API to licensing context provider (elastic#69838) Fix uncaught typecheck merge conflict (elastic#70001) Use TS to discourage SO mappings with dynamic: false / dynamic: true (elastic#69927) ...
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
1 similar comment
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
* [Reporting] ReportingStore module (#69426) * Add store class * fix tests * fix the createIndex bug * add reportingstore test * change function args * nits * add test for automatic index creation failure recovery # Conflicts: # x-pack/plugins/reporting/server/lib/esqueue/job.js * fix ts * fix bugs
Summary
Part of #69340
ESQueue is currently responsible for creating the time-based Reporting index, which is abstracted in its
addJob
method. That functionality must be removed to allow ESQueue to be replaced with the Task Manager service.This PR adds a new class called ReportingStore, which has feature parity with the functionality previously held by Esqueue.addJob.
Checklist
Delete any items that are not applicable to this PR.
For maintainers