Skip to content

fix(opensearch): default to OpenSearch if distribution detection fails#5700

Open
saketh-pallempati wants to merge 2 commits into
opensearch-project:mainfrom
fidelity-contributions:fix-issue-5673
Open

fix(opensearch): default to OpenSearch if distribution detection fails#5700
saketh-pallempati wants to merge 2 commits into
opensearch-project:mainfrom
fidelity-contributions:fix-issue-5673

Conversation

@saketh-pallempati

Copy link
Copy Markdown
Contributor

Description

Accurate Client Selection: The logic for choosing between an OpenSearchAccessor and an ElasticsearchAccessor was refined to correctly rely on the determined cluster distribution, especially after attempting to get version information.

Reliable Default to OpenSearch: If the cluster distribution cannot be auto-detected (i.e., API calls to both OpenSearch and Elasticsearch clients fail) and the distribution_version is not configured, the strategy now consistently defaults to OpenSearch behavior and uses an OpenSearchAccessor.

Enhanced Edge Case Handling: The code now better manages situations where an Elasticsearch client needs to be created dynamically, for instance, if an initial OpenSearch client call succeeds but indicates an Elasticsearch distribution.

Issues Resolved

Resolves #5673

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@saketh-pallempati

Copy link
Copy Markdown
Contributor Author

Please re run the DCO check

LOG.warn("Version number is null in Elasticsearch API response. Proceeding to default.");
}
} catch (final Exception e) {
LOG.warn("Failed to get cluster info using Elasticsearch client. Will proceed with default behavior.", e);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This log could maybe indicate that the default behavior is to assume that it is OpenSearch, although you do have that log later on

"Defaulting to OpenSearch distribution. Consider setting 'distribution_version' in the configuration if this is not an OpenSearch cluster.");
return Pair.of(OPENSEARCH_DISTRIBUTION, OPENSEARCH_POINT_IN_TIME_SUPPORT_VERSION_CUTOFF);
} else {
final String configuredDistributionName = openSearchSourceConfiguration.getDistributionVersion().name();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure we want this check to happen. If users configure distribution version it's probably better to trust it and create that type of accessor. I think there could be cases where the distribution_version is correct but the info response can still return unexpected results. So I would just keep the behavior the same (if distribution_version is set, just force that type of accessor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure I was just trying to add some extra validation. Will simplify the case

@graytaylor0

Copy link
Copy Markdown
Member

I also tried to run the DCO check and it failed

@saketh-pallempati

Copy link
Copy Markdown
Contributor Author

I also tried to run the DCO check and it failed

Yeah some problem on my end i will figure it.

Signed-off-by: Pallempati Saketh <pallempati.saketh@fmr.com>
…cessorStrategy

- Force accessor type when distribution_version is explicitly configured
- Default to OpenSearch when both API calls fail instead of throwing exceptions
- Improve error resilience and respect user configuration preferences

Signed-off-by: Pallempati Saketh <pallempati.saketh@fmr.com>
@graytaylor0

Copy link
Copy Markdown
Member

It's still failing DCO

@saketh-pallempati

Copy link
Copy Markdown
Contributor Author

It's still failing DCO

Sorry that I made a change which should be pushed by my org. Please give it some time.

@saketh-pallempati

Copy link
Copy Markdown
Contributor Author

Hi @graytaylor0
Please check the commit for DCO and the code changes

@graytaylor0 graytaylor0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for cleaning this up!

@saketh-pallempati

Copy link
Copy Markdown
Contributor Author

Thanks for the approval @graytaylor0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assume distribution_version is set to opensearch for OpenSearch source

2 participants