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

Set retry-on-timeout=true for ES clients used by Telemetry devices #507

Merged
merged 2 commits into from
May 22, 2018

Conversation

dliappis
Copy link
Contributor

Closes #502

@dliappis dliappis added the enhancement Improves the status quo label May 18, 2018
Copy link
Member

@danielmitterdorfer danielmitterdorfer 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 the PR. I left a couple of suggestions.

@@ -69,6 +69,8 @@ def start(self):
for cluster_name, cluster_hosts in all_hosts.items():
all_client_options = self.cfg.opts("client", "options").all_client_options
cluster_client_options = all_client_options[cluster_name]
Copy link
Member

Choose a reason for hiding this comment

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

You are modifying the object in the config directly which leads to side-effects, see e.g. #472. Can you please make a copy with:

cluster_client_options = dict(all_client_options[cluster_name])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch thanks!

@@ -69,6 +69,8 @@ def start(self):
for cluster_name, cluster_hosts in all_hosts.items():
all_client_options = self.cfg.opts("client", "options").all_client_options
cluster_client_options = all_client_options[cluster_name]
# Use retries for telemetry connections: http://elasticsearch-py.readthedocs.io/en/latest/index.html#automatic-retries
Copy link
Member

Choose a reason for hiding this comment

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

Can you please explain the reason why we're doing this in the comment (e.g. to avoid aborts on long-living connections)?

@@ -69,6 +69,8 @@ def start(self):
for cluster_name, cluster_hosts in all_hosts.items():
all_client_options = self.cfg.opts("client", "options").all_client_options
cluster_client_options = all_client_options[cluster_name]
# Use retries for telemetry connections: http://elasticsearch-py.readthedocs.io/en/latest/index.html#automatic-retries
cluster_client_options.update({"retry-on-timeout": True})
Copy link
Member

Choose a reason for hiding this comment

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

Why not:

cluster_client_options["retry-on-timeout"] = True

retry_timeout_setting = {"retry-on-timeout": True}

for telemetry_device in cluster.telemetry.devices:
self.assertLessEqual(retry_timeout_setting.items(),telemetry_device.client.client_options.items())
Copy link
Member

Choose a reason for hiding this comment

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

We could use assertDictEqual here to check whether the client dictionary contains only expected options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thought here is that this test cares about ensuring that the specific option is set and we won't need to update it, if, for whatever reason, other client option settings, specified in the Class Attributes, change in the future. I don't mind changing it to what you are suggesting though.

@dliappis
Copy link
Contributor Author

Thanks for the review! I addressed the comments can you take another pass please?

@danielmitterdorfer danielmitterdorfer added the :Telemetry Telemetry Devices that gather additional metrics label May 22, 2018
@danielmitterdorfer danielmitterdorfer added this to the 0.12.0 milestone May 22, 2018
Copy link
Member

@danielmitterdorfer danielmitterdorfer left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@dliappis dliappis merged commit 3ec7cc1 into elastic:master May 22, 2018
@dliappis dliappis deleted the telemetry-retry-on-timeout branch May 22, 2018 09:13
@danielmitterdorfer danielmitterdorfer modified the milestones: 0.12.0, 1.0.0 May 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves the status quo :Telemetry Telemetry Devices that gather additional metrics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants