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

Fixes bugs for product check in update and delete #109979

Conversation

TinaHeiligers
Copy link
Contributor

@TinaHeiligers TinaHeiligers commented Aug 24, 2021

Summary

Adding integration tests for #107246 uncovered a couple of edge cases not handled in the original work. This PR fixes bugs in update and delete introduced in #107301.

In the original implementation for handling 404's in delete, we only verified that an error is from Elasticsearch when body.found is explicitly not_found. However, that might not be the case when the error originates from the proxy itself and we'll miss those.

In update, we don't ignore 404's and these are caught if retryCallCluster throws so we have to handle the product check on NotFound errors in decorateEsError.

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
False positives— An intermediate proxy doesn't forward x-elastic-product header. Low Low As of 7.16, Kibana won't start unless the required headers are present. Until then, the type of error returned could either be a 404 or a 503, but it is still an error.

For maintainers

@@ -69,6 +70,11 @@ export function decorateEsError(error: EsErrors) {
if (match?.length > 0) {
return SavedObjectsErrorHelpers.decorateIndexAliasNotFoundError(error, match[1]);
}
// Throw EsUnavailable error if the 404 is not from elasticsearch
// Needed here to verify Product support for any non-ignored 404 responses from calls to ES
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check against the product header and return the appropriate error from here to catch it in update.

@@ -681,6 +681,10 @@ export class SavedObjectsRepository {
{ ignore: [404] }
);

if (isNotFoundFromUnsupportedServer({ statusCode, headers })) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simplifies the nested conditionals originally added.

@TinaHeiligers TinaHeiligers requested a review from a team August 25, 2021 13:22
@TinaHeiligers TinaHeiligers marked this pull request as ready for review August 25, 2021 13:22
@TinaHeiligers TinaHeiligers added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Aug 25, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(false);
const genericError = decorateEsError(error);
expect(genericError).not.toBe(error);
expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: duplicated. see L117

);
await expectNotFoundEsUnavailableError(type, id);
await expectNotFoundError(type, id);
Copy link
Contributor

@mshustov mshustov Aug 26, 2021

Choose a reason for hiding this comment

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

👍 a good catch

@TinaHeiligers TinaHeiligers added the auto-backport Deprecated - use backport:version if exact versions are needed label Aug 26, 2021
@TinaHeiligers TinaHeiligers enabled auto-merge (squash) August 26, 2021 13:49
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@TinaHeiligers TinaHeiligers merged commit b15b3ce into elastic:master Aug 26, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 26, 2021
* Fixes bugs for product check in update and delete

* Apply suggestions from code review
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

@TinaHeiligers TinaHeiligers deleted the so-repository/fix_unsupported_product_check branch August 26, 2021 16:48
kibanamachine added a commit that referenced this pull request Aug 26, 2021
* Fixes bugs for product check in update and delete

* Apply suggestions from code review

Co-authored-by: Christiane (Tina) Heiligers <christiane.heiligers@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:Saved Objects release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants