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

Update ec2 secure settings #29134

Conversation

albertzaharovits
Copy link
Contributor

This is the analogous of #28517 for the ec2 client settings.

The approach is the same: use a client registry that allows for the client settings to change. Users should not cache the client, instead request one on each use.

Note:
This intentionally duplicates some code from the S3 reload settings PR. The factoring of the common bits will be done as the last step, when all reload requirements have been addressed.

@albertzaharovits albertzaharovits added >feature :Distributed/Discovery-Plugins Anything related to our integration plugins with EC2, GCP and Azure v7.0.0 v6.3.0 labels Mar 19, 2018
@albertzaharovits albertzaharovits self-assigned this Mar 19, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed

Copy link
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

left some minors. LGTM

public void close() throws IOException {
if (client != null) {
client.shutdown();
public AmazonEc2Reference client() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can generalizer this and maybe have a utils class in core that does what we do here. Operate on refcounted and maintain a map. Then we can also have a factory method and that way we share most of the logic. Maybe a followup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ This is becoming a pattern and the code is duplicated. I will do the refactoring as the last PR to this branch, to make sure I account for all distinctions of all use cases.

import org.elasticsearch.common.unit.TimeValue;
import java.util.Locale;

public class Ec2ClientSettings {
Copy link
Contributor

Choose a reason for hiding this comment

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

++ make the class final? and add a short javadoc?

for (int i=0; i<3; i++) {
provider.buildDynamicNodes();
assertThat(provider.fetchCount, is(1));
Thread.sleep(1_000L); // wait for cache to expire
Copy link
Contributor

Choose a reason for hiding this comment

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

while we are on it.. maybe there is a way to expire the cache manually without sleeping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To expire the cache manually it will require mocking the DiscoNodesCache which is part of what this test is about. I think we should not do this.
I think this is related to #28452 , which requires a more "smarter" discovery nodes cache. I will address this test in the scope of that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Discovery-Plugins Anything related to our integration plugins with EC2, GCP and Azure >feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants