Skip to content

Conversation

@deepdatta
Copy link
Contributor

@deepdatta deepdatta commented Aug 26, 2022

Signed-off-by: Deep Datta [email protected]

Description

Add a default_server_major_version config. If this plugin fails to fetch the OpenSearch version number from the host's root URL, it will use this version number, if specified to figure out feature supports.

Issues Resolved

Add a config to skip doing a GET on the healthcheck endpoint #165

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has documentation added
  • Commits are signed as per the DCO using --signoff

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.

@deepdatta deepdatta requested a review from a team as a code owner August 26, 2022 15:05
if skip_healthcheck == false
version = get_version(url)
else
version = "#{default_server_major_version}.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

We're defining default version as 2, should this also be kept as 2 instead of 2.0.0 for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The parsing function used to pick out the major version expects the version in this format. Making this 2 was resulting in additional if checks and code clutter.

config :pipeline, :validate => :string, :default => nil

# If enabled, skip the GET request to the Healthcheck endpoint to get the server version.
# The HEAD request is still done to check if the server is alive.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is HEAD request referring to here?

Copy link
Contributor Author

@deepdatta deepdatta Aug 30, 2022

Choose a reason for hiding this comment

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

The healthcheck! function in pool.rb makes 2 request, one via healhealth_check_request() which sends a HEAD to check connectivity. Then a GET via get_version(url) which receives the info json and parses out the version. Some OpenSearch instances respond to the GET with a 404 and empty body, resulting in an exception.

Copy link
Member

Choose a reason for hiding this comment

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

Should we rename this property? There is somewhat of a health-check with the HEAD request. It isn't quite the same as checking the cluster health, but is somewhat similar. Maybe it should be skip_version_check?

Or an alternative would be to skip it only if default_server_major_version is not defined.

Copy link
Contributor

@sshivanii sshivanii left a comment

Choose a reason for hiding this comment

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

Overall this PR looks good to me, only 2 clarifying questions.

@sshivanii
Copy link
Contributor

Similar comment as the templates PR, please include these changes in the README.

config :pipeline, :validate => :string, :default => nil

# If enabled, skip the GET request to the Healthcheck endpoint to get the server version.
# The HEAD request is still done to check if the server is alive.
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename this property? There is somewhat of a health-check with the HEAD request. It isn't quite the same as checking the cluster health, but is somewhat similar. Maybe it should be skip_version_check?

Or an alternative would be to skip it only if default_server_major_version is not defined.

config :skip_healthcheck, :validate => :boolean, :default => false

# The OpenSearch server major version to use when it's not available from the Healthcheck endpoint.
config :default_server_major_version, :validate => :number, :default => 2
Copy link
Member

Choose a reason for hiding this comment

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

If the user skips the healthcheck, maybe it would be good to have them explicitly set the version? Otherwise, they might end up with unexpected behavior. I could go either way on it, but it seems that this advanced feature might require an explicit declaration on their part.

Thoughts? @deepdatta , @sshivanii

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, we can get rid of the skip_heathcheck config.
Put logic in get_version(url) to check if the response body is empty, if so use the default_server_major_version, if its not set then throw an exception. Thoughts @dlvenable, @sshivanii

Copy link
Member

Choose a reason for hiding this comment

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

@deepdatta , This sounds good. The one change I'd suggestion:
If the get_version(url) throws an exception (perhaps due to 404 or 403), then use default_server_major_version.

Again, if it is not set, we should throw an exception in that case.

Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

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

Thanks Deep!

@deepdatta deepdatta merged commit c184aa4 into opensearch-project:main Sep 1, 2022
@deepdatta deepdatta changed the title Adding a config to skip_healthcheck Adding a config for default_server_major_version Sep 6, 2022
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.

3 participants