-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Background Search] Add maxSize to unbounded arrays #253411
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -15,6 +15,12 @@ const searchSessionRequestInfoSchema = schema.object({ | |||
| status: schema.maybe(schema.string()), | ||||
| startedAt: schema.maybe(schema.string()), | ||||
| completedAt: schema.maybe(schema.string()), | ||||
| error: schema.maybe( | ||||
| schema.object({ | ||||
| code: schema.number(), | ||||
| message: schema.maybe(schema.string()), | ||||
| }) | ||||
| ), | ||||
| }); | ||||
|
|
||||
| const serializeableSchema = schema.mapOf(schema.string(), schema.any()); | ||||
|
|
@@ -50,7 +56,7 @@ const status = schema.object({ | |||
| schema.literal('cancelled'), | ||||
| schema.literal('expired'), | ||||
| ]), | ||||
| errors: schema.maybe(schema.arrayOf(schema.string())), | ||||
| errors: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 10000 })), | ||||
| }); | ||||
|
|
||||
| export const searchSessionStatusSchema = status; | ||||
|
|
@@ -61,12 +67,13 @@ export const searchSessionStatusesSchema = schema.object({ | |||
|
|
||||
| export const searchSessionsFindSchema = schema.object({ | ||||
| total: schema.number(), | ||||
| saved_objects: schema.arrayOf(searchSessionSchema), | ||||
| saved_objects: schema.arrayOf(searchSessionSchema, { maxSize: 10000 }), | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would be the page size for the management page, by default it's 100 but it can be tweaked with |
||||
| statuses: schema.recordOf(schema.string(), searchSessionStatusSchema), | ||||
| }); | ||||
|
|
||||
| const referencesSchema = schema.arrayOf( | ||||
| schema.object({ id: schema.string(), type: schema.string(), name: schema.string() }) | ||||
| schema.object({ id: schema.string(), type: schema.string(), name: schema.string() }), | ||||
| { maxSize: 10 } | ||||
|
Comment on lines
+75
to
+76
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for this one i'm using a low number just for future proofing because as far as i've seen we don't get references, it's always undefined
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this is odd, I wonder if we can remove this altogether. I think this might be a bug. Anyway, not important for this PR. |
||||
| ); | ||||
|
|
||||
| export const searchSessionsUpdateSchema = schema.object({ | ||||
|
|
@@ -75,7 +82,8 @@ export const searchSessionsUpdateSchema = schema.object({ | |||
| updated_at: schema.maybe(schema.string()), | ||||
| updated_by: schema.maybe(schema.string()), | ||||
| version: schema.maybe(schema.string()), | ||||
| namespaces: schema.maybe(schema.arrayOf(schema.string())), | ||||
| // The search-sessions saved object definition specifies that the namespaces are 'single', that means only one space is allowed. | ||||
| namespaces: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 1 })), | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. namespaces should always be 1 as defined in the saved object definition: kibana/src/platform/plugins/shared/data/server/search/saved_objects/search_session.ts Line 23 in 373acb3
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mind adding a comment noting that? |
||||
| references: schema.maybe(referencesSchema), | ||||
| attributes: schema.object({ | ||||
| name: schema.maybe(schema.string()), | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,7 +196,7 @@ export function registerSessionRoutes(router: DataPluginRouter, logger: Logger): | |
| schema.oneOf([schema.literal('desc'), schema.literal('asc')]) | ||
| ), | ||
| filter: schema.maybe(schema.string()), | ||
| searchFields: schema.maybe(schema.arrayOf(schema.string())), | ||
| searchFields: schema.maybe(schema.arrayOf(schema.string(), { maxSize: 10 })), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similar to references i'm going with a low number for future proofing, right now we don't pass down any filter through the |
||
| search: schema.maybe(schema.string()), | ||
| }), | ||
| }, | ||
|
|
@@ -412,7 +412,10 @@ export function registerSessionRoutes(router: DataPluginRouter, logger: Logger): | |
| validate: { | ||
| request: { | ||
| body: schema.object({ | ||
| sessionIds: schema.arrayOf(schema.string()), | ||
| // When a search is sent to the background the client starts polling for its status. All the searches that | ||
| // are in progress are sent to the server to get their updated status until they are in a completed status. | ||
| // For this endpoint the assumption is that the client won't have more than 100 searches in progress at the same time. | ||
| sessionIds: schema.arrayOf(schema.string(), { maxSize: 100 }), | ||
| }), | ||
| }, | ||
| response: { | ||
|
|
||
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.
in theory we can have as many errors as searches in the background search - I'm just going with the elasticsearch default max here