-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Rollup] Migrate to new ES client #95926
Merged
jloleysens
merged 9 commits into
elastic:master
from
jloleysens:rollup-jobs/migrate-to-new-es-client
Apr 7, 2021
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4bf15c6
initial pass at es client migration
jloleysens 7e09d8c
fixed potential for not passing in an error message and triggering an…
jloleysens 4491a8b
Merge branch 'master' into rollup-jobs/migrate-to-new-es-client
kibanamachine 6a84b45
reworked ad hoc fixing of error response
jloleysens b1ccec3
delete legacy client file and remove use of legacyEs service
jloleysens 36309d5
remove unused import
jloleysens b84ea5a
Merge branch 'master' into rollup-jobs/migrate-to-new-es-client
kibanamachine c2f29aa
Merge branch 'master' into rollup-jobs/migrate-to-new-es-client
kibanamachine ab07eef
Merge branch 'master' into rollup-jobs/migrate-to-new-es-client
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 0 additions & 142 deletions
142
x-pack/plugins/rollup/server/client/elasticsearch_rollup.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,6 @@ interface FieldCapability { | |
scaled_float?: any; | ||
} | ||
|
||
interface FieldCapabilities { | ||
fields: FieldCapability[]; | ||
} | ||
|
||
function isNumericField(fieldCapability: FieldCapability) { | ||
const numericTypes = [ | ||
'long', | ||
|
@@ -59,7 +55,7 @@ function isNumericField(fieldCapability: FieldCapability) { | |
export const registerValidateIndexPatternRoute = ({ | ||
router, | ||
license, | ||
lib: { isEsError, formatEsError }, | ||
lib: { handleEsError }, | ||
}: RouteDependencies) => { | ||
router.get( | ||
{ | ||
|
@@ -71,16 +67,12 @@ export const registerValidateIndexPatternRoute = ({ | |
}, | ||
}, | ||
license.guardApiRoute(async (context, request, response) => { | ||
const { client: clusterClient } = context.core.elasticsearch; | ||
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. same nit here :) |
||
try { | ||
const { indexPattern } = request.params; | ||
const [fieldCapabilities, rollupIndexCapabilities]: [ | ||
FieldCapabilities, | ||
{ [key: string]: any } | ||
] = await Promise.all([ | ||
context.rollup!.client.callAsCurrentUser('rollup.fieldCapabilities', { indexPattern }), | ||
context.rollup!.client.callAsCurrentUser('rollup.rollupIndexCapabilities', { | ||
indexPattern, | ||
}), | ||
const [{ body: fieldCapabilities }, { body: rollupIndexCapabilities }] = await Promise.all([ | ||
clusterClient.asCurrentUser.fieldCaps({ index: indexPattern, fields: '*' }), | ||
clusterClient.asCurrentUser.rollup.getRollupIndexCaps({ index: indexPattern }), | ||
]); | ||
|
||
const doesMatchIndices = Object.entries(fieldCapabilities.fields).length !== 0; | ||
|
@@ -92,23 +84,21 @@ export const registerValidateIndexPatternRoute = ({ | |
|
||
const fieldCapabilitiesEntries = Object.entries(fieldCapabilities.fields); | ||
|
||
fieldCapabilitiesEntries.forEach( | ||
([fieldName, fieldCapability]: [string, FieldCapability]) => { | ||
if (fieldCapability.date) { | ||
dateFields.push(fieldName); | ||
return; | ||
} | ||
fieldCapabilitiesEntries.forEach(([fieldName, fieldCapability]) => { | ||
if (fieldCapability.date) { | ||
dateFields.push(fieldName); | ||
return; | ||
} | ||
|
||
if (isNumericField(fieldCapability)) { | ||
numericFields.push(fieldName); | ||
return; | ||
} | ||
if (isNumericField(fieldCapability)) { | ||
numericFields.push(fieldName); | ||
return; | ||
} | ||
|
||
if (fieldCapability.keyword) { | ||
keywordFields.push(fieldName); | ||
} | ||
if (fieldCapability.keyword) { | ||
keywordFields.push(fieldName); | ||
} | ||
); | ||
}); | ||
|
||
const body = { | ||
doesMatchIndices, | ||
|
@@ -132,11 +122,7 @@ export const registerValidateIndexPatternRoute = ({ | |
return response.ok({ body: notFoundBody }); | ||
} | ||
|
||
if (isEsError(err)) { | ||
return response.customError({ statusCode: err.statusCode, body: err }); | ||
} | ||
|
||
throw err; | ||
return handleEsError({ error: err, response }); | ||
} | ||
}) | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: not sure why we need to rename
client
here.