-
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
[Ingest Pipelines] Migrate to new ES client #96406
Merged
jloleysens
merged 14 commits into
elastic:master
from
jloleysens:ingest-piplines/migrate-legacy-es-client
Apr 13, 2021
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
39bc394
- migrated use of legacy.client to client
jloleysens b938298
remove use of legacyEs service in functional test
jloleysens d4e19f3
Merge branch 'master' into ingest-piplines/migrate-legacy-es-client
kibanamachine b80e883
fixing type issues and API response object
jloleysens 826bb98
Merge branch 'master' into ingest-piplines/migrate-legacy-es-client
kibanamachine 77466c5
remove id from get all request!
jloleysens b810dcd
reinstated logic for handling 404 from get all pipelines request
jloleysens 3156eb6
clarify error handling with comments and small variable name refactor
jloleysens 48828aa
Merge branch 'master' into ingest-piplines/migrate-legacy-es-client
kibanamachine 8b30236
updated delete error responses
jloleysens 8d84200
update functional test
jloleysens 82b8238
Merge branch 'master' into ingest-piplines/migrate-legacy-es-client
kibanamachine 89a14ec
Merge branch 'master' into ingest-piplines/migrate-legacy-es-client
kibanamachine 310b84d
refactor use of legacyEs
jloleysens 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
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
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 |
---|---|---|
|
@@ -18,33 +18,22 @@ const paramsSchema = schema.object({ | |
export const registerGetRoutes = ({ | ||
router, | ||
license, | ||
lib: { isEsError }, | ||
lib: { handleEsError }, | ||
}: RouteDependencies): void => { | ||
// Get all pipelines | ||
router.get( | ||
{ path: API_BASE_PATH, validate: false }, | ||
license.guardApiRoute(async (ctx, req, res) => { | ||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client; | ||
const { client: clusterClient } = ctx.core.elasticsearch; | ||
|
||
try { | ||
const pipelines = await callAsCurrentUser('ingest.getPipeline'); | ||
const { body: pipelines } = await clusterClient.asCurrentUser.ingest.getPipeline({ | ||
id: '_all', | ||
}); | ||
|
||
return res.ok({ body: deserializePipelines(pipelines) }); | ||
} catch (error) { | ||
if (isEsError(error)) { | ||
// ES returns 404 when there are no pipelines | ||
// Instead, we return an empty array and 200 status back to the client | ||
if (error.status === 404) { | ||
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. Is this check no longer needed? 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. Good point! This behaviour needs to be preserved! |
||
return res.ok({ body: [] }); | ||
} | ||
|
||
return res.customError({ | ||
statusCode: error.statusCode, | ||
body: error, | ||
}); | ||
} | ||
|
||
throw error; | ||
return handleEsError({ error, response: res }); | ||
} | ||
}) | ||
); | ||
|
@@ -58,27 +47,22 @@ export const registerGetRoutes = ({ | |
}, | ||
}, | ||
license.guardApiRoute(async (ctx, req, res) => { | ||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client; | ||
const { client: clusterClient } = ctx.core.elasticsearch; | ||
const { name } = req.params; | ||
|
||
try { | ||
const pipeline = await callAsCurrentUser('ingest.getPipeline', { id: name }); | ||
const { body: pipelines } = await clusterClient.asCurrentUser.ingest.getPipeline({ | ||
id: name, | ||
}); | ||
|
||
return res.ok({ | ||
body: { | ||
...pipeline[name], | ||
...pipelines[name], | ||
name, | ||
}, | ||
}); | ||
} catch (error) { | ||
if (isEsError(error)) { | ||
return res.customError({ | ||
statusCode: error.statusCode, | ||
body: error, | ||
}); | ||
} | ||
|
||
throw error; | ||
return handleEsError({ error, response: res }); | ||
} | ||
}) | ||
); | ||
|
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
10 changes: 0 additions & 10 deletions
10
x-pack/plugins/ingest_pipelines/server/routes/api/shared/is_object_with_keys.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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.
I don't think an
id
is required or needed to fetch all pipelines.I'm actually getting an error currently when trying to load the list view as-is. (
I'm surprised a test didn't catch this 🤔nm, looks like it did 😄 )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.
Haha this is what happens when you commit test code! This is how I came across the issue with messages returned in
handlEsError
😅 . Will fix!