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

Refactor version number checks #1738

Merged
merged 14 commits into from
Jul 3, 2023
Merged

Conversation

b-deam
Copy link
Member

@b-deam b-deam commented Jun 20, 2023

Serverless Elasticsearch doesn't return a version.number field from the Info API (/) , which is actually something we rely on somewhat commonly throughout the codebase.

To fix this, we need a clearly defined way of determining whether or not Rally is talking to a Serverless Elasticsearch, this applies for both clients used to target the system under test, as well as any ancillary clients like those used by a remote metrics store.

In order to do so, we'll take two approaches:

  • Create a is_serverless | bool property on both existing and new 'serverless' specific clients
  • Refactor all version checks to default to selecting the 'minimum' version required for a specific conditional, and only use the is_serverless property if we need to do something specific for serverless

I think this is a balanced approach, given that serverless has no concept of 'versioning'.

Note:

The underlying client's use of .options() complicates things, because every call reinstantiates a new copy of itself, but without the ability for us to pass in any custom arguments (e.g. distribution_version). To work around this we must work out upfront whether or not we'd like the factory to create a serverless or non-serverless client, each of which have a static is_serverless attribute. Fixed in abf4320

Example tests
# http_logs with node-stats and data-stream-stats telemetry devices
esrally race --track http_logs --pipeline=benchmark-only --target-hosts https://serverless-es --client-options='{ "default": {"headers": {"X-Found-Cluster": "09895e10-efb8-42da-be30-888eb623d6cf.es"}, "basic_auth_user":"esbench", "basic_auth_password":"changeme", "verify_certs": false}}' --kill-running-processes --test-mode --track-params 'number_of_replicas: 1' --telemetry "node-stats, data-stream-stats"

# create-track
esrally create-track --track test --indices logs-221998 --target-hosts https://serverless-es --client-options '{ "default": {"headers": {"X-Found-Cluster": "09895e10-efb8-42da-be30-888eb623d6cf.es"}, "basic_auth_user":"elastic", "basic_auth_password":"changeme", "verify_certs": false}}'

@b-deam b-deam added :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc. discuss Needs further clarification from the team :internal Changes for internal, undocumented features: e.g. experimental, release scripts labels Jun 20, 2023
@b-deam b-deam self-assigned this Jun 20, 2023
@pquentin
Copy link
Member

buildkite build this please after #1739

@pquentin pquentin closed this Jun 20, 2023
@pquentin pquentin reopened this Jun 20, 2023
@b-deam b-deam force-pushed the verify-serverless branch from 4d89886 to 944d78c Compare June 21, 2023 02:56
@b-deam b-deam requested review from pquentin, dliappis and inqueue June 21, 2023 03:07
Comment on lines +187 to +188
elif is_serverless(distribution_version):
return "master"
Copy link
Member Author

@b-deam b-deam Jun 21, 2023

Choose a reason for hiding this comment

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

We only every select the master branch of rally-tracks when targeting a serverless cluster.

esrally/client/asynchronous.py Outdated Show resolved Hide resolved
esrally/client/asynchronous.py Outdated Show resolved Hide resolved
esrally/client/factory.py Show resolved Hide resolved
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks for iterating! That looks much better.

_mimetype_header_to_compat("Content-Type", request_headers)
# Not applicable to serverless
if not self.is_serverless:
if self.distribution_version is not None and (
Copy link
Member

Choose a reason for hiding this comment

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

Can we assume that distribution_version will be defined now?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can for the async client, just because we currently only create them in one place where we already know the distribution flavor/version. I mainly did this to be consistent between the two, but I think a better approach is to just check whether the value is a valid identifier as I've done in 5f2db54

Comment on lines 231 to 242
async def on_request_start(session, trace_config_ctx, params):
async_client.on_request_start()

async def on_request_end(session, trace_config_ctx, params):
async_client.on_request_end()

trace_config = aiohttp.TraceConfig()
trace_config.on_request_start.append(on_request_start)
trace_config.on_request_end.append(on_request_end)
# ensure that we also stop the timer when a request "ends" with an exception (e.g. a timeout)
trace_config.on_request_exception.append(on_request_end)

Copy link
Member

Choose a reason for hiding this comment

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

Would you mind reverting this change? (Move this back up and replace async_client with RallyAsyncElasticsearch in the async methods.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in 94d8634

_mimetype_header_to_compat("Accept", request_headers)
_mimetype_header_to_compat("Content-Type", request_headers)
if not self.is_serverless:
if self.distribution_version is not None and (
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

Copy link
Member Author

Choose a reason for hiding this comment

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

Addressed in 5f2db54

esrally/tracker/tracker.py Show resolved Hide resolved
).create()

info = client.info()
console.info(f"Connected to Elasticsearch cluster [{info['name']}] version [{info['version']['number']}].\n", logger=logger)
console.info(f"Connected to Elasticsearch cluster version [{distribution_version}]\n", logger=logger)
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 log the flavor too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that, but when you're targeting stateful elasticsearch you just get default back, which is a little confusing, so I just left it out entirely. Happy to include it if you think it's important though.

Copy link
Member

Choose a reason for hiding this comment

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

Yes I think it's important to have Rally confirm what sort of cluster it thinks it's benchmarking.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, addressed in 27f1f12. I've kicked off a long running test benchmark too. Will likely merge early next week.

@b-deam b-deam marked this pull request as ready for review June 22, 2023 00:58
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Thanks for all the iterations! LGTM. Only https://github.com/elastic/rally/pull/1738/files#r1238773617 left, but probably does not warrant another round.

Copy link
Contributor

@dliappis dliappis left a comment

Choose a reason for hiding this comment

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

LGTM thank you for this massive change!

@b-deam b-deam merged commit c3b04f4 into elastic:master Jul 3, 2023
@pquentin pquentin added this to the 2.9.0 milestone Aug 24, 2023
@pquentin pquentin removed the discuss Needs further clarification from the team label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:internal Changes for internal, undocumented features: e.g. experimental, release scripts :Load Driver Changes that affect the core of the load driver such as scheduling, the measurement approach etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants